Interface IdempotentService
-
- All Known Implementing Classes:
DefaultIdempotentService
public interface IdempotentServiceTheIdempotentService- Since:
- 1.0.0
- Author:
- Mercy
- See Also:
Idempotent
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description booleancheckToken(org.springframework.web.context.request.NativeWebRequest request, IdempotentAttributes attributes, java.lang.String token)Check the token is existedvoiddestroy()Destroydefault java.lang.StringgenerateToken(org.springframework.web.context.request.NativeWebRequest request, IdempotentAttributes attributes)Generate a new token.java.lang.StringgetToken(org.springframework.web.context.request.NativeWebRequest request, IdempotentAttributes attributes)Get the token from the request.booleaninvalidate(org.springframework.web.context.request.NativeWebRequest request, IdempotentAttributes attributes, java.lang.String token)Invalidate the tokendefault java.lang.StringrenewToken(org.springframework.web.context.request.NativeWebRequest request, IdempotentAttributes attributes)Renew the tokenbooleanstoreToken(org.springframework.web.context.request.NativeWebRequest request, IdempotentAttributes attributes, java.lang.String newToken)Store the token into backend storage.default voidvalidateToken(org.springframework.web.context.request.NativeWebRequest request, IdempotentAttributes attributes)Validate the token
-
-
-
Method Detail
-
generateToken
@Nonnull default java.lang.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- theNativeWebRequestattributes- theIdempotentAttributes- Returns:
- the new token
-
getToken
@Nullable java.lang.String getToken(org.springframework.web.context.request.NativeWebRequest request, IdempotentAttributes attributes)Get the token from the request.- Parameters:
request- theNativeWebRequestattributes- theIdempotentAttributes- Returns:
- the token from the request if exists
-
storeToken
boolean storeToken(org.springframework.web.context.request.NativeWebRequest request, IdempotentAttributes attributes, java.lang.String newToken)Store the token into backend storage.- Parameters:
request- theNativeWebRequestattributes- theIdempotentAttributesnewToken- the new generated token- Returns:
trueif stored successfully
-
checkToken
boolean checkToken(org.springframework.web.context.request.NativeWebRequest request, IdempotentAttributes attributes, java.lang.String token)Check the token is existed- Parameters:
request- theNativeWebRequestattributes- theIdempotentAttributestoken- the token- Returns:
trueif exists
-
invalidate
boolean invalidate(org.springframework.web.context.request.NativeWebRequest request, IdempotentAttributes attributes, java.lang.String token)Invalidate the token- Parameters:
request- theNativeWebRequestattributes- theIdempotentAttributestoken- the token- Returns:
trueif invalidated successfully
-
renewToken
default java.lang.String renewToken(org.springframework.web.context.request.NativeWebRequest request, IdempotentAttributes attributes)Renew the token- Parameters:
request- theNativeWebRequestattributes- theIdempotentAttributes- Returns:
- the new token
-
validateToken
default void validateToken(org.springframework.web.context.request.NativeWebRequest request, IdempotentAttributes attributes) throws IdempotentExceptionValidate the token- Parameters:
request- theNativeWebRequestattributes- theIdempotentAttributes- Throws:
IdempotentException- if the validated token is invalid
-
destroy
void destroy()
Destroy
-
-