java.lang.Object
org.codelibs.jcifs.smb.impl.NtlmPasswordAuthenticator
org.codelibs.jcifs.smb.impl.Kerb5Authenticator
- All Implemented Interfaces:
Serializable,Cloneable,Principal,Credentials,CredentialsInternal
- Direct Known Subclasses:
JAASAuthenticator
Base kerberos authenticator
Uses a subject that contains kerberos credentials for use in GSSAPI context establishment.
Be advised that short/NetBIOS name usage is not supported with this authenticator. Always specify full FQDNs.
This can be a problem if using DFS in it's default configuration as they still return referrals in short form.
See KB-244380 for compatible server configuration.
See
Configuration.isDfsConvertToFQDN() for a workaround.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.codelibs.jcifs.smb.impl.NtlmPasswordAuthenticator
NtlmPasswordAuthenticator.AuthenticationType -
Constructor Summary
ConstructorsConstructorDescriptionKerb5Authenticator(Subject subject) Construct aKerb5Authenticatorobject withSubjectwhich hold TGT retrieved from KDC.Kerb5Authenticator(Subject subject, String domain, String username, String password) Construct aKerb5Authenticatorobject withSubjectand potential NTLM fallback (if the server does not support kerberos). -
Method Summary
Modifier and TypeMethodDescriptionclone()Create a copy of the credentials.static voidClone the contextcreateContext(CIFSContext tc, String targetDomain, String host, byte[] initialToken, boolean doSigning) Create an SSP context for authentication.booleanCompares twoNtlmPasswordAuthenticationobjects for equality.intGet lifetime of this context.getRealm()Get the Kerberos realmGet the service name.Get theSubjectobject.getUser()Get the user name which authenticate against to.Returns the domain.intGet lifetime of current user.inthashCode()Return the upcased username hash code.booleanCheck if these are anonymous credentials.booleanisPreferredMech(org.bouncycastle.asn1.ASN1ObjectIdentifier mechanism) Check if the given mechanism is preferred for this credentialvoidrefresh()Refresh the credentials.voidsetForceFallback(boolean forceFallback) Testing only: force fallback to NTLMvoidsetLifeTime(int time) Set the lifetime for this context.voidSet the Kerberos realmvoidsetService(String name) Set the service name which is used to setupGSSContext.protected voidsetSubject(Subject subject) Set the Kerberos subjectvoidSet the user name which is used to setupGSSContext.voidsetUserLifeTime(int time) Set lifetime of current user.toString()Return the domain and username in the format:domain\\username.Methods inherited from class org.codelibs.jcifs.smb.impl.NtlmPasswordAuthenticator
cloneInternal, getAnsiHash, getName, getNTHash, getPassword, getSigningKey, getSpecifiedUserDomain, getUnicodeHash, getUsername, getUserSessionKey, getUserSessionKey, guessAuthenticationType, isGuest, unwrap
-
Constructor Details
-
Kerb5Authenticator
Construct aKerb5Authenticatorobject withSubjectwhich hold TGT retrieved from KDC. If multiple TGT are contained, the first one will be used to retrieve user principal.- Parameters:
subject- represents the user who perform Kerberos authentication. It contains tickets retrieve from KDC.
-
Kerb5Authenticator
Construct aKerb5Authenticatorobject withSubjectand potential NTLM fallback (if the server does not support kerberos).- Parameters:
subject- represents the user who perform Kerberos authentication. Should at least contain a TGT for the user.domain- domain for NTLM fallbackusername- user for NTLM fallbackpassword- password for NTLM fallback
-
-
Method Details
-
setForceFallback
public void setForceFallback(boolean forceFallback) Testing only: force fallback to NTLM- Parameters:
forceFallback- the forceFallback to set
-
createContext
public SSPContext createContext(CIFSContext tc, String targetDomain, String host, byte[] initialToken, boolean doSigning) throws SmbException Create an SSP context for authentication.- Specified by:
createContextin interfaceCredentialsInternal- Overrides:
createContextin classNtlmPasswordAuthenticator- Parameters:
tc- the CIFS contexttargetDomain- the target domain for authenticationhost- the target hostinitialToken- initial authentication token, if anydoSigning- whether message signing should be enabled- Returns:
- a new SSP authentication context
- Throws:
SmbException- if context creation fails- See Also:
-
setSubject
Set the Kerberos subject- Parameters:
subject- the subject to set
-
refresh
Description copied from interface:CredentialsInternalRefresh the credentials.- Specified by:
refreshin interfaceCredentialsInternal- Overrides:
refreshin classNtlmPasswordAuthenticator- Throws:
CIFSException- if refresh fails
-
clone
Description copied from interface:CredentialsInternalCreate a copy of the credentials.- Specified by:
clonein interfaceCredentialsInternal- Overrides:
clonein classNtlmPasswordAuthenticator- Returns:
- a copy of the credentials
-
cloneInternal
Clone the context- Parameters:
to- the target authenticatorfrom- the source authenticator
-
setUser
Set the user name which is used to setupGSSContext. If null is set, the default user will be used which is retrieved from the first TGT found inSubject.- Parameters:
name- the user name used to setupGSSContext
-
setRealm
Set the Kerberos realm- Parameters:
realm- the realm to set
-
getRealm
Get the Kerberos realm- Returns:
- the kerberos realm
-
getSubject
Get theSubjectobject.- Specified by:
getSubjectin interfaceCredentialsInternal- Overrides:
getSubjectin classNtlmPasswordAuthenticator- Returns:
- Subject represents the user who perform Kerberos authentication. It contains the tickets retrieve from KDC.
-
getUser
Get the user name which authenticate against to. If the default user is used, Null will be returned.- Returns:
- user name
-
setService
Set the service name which is used to setupGSSContext. Program will use this name to require service ticket from KDC.- Parameters:
name- the service name used to require service ticket from KDC.
-
getService
Get the service name.- Returns:
- the service name used to require service ticket from KDC
-
getUserLifeTime
public int getUserLifeTime()Get lifetime of current user.- Returns:
- the remaining lifetime in seconds. If the default lifetime is used, this value have no meaning.
-
setUserLifeTime
public void setUserLifeTime(int time) Set lifetime of current user.- Parameters:
time- the lifetime in seconds
-
getLifeTime
public int getLifeTime()Get lifetime of this context.- Returns:
- the remaining lifetime in seconds. If the default lifetime is used, this value have no meaning.
-
setLifeTime
public void setLifeTime(int time) Set the lifetime for this context.- Parameters:
time- the lifetime in seconds
-
isAnonymous
public boolean isAnonymous()Check if these are anonymous credentials.- Specified by:
isAnonymousin interfaceCredentials- Overrides:
isAnonymousin classNtlmPasswordAuthenticator- Returns:
- whether these are anonymous credentials
- See Also:
-
isPreferredMech
public boolean isPreferredMech(org.bouncycastle.asn1.ASN1ObjectIdentifier mechanism) Check if the given mechanism is preferred for this credential- Overrides:
isPreferredMechin classNtlmPasswordAuthenticator- Parameters:
mechanism- the mechanism to check- Returns:
- whether the given mechanism is the preferred one for this credential
- See Also:
-
toString
Return the domain and username in the format:domain\\username. This is equivalent togetName().- Specified by:
toStringin interfacePrincipal- Overrides:
toStringin classNtlmPasswordAuthenticator- See Also:
-
equals
Compares twoNtlmPasswordAuthenticationobjects for equality. TwoNtlmPasswordAuthenticationobjects are equal if their caseless domain and username fields are equal- Specified by:
equalsin interfacePrincipal- Overrides:
equalsin classNtlmPasswordAuthenticator- See Also:
-
hashCode
public int hashCode()Return the upcased username hash code.- Specified by:
hashCodein interfacePrincipal- Overrides:
hashCodein classNtlmPasswordAuthenticator- See Also:
-
getUserDomain
Description copied from class:NtlmPasswordAuthenticatorReturns the domain.- Specified by:
getUserDomainin interfaceCredentials- Overrides:
getUserDomainin classNtlmPasswordAuthenticator- Returns:
- the domain the user account is in
-