Klasse Ltpa2Utils
java.lang.Object
de.sephirothj.spring.security.ltpa2.Ltpa2Utils
Utility class for operations on an LTPA2 token
- Autor:
- Sephiroth
-
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungdecryptLtpa2Token
(String encryptedToken, SecretKey key) decrypts an base64-encoded LTPA2 tokenencryptToken
(Ltpa2Token token, PrivateKey signerKey, SecretKey key) create a serialized, signed and encrypted LTPA2 tokenboolean
isSignatureValid
(String token, PublicKey signerKey) checks if the signature of the given token is validboolean
isTokenExpired
(String token) checks if the given token is expiredmakeInstance
(String tokenStr) create a new instance of Ltpa2Token from the given serialized LTPA2 tokensignToken
(String token, PrivateKey key) signs the given LTPA2 token
-
Konstruktordetails
-
Ltpa2Utils
public Ltpa2Utils()
-
-
Methodendetails
-
decryptLtpa2Token
@NonNull public String decryptLtpa2Token(@NonNull String encryptedToken, @NonNull SecretKey key) throws InvalidLtpa2TokenException decrypts an base64-encoded LTPA2 token- Parameter:
encryptedToken
- the base64-encoded and encrypted tokenkey
- the shared secret key that was used to encryptencryptedToken
- Gibt zurück:
- the serialized token
- Löst aus:
InvalidLtpa2TokenException
- in case something went wrong
-
makeInstance
create a new instance of Ltpa2Token from the given serialized LTPA2 token- Parameter:
tokenStr
- a serialized LTPA2 token (unencrypted)- Gibt zurück:
- instance of Ltpa2Token
- Löst aus:
InvalidLtpa2TokenException
- if the token is malformed
-
isTokenExpired
checks if the given token is expired- Parameter:
token
- a serialized LTPA2 token (unencrypted)- Gibt zurück:
- whether the given token is expired or not
- Löst aus:
InvalidLtpa2TokenException
- if the token is malformed- Siehe auch:
-
isSignatureValid
public boolean isSignatureValid(@NonNull String token, @NonNull PublicKey signerKey) throws InvalidLtpa2TokenException checks if the signature of the given token is valid- Parameter:
token
- a serialized LTPA2 token (unencrypted)signerKey
- the public key which corresponds to the private key that was used to sign an LTPA2 token- Gibt zurück:
- whether the signature for the given token is valid or not
- Löst aus:
InvalidLtpa2TokenException
- in case an error occured during signature verificationInvalidLtpa2TokenException
- if the token is malformed
-
signToken
@NonNull public String signToken(@NonNull String token, @NonNull PrivateKey key) throws InvalidLtpa2TokenException signs the given LTPA2 token- Parameter:
token
- a serialized LTPA2 token (unencrypted)key
- the private key for signing the given token- Gibt zurück:
- the base64-encoded signature of the token
- Löst aus:
InvalidLtpa2TokenException
- in case an error occured during signature creation- Siehe auch:
-
encryptToken
@NonNull public String encryptToken(@NonNull Ltpa2Token token, @NonNull PrivateKey signerKey, @NonNull SecretKey key) throws InvalidLtpa2TokenException create a serialized, signed and encrypted LTPA2 token- Parameter:
token
- the tokensignerKey
- the private key for signing the given tokenkey
- the shared secret key for encrypting the given token- Gibt zurück:
- serialized, signed and encrypted LTPA2 token
- Löst aus:
InvalidLtpa2TokenException
- in case an error occured during signature creationInvalidLtpa2TokenException
- in case an error occured during encrypting the token
-