public class KerberosAuthenticationHandler extends java.lang.Object implements AuthenticationHandler
KerberosAuthenticationHandler implements the Kerberos SPNEGO authentication mechanism for HTTP.
The supported configuration properties are:
HTTP/${HOSTNAME}@{REALM}. The realm can be omitted from the
principal as the JDK GSS libraries will use the realm name of the configured default realm.
It does not have a default value.KerberosName.setRules(String)| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
DOAS_QUERY_STRING |
static java.lang.String |
ENABLE_TRUSTED_PROXY
Constant for the configuration property that indicates the Trusted Proxy setting.
|
static java.lang.String |
KEYTAB
Constant for the configuration property that indicates the keytab file path.
|
static java.lang.String |
LOAD_BALANCER_PRINCIPAL
Constant for the configuration property that indicates the kerberos principal.
|
static java.lang.String |
NAME_RULES
Constant for the configuration property that indicates the Kerberos name
rules for the Kerberos principals.
|
static java.lang.String |
PRINCIPAL
Constant for the configuration property that indicates the kerberos principal.
|
static java.lang.String |
QUERY_STRING_DELIMITER |
static java.lang.String |
TYPE
Constant that identifies the authentication mechanism.
|
JWT_SSO_ENABLED, NON_BROWSER_USER_AGENTS, NON_BROWSER_USER_AGENTS_DEFAULT, WWW_AUTHENTICATE| Constructor and Description |
|---|
KerberosAuthenticationHandler()
Creates a Kerberos SPNEGO authentication handler with the default
auth-token type,
kerberos. |
KerberosAuthenticationHandler(java.lang.String type)
Creates a Kerberos SPNEGO authentication handler with a custom auth-token
type.
|
| Modifier and Type | Method and Description |
|---|---|
AuthenticationToken |
authenticate(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
It enforces the the Kerberos SPNEGO authentication sequence returning an
AuthenticationToken only
after the Kerberos SPNEGO sequence has completed successfully. |
void |
destroy()
Releases any resources initialized by the authentication handler.
|
protected static java.lang.String |
getDoasUser(javax.servlet.http.HttpServletRequest request) |
protected java.lang.String |
getKeytab()
Returns the keytab used by the authentication handler.
|
protected java.util.Set<javax.security.auth.kerberos.KerberosPrincipal> |
getPrincipals()
Returns the Kerberos principals used by the authentication handler.
|
java.lang.String |
getType()
Returns the authentication type of the authentication handler, 'kerberos'.
|
void |
init(java.util.Properties config)
Initializes the authentication handler instance.
|
protected void |
setNonBrowserUserAgents(java.lang.String nonBrowserUserAgentsStr) |
boolean |
shouldAuthenticate(javax.servlet.http.HttpServletRequest request)
Should the request be authenticated by the handler or not.
|
public static final java.lang.String TYPE
public static final java.lang.String PRINCIPAL
public static final java.lang.String LOAD_BALANCER_PRINCIPAL
public static final java.lang.String KEYTAB
public static final java.lang.String ENABLE_TRUSTED_PROXY
public static final java.lang.String NAME_RULES
public static final java.lang.String QUERY_STRING_DELIMITER
public static final java.lang.String DOAS_QUERY_STRING
public KerberosAuthenticationHandler()
kerberos.public KerberosAuthenticationHandler(java.lang.String type)
type - auth-token type.public void init(java.util.Properties config)
throws javax.servlet.ServletException
It creates a Kerberos context using the principal and keytab specified in the configuration.
This method is invoked by the AuthenticationFilter.init(javax.servlet.FilterConfig) method.
init in interface AuthenticationHandlerconfig - configuration properties to initialize the handler.javax.servlet.ServletException - thrown if the handler could not be initialized.public void destroy()
It destroys the Kerberos context.
destroy in interface AuthenticationHandlerpublic java.lang.String getType()
getType in interface AuthenticationHandlerprotected java.util.Set<javax.security.auth.kerberos.KerberosPrincipal> getPrincipals()
protected java.lang.String getKeytab()
public AuthenticationToken authenticate(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException, AuthenticationException
AuthenticationToken only
after the Kerberos SPNEGO sequence has completed successfully.authenticate in interface AuthenticationHandlerrequest - the HTTP client request.response - the HTTP client response.null if it is in progress (in this case the handler handles the response to the client).java.io.IOException - thrown if an IO error occurred.AuthenticationException - thrown if Kerberos SPNEGO sequence failed.public boolean shouldAuthenticate(javax.servlet.http.HttpServletRequest request)
AuthenticationHandlerThis is useful for deciding if a request should be handled by this handler or just forwarded to the next filter in chain. For example, if it's a java client in a long running application then the SSO handler can decide to not authenticate it and pass it on to the next filter
If the method returns TRUE the request will have to go through
this authentication handler
If the method returns FALSE the request is expected to be
passed on to the next filter in the chain
shouldAuthenticate in interface AuthenticationHandlerrequest - the HTTP client request.TRUE if this request should be authenticated by the handler,
FALSE otherwise.protected static java.lang.String getDoasUser(javax.servlet.http.HttpServletRequest request)
protected void setNonBrowserUserAgents(java.lang.String nonBrowserUserAgentsStr)