Package jcifs.smb

Class SmbSession


  • public final class SmbSession
    extends java.lang.Object
    The class represents a user's session established with an SMB/CIFS server. This class is used internally to the jCIFS library however applications may wish to authenticate aribrary user credentials with the logon method. It is noteworthy that jCIFS does not support DCE/RPC at this time and therefore does not use the NETLOGON procedure. Instead, it simply performs a "tree connect" to IPC$ using the supplied credentials. This is only a subset of the NETLOGON procedure but is achives the same effect. Note that it is possible to change the resource against which clients are authenticated to be something other than IPC$ using the jcifs.smb.client.logonShare property. This can be used to provide simple group based access control. For example, one could setup the NTLM HTTP Filter with the jcifs.smb.client.domainController init parameter set to the name of the server used for authentication. On that host, create a share called JCIFSAUTH and adjust the access control list for that share to permit only the clients that should have access to the target website. Finally, set the jcifs.smb.client.logonShare to JCIFSAUTH. This should restrict access to only those clients that have access to the JCIFSAUTH share. The access control on that share can be changed without changing init parameters or reinitializing the webapp.
    • Method Detail

      • getChallenge

        public static byte[] getChallenge​(UniAddress dc)
                                   throws SmbException,
                                          java.net.UnknownHostException
        Throws:
        SmbException
        java.net.UnknownHostException
      • getChallenge

        public static byte[] getChallenge​(UniAddress dc,
                                          int port)
                                   throws SmbException,
                                          java.net.UnknownHostException
        Throws:
        SmbException
        java.net.UnknownHostException
      • logon

        public static void logon​(UniAddress dc,
                                 NtlmPasswordAuthentication auth)
                          throws SmbException
        Authenticate arbitrary credentials represented by the NtlmPasswordAuthentication object against the domain controller specified by the UniAddress parameter. If the credentials are not accepted, an SmbAuthException will be thrown. If an error occurs an SmbException will be thrown. If the credentials are valid, the method will return without throwing an exception. See the last FAQ question. See also the jcifs.smb.client.logonShare property.
        Throws:
        SmbException
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object