private ReferralResult sendDfsReferralRequest(DfsRequestType type, String hostName, Session session, DFSPath path) throws DFSException { // The client MUST initiate a server session with the SMB server, as specified in [MS-CIFS] section 3.4.4.7, // by passing HostName and UserCredentials as input parameters and receiving an opaque ClientGenericContext, // as specified in [MS-CIFS] section 3.4. // The client MUST search for an existing Session and TreeConnect to any share on the server identified by // ServerName for the user identified by UserCredentials. If no Session and TreeConnect are found, the client // MUST establish a new Session and TreeConnect to IPC$ on the target server as described in section 3.2.4.2 // using the supplied ServerName and UserCredentials Session dfsSession = session; if (!hostName.equals(session.getConnection().getRemoteHostname())) { AuthenticationContext auth = session.getAuthenticationContext(); Connection oldConnection = session.getConnection(); Connection connection; try { connection = oldConnection.getClient().connect(hostName); // TODO } catch (IOException e) { throw new DFSException(e); } dfsSession = connection.authenticate(auth); } try (Share dfsShare = dfsSession.connectShare("IPC$")) { return getReferral(type, dfsShare, path); } catch (Buffer.BufferException | IOException e) { throw new DFSException(e); } }
private ReferralResult sendDfsReferralRequest(DfsRequestType type, String hostName, Session session, DFSPath path) throws DFSException { // The client MUST initiate a server session with the SMB server, as specified in [MS-CIFS] section 3.4.4.7, // by passing HostName and UserCredentials as input parameters and receiving an opaque ClientGenericContext, // as specified in [MS-CIFS] section 3.4. // The client MUST search for an existing Session and TreeConnect to any share on the server identified by // ServerName for the user identified by UserCredentials. If no Session and TreeConnect are found, the client // MUST establish a new Session and TreeConnect to IPC$ on the target server as described in section 3.2.4.2 // using the supplied ServerName and UserCredentials Session dfsSession = session; if (!hostName.equals(session.getConnection().getRemoteHostname())) { AuthenticationContext auth = session.getAuthenticationContext(); Connection oldConnection = session.getConnection(); Connection connection; try { connection = oldConnection.getClient().connect(hostName); // TODO } catch (IOException e) { throw new DFSException(e); } dfsSession = connection.authenticate(auth); } try (Share dfsShare = dfsSession.connectShare("IPC$")) { return getReferral(type, dfsShare, path); } catch (Buffer.BufferException | IOException e) { throw new DFSException(e); } }