From f9b68a313db86f0b2ef5435087b46b7ac19be56e Mon Sep 17 00:00:00 2001 From: Nadir K Amra Date: Fri, 3 Jan 2025 18:11:13 -0600 Subject: [PATCH 1/3] Fix due to lookup reply response missing Signed-off-by: Nadir K Amra --- .../java/com/ibm/as400/access/IFSFileDescriptorImplRemote.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/ibm/as400/access/IFSFileDescriptorImplRemote.java b/src/main/java/com/ibm/as400/access/IFSFileDescriptorImplRemote.java index 3528e732e..355620044 100644 --- a/src/main/java/com/ibm/as400/access/IFSFileDescriptorImplRemote.java +++ b/src/main/java/com/ibm/as400/access/IFSFileDescriptorImplRemote.java @@ -80,6 +80,7 @@ class IFSFileDescriptorImplRemote implements IFSFileDescriptorImpl AS400Server.addReplyStream(new IFSReturnCodeRep(), AS400.FILE); AS400Server.addReplyStream(new IFSWriteRep(), AS400.FILE); AS400Server.addReplyStream(new IFSReadRep(), AS400.FILE); + AS400Server.addReplyStream(new IFSLookupRep(), AS400.FILE); } From bf1ca777cb6099fbf7acce7b7e48703ed9a173e5 Mon Sep 17 00:00:00 2001 From: Nadir K Amra Date: Tue, 7 Jan 2025 16:33:32 -0600 Subject: [PATCH 2/3] Use default verification ID if not set Signed-off-by: Nadir K Amra --- .../com/ibm/as400/security/auth/ProfileTokenEnhancedInfo.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/ibm/as400/security/auth/ProfileTokenEnhancedInfo.java b/src/main/java/com/ibm/as400/security/auth/ProfileTokenEnhancedInfo.java index 462a43fe9..d1056b38d 100644 --- a/src/main/java/com/ibm/as400/security/auth/ProfileTokenEnhancedInfo.java +++ b/src/main/java/com/ibm/as400/security/auth/ProfileTokenEnhancedInfo.java @@ -86,7 +86,9 @@ public ProfileTokenEnhancedInfo(ProfileTokenEnhancedInfo enhancedInfo) { enhancedInfo.localPort_); } - public String getVerificationID() { return verificationID_; } + public String getVerificationID() { + return (verificationID_ != null) ? verificationID_ : ProfileTokenCredential.DEFAULT_VERIFICATION_ID; + } public String getRemoteIPAddress() { return remoteIPAddress_; } public int getRemotePort() { return remotePort_; } public String getLocalIPAddress() { return localIPAddress_; } From 0fb76d0e05538bfe276f785cd4da26af37a21a72 Mon Sep 17 00:00:00 2001 From: Nadir K Amra Date: Wed, 22 Jan 2025 10:16:24 -0600 Subject: [PATCH 3/3] Fix for issue https://github.com/IBM/JTOpen/issues/231 Signed-off-by: Nadir K Amra --- .../access/IFSFileDescriptorImplRemote.java | 310 ++++++++++-------- 1 file changed, 173 insertions(+), 137 deletions(-) diff --git a/src/main/java/com/ibm/as400/access/IFSFileDescriptorImplRemote.java b/src/main/java/com/ibm/as400/access/IFSFileDescriptorImplRemote.java index 355620044..aca752e92 100644 --- a/src/main/java/com/ibm/as400/access/IFSFileDescriptorImplRemote.java +++ b/src/main/java/com/ibm/as400/access/IFSFileDescriptorImplRemote.java @@ -639,8 +639,9 @@ public int getCCSID(boolean retrieveAll) throws IOException if (errorRC_ == IFSReturnCodeRep.FILE_NOT_FOUND || errorRC_ == IFSReturnCodeRep.PATH_NOT_FOUND) throw new ExtendedIOException(path_, ExtendedIOException.PATH_NOT_FOUND); - // Cannot create file handle to object, so let us try the other way - return getCCSID(); + // Cannot create file handle to object, so let us try the other way only + if (retrieveAll) + return getCCSID(); } } catch (AS400SecurityException e) { @@ -668,44 +669,52 @@ public int getCCSID() throws IOException { // In 7.5 and prior releases, need to create user handle for IFS tables to be initialized. userHandle = (getSystem().getVRM() <= 0x00070500) ? system_.createUserHandle() : 0; - - try - { - byte[] path = getConverter().stringToByteArray(path_); - - IFSLookupReq req = new IFSLookupReq(path, preferredServerCCSID_, userHandle, IFSLookupReq.OA12, IFSObjAttrs1.OWNERANAME_ASP_FLAS, 0); - ds = (ClientAccessDataStream) server_.sendAndReceive(req); - } - catch(ConnectionDroppedException e) + if (userHandle == UNINITIALIZED) { - Trace.log(Trace.ERROR, "Byte stream server connection lost."); - connectionDropped(e); - } - catch(InterruptedException e) - { - Trace.log(Trace.ERROR, "Interrupted"); - InterruptedIOException throwException = new InterruptedIOException(e.getMessage()); - throwException.initCause(e); - throw throwException; - } - - int rc = 0; - if (ds instanceof IFSLookupRep) - { - objectHandle = ((IFSLookupRep) ds).getHandle(); - retrieveAttributes(ds, objectHandle); - } - else if (ds instanceof IFSReturnCodeRep) - { - rc = ((IFSReturnCodeRep) ds).getReturnCode(); - if (rc != IFSReturnCodeRep.SUCCESS) Trace.log(Trace.ERROR, "IFSReturnCodeRep return code", rc); - - throw new ExtendedIOException(path_, rc); + IFSListAttrsRep reply = listObjAttrs2(); // the 'ccsid' field is in the OA2 structure + if (reply != null) + fileDataCCSID_ = reply.getCCSID(serverDatastreamLevel_); } else { - Trace.log(Trace.ERROR, "Unknown reply data stream", ds.getReqRepID()); - throw new InternalErrorException(Integer.toHexString(ds.getReqRepID()), InternalErrorException.DATA_STREAM_UNKNOWN); + try + { + byte[] path = getConverter().stringToByteArray(path_); + + IFSLookupReq req = new IFSLookupReq(path, preferredServerCCSID_, userHandle, IFSLookupReq.OA12, IFSObjAttrs1.OWNERANAME_ASP_FLAS, 0); + ds = (ClientAccessDataStream) server_.sendAndReceive(req); + } + catch(ConnectionDroppedException e) + { + Trace.log(Trace.ERROR, "Byte stream server connection lost."); + connectionDropped(e); + } + catch(InterruptedException e) + { + Trace.log(Trace.ERROR, "Interrupted"); + InterruptedIOException throwException = new InterruptedIOException(e.getMessage()); + throwException.initCause(e); + throw throwException; + } + + int rc = 0; + if (ds instanceof IFSLookupRep) + { + objectHandle = ((IFSLookupRep) ds).getHandle(); + retrieveAttributes(ds, objectHandle); + } + else if (ds instanceof IFSReturnCodeRep) + { + rc = ((IFSReturnCodeRep) ds).getReturnCode(); + if (rc != IFSReturnCodeRep.SUCCESS) Trace.log(Trace.ERROR, "IFSReturnCodeRep return code", rc); + + throw new ExtendedIOException(path_, rc); + } + else + { + Trace.log(Trace.ERROR, "Unknown reply data stream", ds.getReqRepID()); + throw new InternalErrorException(Integer.toHexString(ds.getReqRepID()), InternalErrorException.DATA_STREAM_UNKNOWN); + } } } finally @@ -1496,44 +1505,50 @@ public int getASP() throws IOException, AS400SecurityException { // In 7.5 and prior releases, need to create user handle for IFS tables to be initialized. userHandle = (getSystem().getVRM() <= 0x00070500) ? system_.createUserHandle() : 0; - - try - { - // Issue a Look up request to create an object handle. - IFSLookupReq req = new IFSLookupReq(pathname, preferredServerCCSID_, userHandle, IFSLookupReq.OA12, IFSObjAttrs1.OWNERANAME_ASP_FLAS, 0); - ds = (ClientAccessDataStream) server_.sendAndReceive(req); - } - catch(ConnectionDroppedException e) - { - Trace.log(Trace.ERROR, "Byte stream server connection lost."); - connectionDropped(e); - } - catch(InterruptedException e) - { - Trace.log(Trace.ERROR, "Interrupted"); - InterruptedIOException throwException = new InterruptedIOException(e.getMessage()); - throwException.initCause(e); - throw throwException; - } - - rc = 0; - if (ds instanceof IFSLookupRep) + if (userHandle == UNINITIALIZED) { - objectHandle = ((IFSLookupRep) ds).getHandle(); - retrieveAttributes(ds, objectHandle); //@AC7A - } - else if (ds instanceof IFSReturnCodeRep) - { - rc = ((IFSReturnCodeRep) ds).getReturnCode(); - if (rc != IFSReturnCodeRep.SUCCESS) - Trace.log(Trace.ERROR, "IFSReturnCodeRep return code", rc); - - throw new ExtendedIOException(path_, rc); + // Not sure what to do here...20.0.7 returned -1. So we do that same in 20.0.8. } else { - Trace.log(Trace.ERROR, "Unknown reply data stream", ds.getReqRepID()); - throw new InternalErrorException(Integer.toHexString(ds.getReqRepID()), InternalErrorException.DATA_STREAM_UNKNOWN); + try + { + // Issue a Look up request to create an object handle. + IFSLookupReq req = new IFSLookupReq(pathname, preferredServerCCSID_, userHandle, IFSLookupReq.OA12, IFSObjAttrs1.OWNERANAME_ASP_FLAS, 0); + ds = (ClientAccessDataStream) server_.sendAndReceive(req); + } + catch(ConnectionDroppedException e) + { + Trace.log(Trace.ERROR, "Byte stream server connection lost."); + connectionDropped(e); + } + catch(InterruptedException e) + { + Trace.log(Trace.ERROR, "Interrupted"); + InterruptedIOException throwException = new InterruptedIOException(e.getMessage()); + throwException.initCause(e); + throw throwException; + } + + rc = 0; + if (ds instanceof IFSLookupRep) + { + objectHandle = ((IFSLookupRep) ds).getHandle(); + retrieveAttributes(ds, objectHandle); //@AC7A + } + else if (ds instanceof IFSReturnCodeRep) + { + rc = ((IFSReturnCodeRep) ds).getReturnCode(); + if (rc != IFSReturnCodeRep.SUCCESS) + Trace.log(Trace.ERROR, "IFSReturnCodeRep return code", rc); + + throw new ExtendedIOException(path_, rc); + } + else + { + Trace.log(Trace.ERROR, "Unknown reply data stream", ds.getReqRepID()); + throw new InternalErrorException(Integer.toHexString(ds.getReqRepID()), InternalErrorException.DATA_STREAM_UNKNOWN); + } } } finally @@ -1566,43 +1581,58 @@ public String getOwnerNameByUserHandle(boolean forceRetrieve) throws IOException { // In 7.5 and prior releases, need to create user handle for IFS tables to be initialized. userHandle = (getSystem().getVRM() <= 0x00070500) ? system_.createUserHandle() : 0; - - try - { - // Issue a Look up request to create an object handle. - IFSLookupReq req = new IFSLookupReq(pathname, preferredServerCCSID_, userHandle, IFSLookupReq.OA12, IFSObjAttrs1.OWNERANAME_ASP_FLAS, 0); - ds = (ClientAccessDataStream) server_.sendAndReceive(req); - } - catch(ConnectionDroppedException e) - { - Trace.log(Trace.ERROR, "Byte stream server connection lost."); - connectionDropped(e); - } - catch(InterruptedException e) - { - Trace.log(Trace.ERROR, "Interrupted"); - InterruptedIOException throwException = new InterruptedIOException(e.getMessage()); - throwException.initCause(e); - throw throwException; - } - - // Verify that we got a handle back. - rc = 0; - if (ds instanceof IFSLookupRep) + if (userHandle == UNINITIALIZED) { - objectHandle = ((IFSLookupRep) ds).getHandle(); - retrieveAttributes(ds, objectHandle); //@AC7A + IFSListAttrsRep reply = listObjAttrs1(IFSObjAttrs1.OWNER_NAME_FLAG, 0); + if (reply != null) + fileOwnerName_ = reply.getOwnerName(system_.getCcsid()); + else + { + if (Trace.traceOn_) Trace.log(Trace.WARNING, "getOwnerNameByUserHandle: IFSReturnCodeRep return code", errorRC_); + + if (errorRC_ == IFSReturnCodeRep.FILE_NOT_FOUND || errorRC_ == IFSReturnCodeRep.PATH_NOT_FOUND) + throw new ExtendedIOException(path_, ExtendedIOException.PATH_NOT_FOUND); + } } - else if (ds instanceof IFSReturnCodeRep) - { - rc = ((IFSReturnCodeRep) ds).getReturnCode(); - if (rc != IFSReturnCodeRep.SUCCESS) Trace.log(Trace.ERROR, "IFSReturnCodeRep return code", rc); - throw new ExtendedIOException(path_, rc); - } else { - Trace.log(Trace.ERROR, "Unknown reply data stream", ds.getReqRepID()); - throw new InternalErrorException(Integer.toHexString(ds.getReqRepID()), InternalErrorException.DATA_STREAM_UNKNOWN); + try + { + // Issue a Look up request to create an object handle. + IFSLookupReq req = new IFSLookupReq(pathname, preferredServerCCSID_, userHandle, IFSLookupReq.OA12, IFSObjAttrs1.OWNERANAME_ASP_FLAS, 0); + ds = (ClientAccessDataStream) server_.sendAndReceive(req); + } + catch(ConnectionDroppedException e) + { + Trace.log(Trace.ERROR, "Byte stream server connection lost."); + connectionDropped(e); + } + catch(InterruptedException e) + { + Trace.log(Trace.ERROR, "Interrupted"); + InterruptedIOException throwException = new InterruptedIOException(e.getMessage()); + throwException.initCause(e); + throw throwException; + } + + // Verify that we got a handle back. + rc = 0; + if (ds instanceof IFSLookupRep) + { + objectHandle = ((IFSLookupRep) ds).getHandle(); + retrieveAttributes(ds, objectHandle); //@AC7A + } + else if (ds instanceof IFSReturnCodeRep) + { + rc = ((IFSReturnCodeRep) ds).getReturnCode(); + if (rc != IFSReturnCodeRep.SUCCESS) Trace.log(Trace.ERROR, "IFSReturnCodeRep return code", rc); + throw new ExtendedIOException(path_, rc); + } + else + { + Trace.log(Trace.ERROR, "Unknown reply data stream", ds.getReqRepID()); + throw new InternalErrorException(Integer.toHexString(ds.getReqRepID()), InternalErrorException.DATA_STREAM_UNKNOWN); + } } } finally @@ -1633,44 +1663,50 @@ public String getFileSystemType() throws IOException, AS400SecurityException try { userHandle = (getSystem().getVRM() <= 0x00070500) ? system_.createUserHandle() : 0; - - try - { - // Issue a Look up request to create an object handle. - IFSLookupReq req = new IFSLookupReq(pathname, preferredServerCCSID_, userHandle, IFSLookupReq.OA12, IFSObjAttrs1.OWNERANAME_ASP_FLAS, 0); - ds = (ClientAccessDataStream) server_.sendAndReceive(req); - } - catch(ConnectionDroppedException e) + if (userHandle == UNINITIALIZED) { - Trace.log(Trace.ERROR, "Byte stream server connection lost."); - connectionDropped(e); - } - catch(InterruptedException e) - { - Trace.log(Trace.ERROR, "Interrupted"); - InterruptedIOException throwException = new InterruptedIOException(e.getMessage()); - throwException.initCause(e); - throw throwException; - } - - rc = 0; - if (ds instanceof IFSLookupRep) - { - objectHandle = ((IFSLookupRep) ds).getHandle(); - retrieveAttributes(ds, objectHandle); //@AC7A - } - else if (ds instanceof IFSReturnCodeRep) - { - rc = ((IFSReturnCodeRep) ds).getReturnCode(); - if (rc != IFSReturnCodeRep.SUCCESS) - Trace.log(Trace.ERROR, "IFSReturnCodeRep return code", rc); - - throw new ExtendedIOException(path_, rc); + // Not sure what to do here...20.0.7 returned null string. For 20.0.8, return unknown. } else { - Trace.log(Trace.ERROR, "Unknown reply data stream", ds.getReqRepID()); - throw new InternalErrorException(Integer.toHexString(ds.getReqRepID()), InternalErrorException.DATA_STREAM_UNKNOWN); + try + { + // Issue a Look up request to create an object handle. + IFSLookupReq req = new IFSLookupReq(pathname, preferredServerCCSID_, userHandle, IFSLookupReq.OA12, IFSObjAttrs1.OWNERANAME_ASP_FLAS, 0); + ds = (ClientAccessDataStream) server_.sendAndReceive(req); + } + catch(ConnectionDroppedException e) + { + Trace.log(Trace.ERROR, "Byte stream server connection lost."); + connectionDropped(e); + } + catch(InterruptedException e) + { + Trace.log(Trace.ERROR, "Interrupted"); + InterruptedIOException throwException = new InterruptedIOException(e.getMessage()); + throwException.initCause(e); + throw throwException; + } + + rc = 0; + if (ds instanceof IFSLookupRep) + { + objectHandle = ((IFSLookupRep) ds).getHandle(); + retrieveAttributes(ds, objectHandle); //@AC7A + } + else if (ds instanceof IFSReturnCodeRep) + { + rc = ((IFSReturnCodeRep) ds).getReturnCode(); + if (rc != IFSReturnCodeRep.SUCCESS) + Trace.log(Trace.ERROR, "IFSReturnCodeRep return code", rc); + + throw new ExtendedIOException(path_, rc); + } + else + { + Trace.log(Trace.ERROR, "Unknown reply data stream", ds.getReqRepID()); + throw new InternalErrorException(Integer.toHexString(ds.getReqRepID()), InternalErrorException.DATA_STREAM_UNKNOWN); + } } } finally