Interface OAuthStateService

    • Field Detail

      • DEFAULT_EXPIRATION_IN_SECONDS

        static final long DEFAULT_EXPIRATION_IN_SECONDS
        See Also:
        Constant Field Values
    • Method Detail

      • getSessionCookieName

        default String getSessionCookieName()
        Returns the cookie name used for browser sessions.
      • extractStateFromQueryString

        default String extractStateFromQueryString​(Request request)
        Returns the state parameter value from a given query string if it exists.
      • issueNewState

        default String issueNewState​(Request request,
                                     Response response)
                              throws Exception
        Issues a new state parameter and set it in both the browser session and the system's server-side datastore.
        Throws:
        Exception
      • generateNewStateValue

        default String generateNewStateValue()
        Generates a new unique state parameter value.
      • getExpirationInSeconds

        default long getExpirationInSeconds()
        Returns the time period of expiration for state values in seconds.
      • generateSessionCookieValue

        default String generateSessionCookieValue​(Request request,
                                                  String state)
                                           throws Exception
        Generates a cookie value. The default behavior is to use the raw value as-is. If you'd like to go with another representation, have your own class and override this method.
        Throws:
        Exception
      • addNewStateToDatastore

        void addNewStateToDatastore​(String state)
                             throws Exception
        Adds a newly generated state value to the server-side datastore.
        Throws:
        Exception
      • isValid

        default boolean isValid​(Request request)
        Verifies the given state parameter and returns true if it's valid. This methods doesn't have any side-effects, so that you can call this method multiple times.
      • extractStateFromSession

        default String extractStateFromSession​(Request request)
        Returns an underlying state value in a cookie-based session if it exists.
      • isAvailableInDatabase

        boolean isAvailableInDatabase​(String state)
        Verifies the state value is available in the datastore and returns true if it's valid.
      • consume

        default void consume​(Request request,
                             Response response)
                      throws Exception
        Deletes the state value from the server-side datastore and set a response header to delete the one in session.
        Throws:
        Exception
      • deleteStateFromDatastore

        void deleteStateFromDatastore​(String state)
                               throws Exception
        Deletes a given state value from the server-side datastore.
        Throws:
        Exception