Package io.hawt.system
Class Authenticator
- java.lang.Object
-
- io.hawt.system.Authenticator
-
public class Authenticator extends Object
Authenticator performs authentication using JAAS with theLoginContextfor the chosen realm.Authenticator supports the following authentication methods:
- a set of user name and password
- client certificates
-
-
Field Summary
Fields Modifier and Type Field Description static StringATTRIBUTE_X509_CERTIFICATEstatic StringAUTHENTICATION_SCHEME_BASICstatic StringAUTHENTICATION_SCHEME_BEARERstatic StringHEADER_AUTHORIZATION
-
Constructor Summary
Constructors Constructor Description Authenticator(javax.servlet.http.HttpServletRequest request, AuthenticationConfiguration authConfiguration)Request-based authenticator such as when authenticating direct Jolokia accesses.Authenticator(javax.servlet.http.HttpServletRequest request, AuthenticationConfiguration authConfiguration, String username, String password)Explicit username/password authenticator when authenticating users from login page.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AuthenticateResultauthenticate(Consumer<Subject> callback)protected booleancheckRoles(Subject subject, String role, String rolePrincipalClasses)protected SubjectdoAuthenticate()static voidextractAuthHeader(javax.servlet.http.HttpServletRequest request, BiConsumer<String,String> callback)Extracts username/password from Authorization header.booleanhasNoCredentials()protected SubjectinitSubject()booleanisUsernamePasswordSet()protected voidlogin(Subject subject, String realm, Configuration configuration)static voidlogout(AuthenticationConfiguration authConfiguration, Subject subject)
-
-
-
Field Detail
-
HEADER_AUTHORIZATION
public static final String HEADER_AUTHORIZATION
- See Also:
- Constant Field Values
-
AUTHENTICATION_SCHEME_BASIC
public static final String AUTHENTICATION_SCHEME_BASIC
- See Also:
- Constant Field Values
-
AUTHENTICATION_SCHEME_BEARER
public static final String AUTHENTICATION_SCHEME_BEARER
- See Also:
- Constant Field Values
-
ATTRIBUTE_X509_CERTIFICATE
public static final String ATTRIBUTE_X509_CERTIFICATE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Authenticator
public Authenticator(javax.servlet.http.HttpServletRequest request, AuthenticationConfiguration authConfiguration, String username, String password)Explicit username/password authenticator when authenticating users from login page.
-
Authenticator
public Authenticator(javax.servlet.http.HttpServletRequest request, AuthenticationConfiguration authConfiguration)Request-based authenticator such as when authenticating direct Jolokia accesses.
-
-
Method Detail
-
extractAuthHeader
public static void extractAuthHeader(javax.servlet.http.HttpServletRequest request, BiConsumer<String,String> callback)Extracts username/password from Authorization header. Callback is invoked only when Authorization header is present.
-
isUsernamePasswordSet
public boolean isUsernamePasswordSet()
-
hasNoCredentials
public boolean hasNoCredentials()
-
logout
public static void logout(AuthenticationConfiguration authConfiguration, Subject subject)
-
authenticate
public AuthenticateResult authenticate(Consumer<Subject> callback)
-
doAuthenticate
protected Subject doAuthenticate()
-
initSubject
protected Subject initSubject()
-
login
protected void login(Subject subject, String realm, Configuration configuration) throws LoginException
- Throws:
LoginException
-
-