Class SecurityUtils


  • public class SecurityUtils
    extends Object
    Contains security utility methods.
    Author:
    Alfonso Vásquez
    • Method Detail

      • getTicketCookie

        public static String getTicketCookie​(javax.servlet.http.HttpServletRequest request)
        Returns the ticket cookie value from the request.
        Parameters:
        request - the request where to retrieve the ticket from
        Returns:
        the ticket
      • getProfileLastModifiedCookie

        public static Long getProfileLastModifiedCookie​(javax.servlet.http.HttpServletRequest request)
        Returns the last modified timestamp cookie from the request.
        Parameters:
        request - the request where to retrieve the last modified timestamp from
        Returns:
        the last modified timestamp of the authenticated profile
      • getCurrentAuthentication

        public static Authentication getCurrentAuthentication()
        Returns the authentication attribute from the current request.
        Returns:
        the authentication object
      • setCurrentAuthentication

        public static void setCurrentAuthentication​(Authentication authentication)
        Sets the authentication attribute in the current request.
        Parameters:
        authentication - the authentication object to set as request attribute
      • removeCurrentAuthentication

        public static void removeCurrentAuthentication()
        Removes the authentication attribute from the current request.
      • getAuthentication

        public static Authentication getAuthentication​(javax.servlet.http.HttpServletRequest request)
        Returns the authentication attribute from the specified request.
        Parameters:
        request - the request where to get the attribute from
        Returns:
        the authentication object
      • setAuthentication

        public static void setAuthentication​(javax.servlet.http.HttpServletRequest request,
                                             Authentication authentication)
        Sets the authentication attribute in the specified request.
        Parameters:
        request - the request where to add the attribute to
        authentication - the authentication object to set as request attribute
      • removeAuthentication

        public static void removeAuthentication​(javax.servlet.http.HttpServletRequest request)
        Removes the authentication attribute from the specified request.
        Parameters:
        request - the request where to remove the attribute from
      • getCurrentProfile

        public static org.craftercms.profile.api.Profile getCurrentProfile()
        Returns the profile from authentication attribute from the current request.
        Returns:
        the profile object, or null if there's no authentication
      • getProfile

        public static org.craftercms.profile.api.Profile getProfile​(javax.servlet.http.HttpServletRequest request)
        Returns the profile from authentication attribute from the specified request.
        Returns:
        the profile object, or null if there's no authentication