- java.lang.Object
-
- org.glassfish.soteria.mechanisms.jaspic.Jaspic
-
public final class Jaspic extends Object
A set of utility methods for using the Jakarta Authentication API- Author:
- Arjan Tijms
-
-
Field Summary
Fields Modifier and Type Field Description static StringAUTH_PARAMSstatic StringCONTEXT_REGISTRATION_IDstatic StringDID_AUTHENTICATIONstatic StringIS_AUTHENTICATIONstatic StringIS_AUTHENTICATION_FROM_FILTERstatic StringIS_REFRESHstatic StringIS_SECURE_RESPONSEstatic StringLAST_AUTH_STATUSstatic StringLOGGEDIN_ROLESstatic StringLOGGEDIN_USERNAME
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanauthenticate(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, jakarta.security.enterprise.authentication.mechanism.http.AuthenticationParameters authParameters)static voidcleanSubject(Subject subject)static jakarta.security.auth.message.AuthStatusfromAuthenticationStatus(jakarta.security.enterprise.AuthenticationStatus authenticationStatus)static StringgetAppContextID(jakarta.servlet.ServletContext context)Gets the app context ID from the servlet context.static jakarta.security.enterprise.authentication.mechanism.http.AuthenticationParametersgetAuthParameters(jakarta.servlet.http.HttpServletRequest request)static jakarta.security.enterprise.AuthenticationStatusgetLastAuthenticationStatus(jakarta.servlet.http.HttpServletRequest request)static booleanisAuthenticationRequest(jakarta.servlet.http.HttpServletRequest request)static booleanisProtectedResource(jakarta.security.auth.message.MessageInfo messageInfo)static booleanisRegisterSession(jakarta.security.auth.message.MessageInfo messageInfo)static voidlogout(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)static voidnotifyContainerAboutLogin(Subject clientSubject, CallbackHandler handler, String callerPrincipalName, Set<String> groups)static voidnotifyContainerAboutLogin(Subject clientSubject, CallbackHandler handler, Principal callerPrincipal, Set<String> groups)static voidsetDidAuthentication(jakarta.servlet.http.HttpServletRequest request)Should be called when the callback handler is used with the intention that an actual user is going to be authenticated (as opposed to using the handler for the "do nothing" protocol which uses the unauthenticated identity).static voidsetLastAuthenticationStatus(jakarta.servlet.http.HttpServletRequest request, jakarta.security.enterprise.AuthenticationStatus status)static voidsetRegisterSession(jakarta.security.auth.message.MessageInfo messageInfo, String username, Set<String> roles)
-
-
-
Field Detail
-
IS_AUTHENTICATION
public static final String IS_AUTHENTICATION
- See Also:
- Constant Field Values
-
IS_AUTHENTICATION_FROM_FILTER
public static final String IS_AUTHENTICATION_FROM_FILTER
- See Also:
- Constant Field Values
-
IS_SECURE_RESPONSE
public static final String IS_SECURE_RESPONSE
- See Also:
- Constant Field Values
-
IS_REFRESH
public static final String IS_REFRESH
- See Also:
- Constant Field Values
-
DID_AUTHENTICATION
public static final String DID_AUTHENTICATION
- See Also:
- Constant Field Values
-
AUTH_PARAMS
public static final String AUTH_PARAMS
- See Also:
- Constant Field Values
-
LOGGEDIN_USERNAME
public static final String LOGGEDIN_USERNAME
- See Also:
- Constant Field Values
-
LOGGEDIN_ROLES
public static final String LOGGEDIN_ROLES
- See Also:
- Constant Field Values
-
LAST_AUTH_STATUS
public static final String LAST_AUTH_STATUS
- See Also:
- Constant Field Values
-
CONTEXT_REGISTRATION_ID
public static final String CONTEXT_REGISTRATION_ID
- See Also:
- Constant Field Values
-
-
Method Detail
-
authenticate
public static boolean authenticate(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, jakarta.security.enterprise.authentication.mechanism.http.AuthenticationParameters authParameters)
-
getAuthParameters
public static jakarta.security.enterprise.authentication.mechanism.http.AuthenticationParameters getAuthParameters(jakarta.servlet.http.HttpServletRequest request)
-
logout
public static void logout(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)
-
cleanSubject
public static void cleanSubject(Subject subject)
-
isRegisterSession
public static boolean isRegisterSession(jakarta.security.auth.message.MessageInfo messageInfo)
-
isProtectedResource
public static boolean isProtectedResource(jakarta.security.auth.message.MessageInfo messageInfo)
-
setRegisterSession
public static void setRegisterSession(jakarta.security.auth.message.MessageInfo messageInfo, String username, Set<String> roles)
-
isAuthenticationRequest
public static boolean isAuthenticationRequest(jakarta.servlet.http.HttpServletRequest request)
-
notifyContainerAboutLogin
public static void notifyContainerAboutLogin(Subject clientSubject, CallbackHandler handler, Principal callerPrincipal, Set<String> groups)
-
notifyContainerAboutLogin
public static void notifyContainerAboutLogin(Subject clientSubject, CallbackHandler handler, String callerPrincipalName, Set<String> groups)
-
setLastAuthenticationStatus
public static void setLastAuthenticationStatus(jakarta.servlet.http.HttpServletRequest request, jakarta.security.enterprise.AuthenticationStatus status)
-
getLastAuthenticationStatus
public static jakarta.security.enterprise.AuthenticationStatus getLastAuthenticationStatus(jakarta.servlet.http.HttpServletRequest request)
-
fromAuthenticationStatus
public static jakarta.security.auth.message.AuthStatus fromAuthenticationStatus(jakarta.security.enterprise.AuthenticationStatus authenticationStatus)
-
setDidAuthentication
public static void setDidAuthentication(jakarta.servlet.http.HttpServletRequest request)
Should be called when the callback handler is used with the intention that an actual user is going to be authenticated (as opposed to using the handler for the "do nothing" protocol which uses the unauthenticated identity).- Parameters:
request- The involved HTTP servlet request.
-
getAppContextID
public static String getAppContextID(jakarta.servlet.ServletContext context)
Gets the app context ID from the servlet context.The app context ID is the ID that JASPIC associates with the given application. In this case that given application is the web application corresponding to the ServletContext.
- Parameters:
context- the servlet context for which to obtain the JASPIC app context ID- Returns:
- the app context ID for the web application corresponding to the given context
-
-