@NotMutable @ThreadSafety(level=NOT_THREADSAFE) public final class GSSAPIBindRequest extends SASLBindRequest implements javax.security.auth.callback.CallbackHandler, java.security.PrivilegedExceptionAction<java.lang.Object>
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(); }
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
GSSAPI_MECHANISM_NAME
The name for the GSSAPI SASL mechanism.
|
CRED_TYPE_SASL
VERSION_ELEMENT
Constructor and Description |
---|
GSSAPIBindRequest(GSSAPIBindRequestProperties gssapiProperties,
Control... controls)
Creates a new SASL GSSAPI bind request with the provided set of properties.
|
GSSAPIBindRequest(java.lang.String authenticationID,
byte[] password)
Creates a new SASL GSSAPI bind request with the provided authentication ID
and password.
|
GSSAPIBindRequest(java.lang.String authenticationID,
byte[] password,
Control[] controls)
Creates a new SASL GSSAPI bind request with the provided authentication ID
and password.
|
GSSAPIBindRequest(java.lang.String authenticationID,
java.lang.String password)
Creates a new SASL GSSAPI bind request with the provided authentication ID
and password.
|
GSSAPIBindRequest(java.lang.String authenticationID,
java.lang.String authorizationID,
byte[] password,
java.lang.String realm,
java.lang.String kdcAddress,
java.lang.String configFilePath)
Creates a new SASL GSSAPI bind request with the provided information.
|
GSSAPIBindRequest(java.lang.String authenticationID,
java.lang.String authorizationID,
byte[] password,
java.lang.String realm,
java.lang.String kdcAddress,
java.lang.String configFilePath,
Control[] controls)
Creates a new SASL GSSAPI bind request with the provided information.
|
GSSAPIBindRequest(java.lang.String authenticationID,
java.lang.String password,
Control[] controls)
Creates a new SASL GSSAPI bind request with the provided authentication ID
and password.
|
GSSAPIBindRequest(java.lang.String authenticationID,
java.lang.String authorizationID,
java.lang.String password,
java.lang.String realm,
java.lang.String kdcAddress,
java.lang.String configFilePath)
Creates a new SASL GSSAPI bind request with the provided information.
|
GSSAPIBindRequest(java.lang.String authenticationID,
java.lang.String authorizationID,
java.lang.String password,
java.lang.String realm,
java.lang.String kdcAddress,
java.lang.String configFilePath,
Control[] controls)
Creates a new SASL GSSAPI bind request with the provided information.
|
Modifier and Type | Method and Description |
---|---|
GSSAPIBindRequest |
duplicate()
Creates a new instance of this LDAP request that may be modified without
impacting this request.
|
GSSAPIBindRequest |
duplicate(Control[] controls)
Creates a new instance of this LDAP request that may be modified without
impacting this request.
|
boolean |
enableGSSAPIDebugging()
Indicates whether JVM-level debugging should be enabled for GSSAPI bind
processing.
|
java.util.List<SASLQualityOfProtection> |
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.
|
java.lang.String |
getAuthenticationID()
Retrieves the authentication ID for the GSSAPI bind request, if defined.
|
java.lang.String |
getAuthorizationID()
Retrieves the authorization ID for this bind request, if any.
|
GSSAPIChannelBindingType |
getChannelBindingType()
Retrieves the type of channel binding that should be used for this GSSAPI
bind request.
|
java.lang.String |
getConfigFilePath()
Retrieves the path to the JAAS configuration file that will be used during
authentication processing.
|
java.lang.Boolean |
getIsInitiator()
Indicates whether the client should be configured so that it explicitly
indicates whether it is the initiator or the acceptor.
|
java.lang.String |
getKDCAddress()
Retrieves the address of the Kerberos key distribution center.
|
java.lang.String |
getKeyTabPath()
Retrieves the path to the keytab file from which to obtain the user
credentials.
|
int |
getLastMessageID()
Retrieves the message ID for the last LDAP message sent using this request.
|
byte[] |
getPasswordBytes()
Retrieves the bytes that comprise the the password for this bind request,
if defined.
|
java.lang.String |
getPasswordString()
Retrieves the string representation of the password for this bind request,
if defined.
|
java.lang.String |
getRealm()
Retrieves the realm for this bind request, if any.
|
GSSAPIBindRequest |
getRebindRequest(java.lang.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.
|
java.lang.String |
getSASLMechanismName()
Retrieves the name of the SASL mechanism used in this SASL bind request.
|
java.lang.String |
getServicePrincipalProtocol()
Retrieves the protocol specified in the service principal that the
directory server uses for its communication with the KDC.
|
java.util.Set<java.lang.String> |
getSuppressedSystemProperties()
Retrieves a set of system properties that will not be altered by GSSAPI
processing.
|
java.lang.String |
getTicketCachePath()
Retrieves the path to the Kerberos ticket cache file that should be used
during authentication, if defined.
|
void |
handle(javax.security.auth.callback.Callback[] callbacks)
Handles any necessary callbacks required for SASL authentication.
|
protected BindResult |
process(LDAPConnection connection,
int depth)
Sends this bind request to the target server over the provided connection
and returns the corresponding response.
|
boolean |
refreshKrb5Config()
Indicates whether to refresh the configuration before the JAAS
login method is called. |
boolean |
renewTGT()
Indicates whether to attempt to renew the client's ticket-granting ticket
(TGT) if an existing Kerberos session is used to authenticate.
|
boolean |
requireCachedCredentials()
Indicates whether GSSAPI authentication should only occur using an existing
Kerberos session.
|
java.lang.Object |
run()
Perform the privileged portion of the authentication processing.
|
void |
toCode(java.util.List<java.lang.String> lineList,
java.lang.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.
|
void |
toString(java.lang.StringBuilder buffer)
Appends a string representation of this request to the provided buffer.
|
boolean |
useKeyTab()
Indicates whether to use a keytab to obtain the user credentials.
|
boolean |
useSubjectCredentialsOnly()
Indicates whether to allow the client to use credentials that are outside
of the current subject, obtained via some system-specific mechanism.
|
boolean |
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.
|
getBindType, responseReceived, sendBindRequest, sendMessage
getOperationType
followReferrals, getControl, getControlList, getControls, getIntermediateResponseListener, getReferralConnector, getReferralConnectorInternal, getReferralDepth, getResponseTimeoutMillis, hasControl, hasControl, setFollowReferrals, setIntermediateResponseListener, setReferralConnector, setReferralDepth, setResponseTimeoutMillis, toString
@NotNull public static final java.lang.String GSSAPI_MECHANISM_NAME
public GSSAPIBindRequest(@NotNull java.lang.String authenticationID, @NotNull java.lang.String password) throws LDAPException
authenticationID
- The authentication ID for this bind request. It
must not be null
.password
- The password for this bind request. It must not
be null
.LDAPException
- If a problem occurs while creating the JAAS
configuration file to use during authentication
processing.public GSSAPIBindRequest(@NotNull java.lang.String authenticationID, @NotNull byte[] password) throws LDAPException
authenticationID
- The authentication ID for this bind request. It
must not be null
.password
- The password for this bind request. It must not
be null
.LDAPException
- If a problem occurs while creating the JAAS
configuration file to use during authentication
processing.public GSSAPIBindRequest(@NotNull java.lang.String authenticationID, @NotNull java.lang.String password, @Nullable Control[] controls) throws LDAPException
authenticationID
- The authentication ID for this bind request. It
must not be null
.password
- The password for this bind request. It must not
be null
.controls
- The set of controls to include in the request.LDAPException
- If a problem occurs while creating the JAAS
configuration file to use during authentication
processing.public GSSAPIBindRequest(@NotNull java.lang.String authenticationID, @NotNull byte[] password, @Nullable Control[] controls) throws LDAPException
authenticationID
- The authentication ID for this bind request. It
must not be null
.password
- The password for this bind request. It must not
be null
.controls
- The set of controls to include in the request.LDAPException
- If a problem occurs while creating the JAAS
configuration file to use during authentication
processing.public GSSAPIBindRequest(@NotNull java.lang.String authenticationID, @Nullable java.lang.String authorizationID, @NotNull java.lang.String password, @Nullable java.lang.String realm, @Nullable java.lang.String kdcAddress, @Nullable java.lang.String configFilePath) throws LDAPException
authenticationID
- The authentication ID for this bind request. It
must not be null
.authorizationID
- The authorization ID for this bind request. It
may be null
if no alternate authorization
ID should be used.password
- The password for this bind request. It must not
be null
.realm
- The realm to use for the authentication. It may
be null
to attempt to use the default
realm from the system configuration.kdcAddress
- The address of the Kerberos key distribution
center. It may be null
to 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 be
null
to use the default JAAS
configuration.LDAPException
- If a problem occurs while creating the JAAS
configuration file to use during authentication
processing.public GSSAPIBindRequest(@NotNull java.lang.String authenticationID, @Nullable java.lang.String authorizationID, @NotNull byte[] password, @Nullable java.lang.String realm, @Nullable java.lang.String kdcAddress, @Nullable java.lang.String configFilePath) throws LDAPException
authenticationID
- The authentication ID for this bind request. It
must not be null
.authorizationID
- The authorization ID for this bind request. It
may be null
if no alternate authorization
ID should be used.password
- The password for this bind request. It must not
be null
.realm
- The realm to use for the authentication. It may
be null
to attempt to use the default
realm from the system configuration.kdcAddress
- The address of the Kerberos key distribution
center. It may be null
to 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 be
null
to use the default JAAS
configuration.LDAPException
- If a problem occurs while creating the JAAS
configuration file to use during authentication
processing.public GSSAPIBindRequest(@NotNull java.lang.String authenticationID, @Nullable java.lang.String authorizationID, @NotNull java.lang.String password, @Nullable java.lang.String realm, @Nullable java.lang.String kdcAddress, @Nullable java.lang.String configFilePath, @Nullable Control[] controls) throws LDAPException
authenticationID
- The authentication ID for this bind request. It
must not be null
.authorizationID
- The authorization ID for this bind request. It
may be null
if no alternate authorization
ID should be used.password
- The password for this bind request. It must not
be null
.realm
- The realm to use for the authentication. It may
be null
to attempt to use the default
realm from the system configuration.kdcAddress
- The address of the Kerberos key distribution
center. It may be null
to 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 be
null
to use the default JAAS
configuration.controls
- The set of controls to include in the request.LDAPException
- If a problem occurs while creating the JAAS
configuration file to use during authentication
processing.public GSSAPIBindRequest(@NotNull java.lang.String authenticationID, @Nullable java.lang.String authorizationID, @NotNull byte[] password, @Nullable java.lang.String realm, @Nullable java.lang.String kdcAddress, @Nullable java.lang.String configFilePath, @Nullable Control[] controls) throws LDAPException
authenticationID
- The authentication ID for this bind request. It
must not be null
.authorizationID
- The authorization ID for this bind request. It
may be null
if no alternate authorization
ID should be used.password
- The password for this bind request. It must not
be null
.realm
- The realm to use for the authentication. It may
be null
to attempt to use the default
realm from the system configuration.kdcAddress
- The address of the Kerberos key distribution
center. It may be null
to 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 be
null
to use the default JAAS
configuration.controls
- The set of controls to include in the request.LDAPException
- If a problem occurs while creating the JAAS
configuration file to use during authentication
processing.public GSSAPIBindRequest(@NotNull GSSAPIBindRequestProperties gssapiProperties, @Nullable Control... controls) throws LDAPException
gssapiProperties
- The set of properties that should be used for
the GSSAPI bind request. It must not be
null
.controls
- The set of controls to include in the request.LDAPException
- If a problem occurs while creating the JAAS
configuration file to use during authentication
processing.@NotNull public java.lang.String getSASLMechanismName()
getSASLMechanismName
in class SASLBindRequest
@Nullable public java.lang.String getAuthenticationID()
null
if an existing Kerberos session should be used.@Nullable public java.lang.String getAuthorizationID()
null
if
there should not be a separate authorization identity.@Nullable public java.lang.String getPasswordString()
null
if an existing Kerberos session should be used.@Nullable public byte[] getPasswordBytes()
null
if an existing Kerberos session should be used.@Nullable public java.lang.String getRealm()
null
if none was
defined and the client should attempt to determine the realm from
the system configuration.@NotNull public java.util.List<SASLQualityOfProtection> getAllowedQoP()
@Nullable public java.lang.String getKDCAddress()
null
if none was defined and the client should attempt to
determine the KDC address from the system configuration.@Nullable public java.lang.String getConfigFilePath()
@NotNull public java.lang.String getServicePrincipalProtocol()
public boolean refreshKrb5Config()
login
method is called.true
if the GSSAPI implementation should refresh the
configuration before the JAAS login
method is called, or
false
if not.public boolean useKeyTab()
true
if the GSSAPI login attempt should use a keytab to
obtain the user credentials, or false
if not.@Nullable public java.lang.String getKeyTabPath()
useKeyTab
returns
true
.null
if the default keytab location should
be used.public boolean useTicketCache()
true
if a ticket cache may be used to take advantage of an
existing Kerberos session, or false
if Kerberos
credentials should always be provided.public boolean requireCachedCredentials()
true
if GSSAPI authentication should only use an existing
Kerberos session and should fail if the client does not have an
existing session, or false
if the client will be allowed
to create a new session if one does not already exist.@Nullable public java.lang.String getTicketCachePath()
null
if the default ticket cache
file should be used.public boolean renewTGT()
true
if the client should attempt to renew its
ticket-granting ticket if the authentication is processed using an
existing Kerberos session, or false
if not.public boolean useSubjectCredentialsOnly()
true
if the client will only be allowed to use credentials
that are within the current subject, or false
if the
client will be allowed to use credentials outside the current
subject.@Nullable public java.lang.Boolean getIsInitiator()
Boolean.TRUE
if the client should explicitly indicate that
it is the GSSAPI initiator, Boolean.FALSE
if the client
should explicitly indicate that it is the GSSAPI acceptor, or
null
if the client should not explicitly indicate either
state (which is the default behavior unless the
GSSAPIBindRequestProperties.setIsInitiator(java.lang.Boolean)
method has
been used to explicitly specify a value).@NotNull public java.util.Set<java.lang.String> getSuppressedSystemProperties()
@NotNull public GSSAPIChannelBindingType getChannelBindingType()
GSSAPIChannelBindingType.NONE
if no
channel binding should be used.public boolean enableGSSAPIDebugging()
true
if JVM-level debugging should be enabled for GSSAPI
bind processing, or false
if not.@NotNull protected BindResult process(@NotNull LDAPConnection connection, int depth) throws LDAPException
process
in class BindRequest
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.LDAPException
- If a problem occurs while sending the request or
reading the response.@InternalUseOnly @NotNull public java.lang.Object run() throws LDAPException
run
in interface java.security.PrivilegedExceptionAction<java.lang.Object>
null
, since no return value is actually needed.LDAPException
- If a problem occurs during processing.@NotNull public GSSAPIBindRequest getRebindRequest(@NotNull java.lang.String host, int port)
getRebindRequest
in class BindRequest
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.null
to indicate that automatic
re-binding is not supported for this type of bind request.@InternalUseOnly public void handle(@NotNull javax.security.auth.callback.Callback[] callbacks) throws javax.security.auth.callback.UnsupportedCallbackException
handle
in interface javax.security.auth.callback.CallbackHandler
callbacks
- The set of callbacks to be handled.javax.security.auth.callback.UnsupportedCallbackException
- If an unsupported type of callback
was received.public int getLastMessageID()
getLastMessageID
in class SASLBindRequest
@NotNull public GSSAPIBindRequest duplicate()
duplicate
in interface ReadOnlyLDAPRequest
duplicate
in class BindRequest
@NotNull public GSSAPIBindRequest duplicate(@Nullable Control[] controls)
duplicate
in interface ReadOnlyLDAPRequest
duplicate
in class BindRequest
controls
- The set of controls to include in the duplicate request.public void toString(@NotNull java.lang.StringBuilder buffer)
toString
in interface ReadOnlyLDAPRequest
toString
in class LDAPRequest
buffer
- The buffer to which to append a string representation of
this request.public void toCode(@NotNull java.util.List<java.lang.String> lineList, @NotNull java.lang.String requestID, int indentSpaces, boolean includeProcessing)
toCode
in interface ReadOnlyLDAPRequest
toCode
in class SASLBindRequest
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 is null
or
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 (if true
),
or just to generate the request (if
false
).