Class Jaspic


  • public final class Jaspic
    extends Object
    A set of utility methods for using the Jakarta Authentication API
    Author:
    Arjan Tijms
    • 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)
      • 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