Interface IdempotentService
- All Known Implementing Classes:
DefaultIdempotentService
public interface IdempotentService
The
Idempotent Service- Since:
- 1.0.0
- Author:
- Mercy
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbooleancheckToken(org.springframework.web.context.request.NativeWebRequest request, IdempotentAttributes attributes, String token) Check the token is existedvoiddestroy()Destroydefault StringgenerateToken(org.springframework.web.context.request.NativeWebRequest request, IdempotentAttributes attributes) Generate a new token.getToken(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, String token) Invalidate the tokendefault StringrenewToken(org.springframework.web.context.request.NativeWebRequest request, IdempotentAttributes attributes) Renew the tokenbooleanstoreToken(org.springframework.web.context.request.NativeWebRequest request, IdempotentAttributes attributes, String newToken) Store the token into backend storage.default voidvalidateToken(org.springframework.web.context.request.NativeWebRequest request, IdempotentAttributes attributes) Validate the token
-
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- theNativeWebRequestattributes- theIdempotentAttributes- 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- theNativeWebRequestattributes- theIdempotentAttributes- 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- theNativeWebRequestattributes- theIdempotentAttributesnewToken- the new generated token- Returns:
trueif stored successfully
-
checkToken
boolean checkToken(org.springframework.web.context.request.NativeWebRequest request, IdempotentAttributes attributes, 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, String token) Invalidate the token- Parameters:
request- theNativeWebRequestattributes- theIdempotentAttributestoken- the token- Returns:
trueif invalidated successfully
-
renewToken
default 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 IdempotentException Validate the token- Parameters:
request- theNativeWebRequestattributes- theIdempotentAttributes- Throws:
IdempotentException- if the validated token is invalid
-
destroy
void destroy()Destroy
-