Class GSSContextAcceptor
java.lang.Object
net.shibboleth.idp.authn.spnego.impl.GSSContextAcceptor
Helper class that manages context establishment for the SPNEGO GSS-API mechanism.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate GSSContext
The GSSContext being established, or that was established.private KerberosSettings
The Kerberos settings.private GSSAcceptorLoginModule
The Kerberos login module and server login state.private final org.slf4j.Logger
Class logger.private KerberosRealmSettings
The realm in use.private GSSCredential
Server credentials used during context establishment.private final Oid
The OID representing the SPNEGO pseudo-mechanism. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate byte[]
acceptFirstToken
(byte[] inToken, int offset, int len) Process the first inbound GSS token.byte[]
acceptSecContext
(byte[] inToken, int offset, int len) Process the inbound GSS token.private void
Establish initial server credentials and create a GSS acceptor context based on then.Return the GSS security context.private GSSCredential
getServerCredential
(Subject subject) Create the credential for the GSS-API.void
logout()
Dispose of the context and the server's credentials, and do a logout of the Kerberos login module.
-
Field Details
-
log
@Nonnull private final org.slf4j.Logger logClass logger. -
spnegoOid
The OID representing the SPNEGO pseudo-mechanism. -
kerberosSettings
The Kerberos settings. -
realmSettings
The realm in use. -
krbLoginModule
The Kerberos login module and server login state. -
serverCreds
Server credentials used during context establishment. -
context
The GSSContext being established, or that was established.
-
-
Constructor Details
-
GSSContextAcceptor
Constructor.- Parameters:
settings
- the KerberosSettings to use- Throws:
GSSException
- if an error occurs establishing server credentials
-
-
Method Details
-
getContext
Return the GSS security context.- Returns:
- the context
-
acceptSecContext
@Nullable public byte[] acceptSecContext(@Nonnull byte[] inToken, int offset, int len) throws Exception Process the inbound GSS token.During the first (and likely only) token step, we will also establish the server's credentials in the process. If additional round trips occur, this will be detected and the previous partial context will be used.
- Parameters:
inToken
- token generated by the peeroffset
- the offset within the inToken where the token beginslen
- the length of the token- Returns:
- a byte[] containing the token to be sent to the peer, or null if no output token is needed
- Throws:
Exception
- if an error occurs- See Also:
-
logout
public void logout()Dispose of the context and the server's credentials, and do a logout of the Kerberos login module. -
acceptFirstToken
@Nullable private byte[] acceptFirstToken(@Nonnull byte[] inToken, int offset, int len) throws Exception Process the first inbound GSS token.- Parameters:
inToken
- token generated by the peeroffset
- the offset within the inToken where the token beginslen
- the length of the token- Returns:
- a byte[] containing the token to be sent to the peer, or null if no output token is needed
- Throws:
Exception
- if an error occurs
-
createGSSContext
private void createGSSContext(@Nonnull KerberosRealmSettings realm) throws GSSException, LoginException, PrivilegedActionException Establish initial server credentials and create a GSS acceptor context based on then.- Parameters:
realm
- realm settings to use- Throws:
GSSException
- thrown if GSS context could not be createdLoginException
- thrown if login failedPrivilegedActionException
- thrown if GSS credentials could not be created
-
getServerCredential
@Nonnull private GSSCredential getServerCredential(@Nonnull Subject subject) throws PrivilegedActionException Create the credential for the GSS-API.- Parameters:
subject
- Kerberos subject to create the credentials from- Returns:
- the created GSS credentials
- Throws:
PrivilegedActionException
- thrown if server credentials could not be created
-