Package jcifs.smb

Class NtlmPasswordAuthenticator

    • Constructor Detail

      • NtlmPasswordAuthenticator

        public NtlmPasswordAuthenticator()
        Construct anonymous credentials
      • NtlmPasswordAuthenticator

        public NtlmPasswordAuthenticator​(String username,
                                         String password)
        Create username/password credentials
        Parameters:
        username -
        password -
      • NtlmPasswordAuthenticator

        public NtlmPasswordAuthenticator​(String domain,
                                         String username,
                                         String password)
        Create username/password credentials with specified domain
        Parameters:
        domain -
        username -
        password -
      • NtlmPasswordAuthenticator

        protected NtlmPasswordAuthenticator​(String userInfo,
                                            String defDomain,
                                            String defUser,
                                            String defPassword)
    • Method Detail

      • unwrap

        public <T extends Credentials> T unwrap​(Class<T> t)
        Specified by:
        unwrap in interface Credentials
        Returns:
        instance for type, null if the type cannot be unwrapped
      • getUserDomain

        public String getUserDomain()
        Returns the domain.
        Specified by:
        getUserDomain in interface Credentials
        Returns:
        the domain the user account is in
      • getSpecifiedUserDomain

        public String getSpecifiedUserDomain()
        Returns:
        the original specified user domain
      • getUsername

        public String getUsername()
        Returns the username.
        Returns:
        the username
      • getPassword

        public String getPassword()
        Returns the password in plain text or null if the raw password hashes were used to construct this NtlmPasswordAuthentication object which will be the case when NTLM HTTP Authentication is used. There is no way to retrieve a users password in plain text unless it is supplied by the user at runtime.
        Returns:
        the password
      • getName

        public String getName()
        Return the domain and username in the format: domain\\username. This is equivalent to toString().
        Specified by:
        getName in interface Principal
      • equals

        public boolean equals​(Object obj)
        Compares two NtlmPasswordAuthentication objects for equality. Two NtlmPasswordAuthentication objects are equal if their caseless domain and username fields are equal
        Specified by:
        equals in interface Principal
        Overrides:
        equals in class Object
        See Also:
        Object.equals(java.lang.Object)
      • hashCode

        public int hashCode()
        Return the upcased username hash code.
        Specified by:
        hashCode in interface Principal
        Overrides:
        hashCode in class Object
      • toString

        public String toString()
        Return the domain and username in the format: domain\\username. This is equivalent to getName().
        Specified by:
        toString in interface Principal
        Overrides:
        toString in class Object
      • isAnonymous

        public boolean isAnonymous()
        Specified by:
        isAnonymous in interface Credentials
        Returns:
        whether these are anonymous credentials
      • isGuest

        public boolean isGuest()
        Specified by:
        isGuest in interface Credentials
        Returns:
        whether these are guest credentials
      • isPreferredMech

        public boolean isPreferredMech​(org.bouncycastle.asn1.ASN1ObjectIdentifier mechanism)
        Parameters:
        mechanism -
        Returns:
        whether the given mechanism is the preferred one for this credential
      • getUserSessionKey

        public byte[] getUserSessionKey​(CIFSContext tc,
                                        byte[] chlng)
        Returns the effective user session key.
        Parameters:
        tc -
        chlng - The server challenge.
        Returns:
        A byte[] containing the effective user session key, used in SMB MAC signing and NTLMSSP signing and sealing.
      • getUserSessionKey

        public void getUserSessionKey​(CIFSContext tc,
                                      byte[] chlng,
                                      byte[] dest,
                                      int offset)
                               throws SmbException
        Calculates the effective user session key.
        Parameters:
        tc - context to use
        chlng - The server challenge.
        dest - The destination array in which the user session key will be placed.
        offset - The offset in the destination array at which the session key will start.
        Throws:
        SmbException
      • getNTHash

        protected byte[] getNTHash()
        Returns: