Interface IdempotentService

All Known Implementing Classes:
DefaultIdempotentService

public interface IdempotentService
The Idempotent Service
Since:
1.0.0
Author:
Mercy
See Also:
  • Method Details

    • generateToken

      @Nonnull default String generateToken(org.springframework.web.context.request.NativeWebRequest request, IdempotentAttributes attributes)
      Generate a new token.

      Note : The new token should not be generated twice in one request.

      Parameters:
      request - the NativeWebRequest
      attributes - the IdempotentAttributes
      Returns:
      the new token
    • getToken

      @Nullable String getToken(org.springframework.web.context.request.NativeWebRequest request, IdempotentAttributes attributes)
      Get the token from the request.
      Parameters:
      request - the NativeWebRequest
      attributes - the IdempotentAttributes
      Returns:
      the token from the request if exists
    • storeToken

      boolean storeToken(org.springframework.web.context.request.NativeWebRequest request, IdempotentAttributes attributes, String newToken)
      Store the token into backend storage.
      Parameters:
      request - the NativeWebRequest
      attributes - the IdempotentAttributes
      newToken - the new generated token
      Returns:
      true if stored successfully
    • checkToken

      boolean checkToken(org.springframework.web.context.request.NativeWebRequest request, IdempotentAttributes attributes, String token)
      Check the token is existed
      Parameters:
      request - the NativeWebRequest
      attributes - the IdempotentAttributes
      token - the token
      Returns:
      true if exists
    • invalidate

      boolean invalidate(org.springframework.web.context.request.NativeWebRequest request, IdempotentAttributes attributes, String token)
      Invalidate the token
      Parameters:
      request - the NativeWebRequest
      attributes - the IdempotentAttributes
      token - the token
      Returns:
      true if invalidated successfully
    • renewToken

      default String renewToken(org.springframework.web.context.request.NativeWebRequest request, IdempotentAttributes attributes)
      Renew the token
      Parameters:
      request - the NativeWebRequest
      attributes - the IdempotentAttributes
      Returns:
      the new token
    • validateToken

      default void validateToken(org.springframework.web.context.request.NativeWebRequest request, IdempotentAttributes attributes) throws IdempotentException
      Validate the token
      Parameters:
      request - the NativeWebRequest
      attributes - the IdempotentAttributes
      Throws:
      IdempotentException - if the validated token is invalid
    • destroy

      void destroy()
      Destroy