Package com.unboundid.ldap.sdk
Class GSSAPIBindRequest
java.lang.Object
com.unboundid.ldap.sdk.LDAPRequest
com.unboundid.ldap.sdk.BindRequest
com.unboundid.ldap.sdk.SASLBindRequest
com.unboundid.ldap.sdk.GSSAPIBindRequest
- All Implemented Interfaces:
ReadOnlyLDAPRequest,Serializable,PrivilegedExceptionAction<Object>,CallbackHandler
@NotMutable
@ThreadSafety(level=NOT_THREADSAFE)
public final class GSSAPIBindRequest
extends SASLBindRequest
implements CallbackHandler, PrivilegedExceptionAction<Object>
This class provides a SASL GSSAPI bind request implementation as described in
RFC 4752. It provides the
ability to authenticate to a directory server using Kerberos V, which can
serve as a kind of single sign-on mechanism that may be shared across
client applications that support Kerberos.
This class uses the Java Authentication and Authorization Service (JAAS) behind the scenes to perform all Kerberos processing. This framework requires a configuration file to indicate the underlying mechanism to be used. It is possible for clients to explicitly specify the path to the configuration file that should be used, but if none is given then a default file will be created and used. This default file should be sufficient for Sun-provided JVMs, but a custom file may be required for JVMs provided by other vendors.
Elements included in a GSSAPI bind request include:
This class uses the Java Authentication and Authorization Service (JAAS) behind the scenes to perform all Kerberos processing. This framework requires a configuration file to indicate the underlying mechanism to be used. It is possible for clients to explicitly specify the path to the configuration file that should be used, but if none is given then a default file will be created and used. This default file should be sufficient for Sun-provided JVMs, but a custom file may be required for JVMs provided by other vendors.
Elements included in a GSSAPI bind request include:
- Authentication ID -- A string which identifies the user that is attempting to authenticate. It should be the user's Kerberos principal.
- Authorization ID -- An optional string which specifies an alternate authorization identity that should be used for subsequent operations requested on the connection. Like the authentication ID, the authorization ID should be a Kerberos principal.
- KDC Address -- An optional string which specifies the IP address or resolvable name for the Kerberos key distribution center. If this is not provided, an attempt will be made to determine the appropriate value from the system configuration.
- Realm -- An optional string which specifies the realm into which the user should authenticate. If this is not provided, an attempt will be made to determine the appropriate value from the system configuration
- Password -- The clear-text password for the target user in the Kerberos realm.
Example
The following example demonstrates the process for performing a GSSAPI bind against a directory server with a username of "john.doe" and a password of "password":
GSSAPIBindRequestProperties gssapiProperties =
new GSSAPIBindRequestProperties("john.doe@EXAMPLE.COM", "password");
gssapiProperties.setKDCAddress("kdc.example.com");
gssapiProperties.setRealm("EXAMPLE.COM");
GSSAPIBindRequest bindRequest =
new GSSAPIBindRequest(gssapiProperties);
BindResult bindResult;
try
{
bindResult = connection.bind(bindRequest);
// If we get here, then the bind was successful.
}
catch (LDAPException le)
{
// The bind failed for some reason.
bindResult = new BindResult(le.toLDAPResult());
ResultCode resultCode = le.getResultCode();
String errorMessageFromServer = le.getDiagnosticMessage();
}
- See Also:
-
Field Summary
FieldsFields inherited from class com.unboundid.ldap.sdk.SASLBindRequest
CRED_TYPE_SASLFields inherited from class com.unboundid.ldap.sdk.BindRequest
VERSION_ELEMENT -
Constructor Summary
ConstructorsConstructorDescriptionGSSAPIBindRequest(GSSAPIBindRequestProperties gssapiProperties, Control... controls) Creates a new SASL GSSAPI bind request with the provided set of properties.GSSAPIBindRequest(String authenticationID, byte[] password) Creates a new SASL GSSAPI bind request with the provided authentication ID and password.GSSAPIBindRequest(String authenticationID, byte[] password, Control[] controls) Creates a new SASL GSSAPI bind request with the provided authentication ID and password.GSSAPIBindRequest(String authenticationID, String password) Creates a new SASL GSSAPI bind request with the provided authentication ID and password.GSSAPIBindRequest(String authenticationID, String authorizationID, byte[] password, String realm, String kdcAddress, String configFilePath) Creates a new SASL GSSAPI bind request with the provided information.GSSAPIBindRequest(String authenticationID, String authorizationID, byte[] password, String realm, String kdcAddress, String configFilePath, Control[] controls) Creates a new SASL GSSAPI bind request with the provided information.GSSAPIBindRequest(String authenticationID, String password, Control[] controls) Creates a new SASL GSSAPI bind request with the provided authentication ID and password.GSSAPIBindRequest(String authenticationID, String authorizationID, String password, String realm, String kdcAddress, String configFilePath) Creates a new SASL GSSAPI bind request with the provided information.GSSAPIBindRequest(String authenticationID, String authorizationID, String password, String realm, String kdcAddress, String configFilePath, Control[] controls) Creates a new SASL GSSAPI bind request with the provided information. -
Method Summary
Modifier and TypeMethodDescriptionCreates a new instance of this LDAP request that may be modified without impacting this request.Creates a new instance of this LDAP request that may be modified without impacting this request.booleanIndicates whether JVM-level debugging should be enabled for GSSAPI bind processing.Retrieves the list of allowed qualities of protection that may be used for communication that occurs on the connection after the authentication has completed, in order from most preferred to least preferred.Retrieves the authentication ID for the GSSAPI bind request, if defined.Retrieves the authorization ID for this bind request, if any.Retrieves the type of channel binding that should be used for this GSSAPI bind request.Retrieves the path to the JAAS configuration file that will be used during authentication processing.Indicates whether the client should be configured so that it explicitly indicates whether it is the initiator or the acceptor.Retrieves the address of the Kerberos key distribution center.Retrieves the path to the keytab file from which to obtain the user credentials.intRetrieves the message ID for the last LDAP message sent using this request.byte[]Retrieves the bytes that comprise the the password for this bind request, if defined.Retrieves the string representation of the password for this bind request, if defined.getRealm()Retrieves the realm for this bind request, if any.getRebindRequest(String host, int port) Retrieves a bind request that may be used to re-bind using the same credentials authentication type and credentials as previously used to perform the initial bind.Retrieves the name of the SASL mechanism used in this SASL bind request.Retrieves the protocol specified in the service principal that the directory server uses for its communication with the KDC.Retrieves a set of system properties that will not be altered by GSSAPI processing.Retrieves the path to the Kerberos ticket cache file that should be used during authentication, if defined.voidHandles any necessary callbacks required for SASL authentication.protected BindResultprocess(LDAPConnection connection, int depth) Sends this bind request to the target server over the provided connection and returns the corresponding response.booleanIndicates whether to refresh the configuration before the JAASloginmethod is called.booleanrenewTGT()Indicates whether to attempt to renew the client's ticket-granting ticket (TGT) if an existing Kerberos session is used to authenticate.booleanIndicates whether GSSAPI authentication should only occur using an existing Kerberos session.run()Perform the privileged portion of the authentication processing.voidAppends a number of lines comprising the Java source code that can be used to recreate this request to the given list.voidtoString(StringBuilder buffer) Appends a string representation of this request to the provided buffer.booleanIndicates whether to use a keytab to obtain the user credentials.booleanIndicates whether to allow the client to use credentials that are outside of the current subject, obtained via some system-specific mechanism.booleanIndicates whether to enable the use of a ticket cache to to avoid the need to supply credentials if the client already has an existing Kerberos session.Methods inherited from class com.unboundid.ldap.sdk.SASLBindRequest
getBindType, responseReceived, sendBindRequest, sendMessageMethods inherited from class com.unboundid.ldap.sdk.BindRequest
getOperationTypeMethods inherited from class com.unboundid.ldap.sdk.LDAPRequest
followReferrals, getControl, getControlList, getControls, getIntermediateResponseListener, getReferralConnector, getReferralConnectorInternal, getReferralDepth, getResponseTimeoutMillis, hasControl, hasControl, setFollowReferrals, setIntermediateResponseListener, setReferralConnector, setReferralDepth, setResponseTimeoutMillis, toString
-
Field Details
-
GSSAPI_MECHANISM_NAME
The name for the GSSAPI SASL mechanism.- See Also:
-
-
Constructor Details
-
GSSAPIBindRequest
public GSSAPIBindRequest(@NotNull String authenticationID, @NotNull String password) throws LDAPException Creates a new SASL GSSAPI bind request with the provided authentication ID and password.- Parameters:
authenticationID- The authentication ID for this bind request. It must not benull.password- The password for this bind request. It must not benull.- Throws:
LDAPException- If a problem occurs while creating the JAAS configuration file to use during authentication processing.
-
GSSAPIBindRequest
public GSSAPIBindRequest(@NotNull String authenticationID, @NotNull byte[] password) throws LDAPException Creates a new SASL GSSAPI bind request with the provided authentication ID and password.- Parameters:
authenticationID- The authentication ID for this bind request. It must not benull.password- The password for this bind request. It must not benull.- Throws:
LDAPException- If a problem occurs while creating the JAAS configuration file to use during authentication processing.
-
GSSAPIBindRequest
public GSSAPIBindRequest(@NotNull String authenticationID, @NotNull String password, @Nullable Control[] controls) throws LDAPException Creates a new SASL GSSAPI bind request with the provided authentication ID and password.- Parameters:
authenticationID- The authentication ID for this bind request. It must not benull.password- The password for this bind request. It must not benull.controls- The set of controls to include in the request.- Throws:
LDAPException- If a problem occurs while creating the JAAS configuration file to use during authentication processing.
-
GSSAPIBindRequest
public GSSAPIBindRequest(@NotNull String authenticationID, @NotNull byte[] password, @Nullable Control[] controls) throws LDAPException Creates a new SASL GSSAPI bind request with the provided authentication ID and password.- Parameters:
authenticationID- The authentication ID for this bind request. It must not benull.password- The password for this bind request. It must not benull.controls- The set of controls to include in the request.- Throws:
LDAPException- If a problem occurs while creating the JAAS configuration file to use during authentication processing.
-
GSSAPIBindRequest
public GSSAPIBindRequest(@NotNull String authenticationID, @Nullable String authorizationID, @NotNull String password, @Nullable String realm, @Nullable String kdcAddress, @Nullable String configFilePath) throws LDAPException Creates a new SASL GSSAPI bind request with the provided information.- Parameters:
authenticationID- The authentication ID for this bind request. It must not benull.authorizationID- The authorization ID for this bind request. It may benullif no alternate authorization ID should be used.password- The password for this bind request. It must not benull.realm- The realm to use for the authentication. It may benullto attempt to use the default realm from the system configuration.kdcAddress- The address of the Kerberos key distribution center. It may benullto attempt to use the default KDC from the system configuration.configFilePath- The path to the JAAS configuration file to use for the authentication processing. It may benullto use the default JAAS configuration.- Throws:
LDAPException- If a problem occurs while creating the JAAS configuration file to use during authentication processing.
-
GSSAPIBindRequest
public GSSAPIBindRequest(@NotNull String authenticationID, @Nullable String authorizationID, @NotNull byte[] password, @Nullable String realm, @Nullable String kdcAddress, @Nullable String configFilePath) throws LDAPException Creates a new SASL GSSAPI bind request with the provided information.- Parameters:
authenticationID- The authentication ID for this bind request. It must not benull.authorizationID- The authorization ID for this bind request. It may benullif no alternate authorization ID should be used.password- The password for this bind request. It must not benull.realm- The realm to use for the authentication. It may benullto attempt to use the default realm from the system configuration.kdcAddress- The address of the Kerberos key distribution center. It may benullto attempt to use the default KDC from the system configuration.configFilePath- The path to the JAAS configuration file to use for the authentication processing. It may benullto use the default JAAS configuration.- Throws:
LDAPException- If a problem occurs while creating the JAAS configuration file to use during authentication processing.
-
GSSAPIBindRequest
public GSSAPIBindRequest(@NotNull String authenticationID, @Nullable String authorizationID, @NotNull String password, @Nullable String realm, @Nullable String kdcAddress, @Nullable String configFilePath, @Nullable Control[] controls) throws LDAPException Creates a new SASL GSSAPI bind request with the provided information.- Parameters:
authenticationID- The authentication ID for this bind request. It must not benull.authorizationID- The authorization ID for this bind request. It may benullif no alternate authorization ID should be used.password- The password for this bind request. It must not benull.realm- The realm to use for the authentication. It may benullto attempt to use the default realm from the system configuration.kdcAddress- The address of the Kerberos key distribution center. It may benullto attempt to use the default KDC from the system configuration.configFilePath- The path to the JAAS configuration file to use for the authentication processing. It may benullto use the default JAAS configuration.controls- The set of controls to include in the request.- Throws:
LDAPException- If a problem occurs while creating the JAAS configuration file to use during authentication processing.
-
GSSAPIBindRequest
public GSSAPIBindRequest(@NotNull String authenticationID, @Nullable String authorizationID, @NotNull byte[] password, @Nullable String realm, @Nullable String kdcAddress, @Nullable String configFilePath, @Nullable Control[] controls) throws LDAPException Creates a new SASL GSSAPI bind request with the provided information.- Parameters:
authenticationID- The authentication ID for this bind request. It must not benull.authorizationID- The authorization ID for this bind request. It may benullif no alternate authorization ID should be used.password- The password for this bind request. It must not benull.realm- The realm to use for the authentication. It may benullto attempt to use the default realm from the system configuration.kdcAddress- The address of the Kerberos key distribution center. It may benullto attempt to use the default KDC from the system configuration.configFilePath- The path to the JAAS configuration file to use for the authentication processing. It may benullto use the default JAAS configuration.controls- The set of controls to include in the request.- Throws:
LDAPException- If a problem occurs while creating the JAAS configuration file to use during authentication processing.
-
GSSAPIBindRequest
public GSSAPIBindRequest(@NotNull GSSAPIBindRequestProperties gssapiProperties, @Nullable Control... controls) throws LDAPException Creates a new SASL GSSAPI bind request with the provided set of properties.- Parameters:
gssapiProperties- The set of properties that should be used for the GSSAPI bind request. It must not benull.controls- The set of controls to include in the request.- Throws:
LDAPException- If a problem occurs while creating the JAAS configuration file to use during authentication processing.
-
-
Method Details
-
getSASLMechanismName
Retrieves the name of the SASL mechanism used in this SASL bind request.- Specified by:
getSASLMechanismNamein classSASLBindRequest- Returns:
- The name of the SASL mechanism used in this SASL bind request.
-
getAuthenticationID
Retrieves the authentication ID for the GSSAPI bind request, if defined.- Returns:
- The authentication ID for the GSSAPI bind request, or
nullif an existing Kerberos session should be used.
-
getAuthorizationID
Retrieves the authorization ID for this bind request, if any.- Returns:
- The authorization ID for this bind request, or
nullif there should not be a separate authorization identity.
-
getPasswordString
Retrieves the string representation of the password for this bind request, if defined.- Returns:
- The string representation of the password for this bind request,
or
nullif an existing Kerberos session should be used.
-
getPasswordBytes
Retrieves the bytes that comprise the the password for this bind request, if defined.- Returns:
- The bytes that comprise the password for this bind request, or
nullif an existing Kerberos session should be used.
-
getRealm
Retrieves the realm for this bind request, if any.- Returns:
- The realm for this bind request, or
nullif none was defined and the client should attempt to determine the realm from the system configuration.
-
getAllowedQoP
Retrieves the list of allowed qualities of protection that may be used for communication that occurs on the connection after the authentication has completed, in order from most preferred to least preferred.- Returns:
- The list of allowed qualities of protection that may be used for communication that occurs on the connection after the authentication has completed, in order from most preferred to least preferred.
-
getKDCAddress
Retrieves the address of the Kerberos key distribution center.- Returns:
- The address of the Kerberos key distribution center, or
nullif none was defined and the client should attempt to determine the KDC address from the system configuration.
-
getConfigFilePath
Retrieves the path to the JAAS configuration file that will be used during authentication processing.- Returns:
- The path to the JAAS configuration file that will be used during authentication processing.
-
getServicePrincipalProtocol
Retrieves the protocol specified in the service principal that the directory server uses for its communication with the KDC.- Returns:
- The protocol specified in the service principal that the directory server uses for its communication with the KDC.
-
refreshKrb5Config
Indicates whether to refresh the configuration before the JAASloginmethod is called.- Returns:
trueif the GSSAPI implementation should refresh the configuration before the JAASloginmethod is called, orfalseif not.
-
useKeyTab
Indicates whether to use a keytab to obtain the user credentials.- Returns:
trueif the GSSAPI login attempt should use a keytab to obtain the user credentials, orfalseif not.
-
getKeyTabPath
Retrieves the path to the keytab file from which to obtain the user credentials. This will only be used ifuseKeyTabreturnstrue.- Returns:
- The path to the keytab file from which to obtain the user
credentials, or
nullif the default keytab location should be used.
-
useTicketCache
Indicates whether to enable the use of a ticket cache to to avoid the need to supply credentials if the client already has an existing Kerberos session.- Returns:
trueif a ticket cache may be used to take advantage of an existing Kerberos session, orfalseif Kerberos credentials should always be provided.
-
requireCachedCredentials
Indicates whether GSSAPI authentication should only occur using an existing Kerberos session.- Returns:
trueif GSSAPI authentication should only use an existing Kerberos session and should fail if the client does not have an existing session, orfalseif the client will be allowed to create a new session if one does not already exist.
-
getTicketCachePath
Retrieves the path to the Kerberos ticket cache file that should be used during authentication, if defined.- Returns:
- The path to the Kerberos ticket cache file that should be used
during authentication, or
nullif the default ticket cache file should be used.
-
renewTGT
Indicates whether to attempt to renew the client's ticket-granting ticket (TGT) if an existing Kerberos session is used to authenticate.- Returns:
trueif the client should attempt to renew its ticket-granting ticket if the authentication is processed using an existing Kerberos session, orfalseif not.
-
useSubjectCredentialsOnly
Indicates whether to allow the client to use credentials that are outside of the current subject, obtained via some system-specific mechanism.- Returns:
trueif the client will only be allowed to use credentials that are within the current subject, orfalseif the client will be allowed to use credentials outside the current subject.
-
getIsInitiator
Indicates whether the client should be configured so that it explicitly indicates whether it is the initiator or the acceptor.- Returns:
Boolean.TRUEif the client should explicitly indicate that it is the GSSAPI initiator,Boolean.FALSEif the client should explicitly indicate that it is the GSSAPI acceptor, ornullif the client should not explicitly indicate either state (which is the default behavior unless theGSSAPIBindRequestProperties.setIsInitiator(java.lang.Boolean)method has been used to explicitly specify a value).
-
getSuppressedSystemProperties
Retrieves a set of system properties that will not be altered by GSSAPI processing.- Returns:
- A set of system properties that will not be altered by GSSAPI processing.
-
getChannelBindingType
Retrieves the type of channel binding that should be used for this GSSAPI bind request.- Returns:
- The type of channel binding that should be used for this GSSAPI
bind request, or
GSSAPIChannelBindingType.NONEif no channel binding should be used.
-
enableGSSAPIDebugging
Indicates whether JVM-level debugging should be enabled for GSSAPI bind processing.- Returns:
trueif JVM-level debugging should be enabled for GSSAPI bind processing, orfalseif not.
-
process
@NotNull protected BindResult process(@NotNull LDAPConnection connection, int depth) throws LDAPException Sends this bind request to the target server over the provided connection and returns the corresponding response.- Specified by:
processin classBindRequest- Parameters:
connection- The connection to use to send this bind request to the server and read the associated response.depth- The current referral depth for this request. It should always be one for the initial request, and should only be incremented when following referrals.- Returns:
- The bind response read from the server.
- Throws:
LDAPException- If a problem occurs while sending the request or reading the response.
-
run
Perform the privileged portion of the authentication processing.- Specified by:
runin interfacePrivilegedExceptionAction<Object>- Returns:
null, since no return value is actually needed.- Throws:
LDAPException- If a problem occurs during processing.
-
getRebindRequest
Retrieves a bind request that may be used to re-bind using the same credentials authentication type and credentials as previously used to perform the initial bind. This may be used in an attempt to automatically re-establish a connection that is lost, or potentially when following a referral to another directory instance.
It is recommended that all bind request types which implement this capability be implemented so that the elements needed to create a new request are immutable. If this is not done, then changes made to a bind request object may alter the authentication/authorization identity and/or credentials associated with that request so that a rebind request created from it will not match the original request used to authenticate on a connection.- Overrides:
getRebindRequestin classBindRequest- Parameters:
host- The address of the directory server to which the connection is established.port- The port of the directory server to which the connection is established.- Returns:
- A bind request that may be used to re-bind using the same
authentication type and credentials as previously used to perform
the initial bind, or
nullto indicate that automatic re-binding is not supported for this type of bind request.
-
handle
@InternalUseOnly public void handle(@NotNull Callback[] callbacks) throws UnsupportedCallbackException Handles any necessary callbacks required for SASL authentication.- Specified by:
handlein interfaceCallbackHandler- Parameters:
callbacks- The set of callbacks to be handled.- Throws:
UnsupportedCallbackException- If an unsupported type of callback was received.
-
getLastMessageID
Retrieves the message ID for the last LDAP message sent using this request.- Overrides:
getLastMessageIDin classSASLBindRequest- Returns:
- The message ID for the last LDAP message sent using this request, or -1 if it no LDAP messages have yet been sent using this request.
-
duplicate
Creates a new instance of this LDAP request that may be modified without impacting this request.- Specified by:
duplicatein interfaceReadOnlyLDAPRequest- Specified by:
duplicatein classBindRequest- Returns:
- A new instance of this LDAP request that may be modified without impacting this request.
-
duplicate
Creates a new instance of this LDAP request that may be modified without impacting this request. The provided controls will be used for the new request instead of duplicating the controls from this request.- Specified by:
duplicatein interfaceReadOnlyLDAPRequest- Specified by:
duplicatein classBindRequest- Parameters:
controls- The set of controls to include in the duplicate request.- Returns:
- A new instance of this LDAP request that may be modified without impacting this request.
-
toString
Appends a string representation of this request to the provided buffer.- Specified by:
toStringin interfaceReadOnlyLDAPRequest- Specified by:
toStringin classLDAPRequest- Parameters:
buffer- The buffer to which to append a string representation of this request.
-
toCode
public void toCode(@NotNull List<String> lineList, @NotNull String requestID, int indentSpaces, boolean includeProcessing) Appends a number of lines comprising the Java source code that can be used to recreate this request to the given list.- Specified by:
toCodein interfaceReadOnlyLDAPRequest- Overrides:
toCodein classSASLBindRequest- Parameters:
lineList- The list to which the source code lines should be added.requestID- The name that should be used as an identifier for the request. If this isnullor empty, then a generic ID will be used.indentSpaces- The number of spaces that should be used to indent the generated code. It must not be negative.includeProcessing- Indicates whether the generated code should include code required to actually process the request and handle the result (iftrue), or just to generate the request (iffalse).
-