Class BroadleafAuthorizationRequestRepository

  • All Implemented Interfaces:
    org.springframework.security.oauth2.client.web.AuthorizationRequestRepository<org.springframework.security.oauth2.core.endpoint.OAuth2AuthorizationRequest>

    public class BroadleafAuthorizationRequestRepository
    extends Object
    implements org.springframework.security.oauth2.client.web.AuthorizationRequestRepository<org.springframework.security.oauth2.core.endpoint.OAuth2AuthorizationRequest>
    Save and load OAuth2AuthorizationRequest from a cookie. The OAuth2AuthorizationRequest is wrapped in an AuthorizationRequestWrapper. Then it is serialized, wrapped in a signed jwt token, and saved to a cookie. When the browser redirects back to this app from the third party login, the AuthorizationRequestWrapper is read from the cookie, verified, and deserialized into an OAuth2AuthorizationRequest.
    • Constructor Detail

      • BroadleafAuthorizationRequestRepository

        public BroadleafAuthorizationRequestRepository​(StatelessUtil statelessUtil,
                                                       ContextHelperService contextHelperService)
    • Method Detail

      • loadAuthorizationRequest

        @Nullable
        public org.springframework.security.oauth2.core.endpoint.OAuth2AuthorizationRequest loadAuthorizationRequest​(javax.servlet.http.HttpServletRequest request)
        Load a saved OAuth2AuthorizationRequest from a cookie. As a side-effect, this method will also set the clientId as a request attribute.
        Specified by:
        loadAuthorizationRequest in interface org.springframework.security.oauth2.client.web.AuthorizationRequestRepository<org.springframework.security.oauth2.core.endpoint.OAuth2AuthorizationRequest>
        Parameters:
        request -
        Returns:
      • saveAuthorizationRequest

        public void saveAuthorizationRequest​(org.springframework.security.oauth2.core.endpoint.OAuth2AuthorizationRequest authorizationRequest,
                                             javax.servlet.http.HttpServletRequest request,
                                             javax.servlet.http.HttpServletResponse response)
        Save a OAuth2AuthorizationRequest to a cookie.
        Specified by:
        saveAuthorizationRequest in interface org.springframework.security.oauth2.client.web.AuthorizationRequestRepository<org.springframework.security.oauth2.core.endpoint.OAuth2AuthorizationRequest>
        Parameters:
        authorizationRequest -
        request -
        response -
      • removeAuthorizationRequest

        public org.springframework.security.oauth2.core.endpoint.OAuth2AuthorizationRequest removeAuthorizationRequest​(javax.servlet.http.HttpServletRequest request,
                                                                                                                       javax.servlet.http.HttpServletResponse response)
        Set a blank cookie to delete the saved authorization request.
        Specified by:
        removeAuthorizationRequest in interface org.springframework.security.oauth2.client.web.AuthorizationRequestRepository<org.springframework.security.oauth2.core.endpoint.OAuth2AuthorizationRequest>
        Parameters:
        request -
        response -
        Returns:
      • removeAuthorizationRequest

        public org.springframework.security.oauth2.core.endpoint.OAuth2AuthorizationRequest removeAuthorizationRequest​(javax.servlet.http.HttpServletRequest request)
        This method is deprecated in the interface and is not supported by this implementation.
        Specified by:
        removeAuthorizationRequest in interface org.springframework.security.oauth2.client.web.AuthorizationRequestRepository<org.springframework.security.oauth2.core.endpoint.OAuth2AuthorizationRequest>
        Parameters:
        request -
        Returns:
        Throws:
        UnsupportedOperationException
      • saveAuthRequestWrapperResponseCookie

        @NotNull
        protected @NotNull org.springframework.http.ResponseCookie saveAuthRequestWrapperResponseCookie​(AuthorizationRequestWrapper authorizationRequestWrapper)
      • readAuthRequestWrapperFromCookie

        @Nullable
        protected AuthorizationRequestWrapper readAuthRequestWrapperFromCookie​(javax.servlet.http.HttpServletRequest request)
      • wrapAuthorizationRequest

        protected AuthorizationRequestWrapper wrapAuthorizationRequest​(org.springframework.security.oauth2.core.endpoint.OAuth2AuthorizationRequest authorizationRequest,
                                                                       String clientId)
        Wrap a OAuth2AuthorizationRequest in a AuthorizationRequestWrapper with the current client id
        Parameters:
        authorizationRequest -
        clientId -
        Returns:
      • buildOAuth2AuthorizationRequest

        protected org.springframework.security.oauth2.core.endpoint.OAuth2AuthorizationRequest buildOAuth2AuthorizationRequest​(AuthorizationRequestWrapper authorizationRequestWrapper)
        Build a OAuth2AuthorizationRequest from a AuthorizationRequestWrapper.
        Parameters:
        authorizationRequestWrapper -
        Returns:
      • getSavedAuthRequestCookieName

        @NotNull
        public @NotNull String getSavedAuthRequestCookieName()
      • getObjectMapper

        protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
      • setObjectMapper

        protected void setObjectMapper​(com.fasterxml.jackson.databind.ObjectMapper objectMapper)