Package org.wildfly.security.util
Class PasswordBasedEncryptionUtil
- java.lang.Object
-
- org.wildfly.security.util.PasswordBasedEncryptionUtil
-
public final class PasswordBasedEncryptionUtil extends Object
Password Based Encryption utility class for tooling. It provides builder to build PBE masked strings for usage withorg.wildfly.security.credential.store.CredentialStore.- Author:
- Peter Skopek
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPasswordBasedEncryptionUtil.BuilderBuilder class to buildPasswordBasedEncryptionUtilclass with all necessary parameters to support password based encryption algorithms.
-
Field Summary
Fields Modifier and Type Field Description static org.wildfly.common.codec.Base64AlphabetPICKETBOX_COMPATIBILITYThe alphabet used by PicketBox project base 64 encoding.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description char[]decodeAndDecrypt(String encodedPayload)Decode given payload and decrypt it to original.StringencryptAndEncode(char[] payload)Encrypt a payload and encode the result usingAlphabetgiven to builder.AlgorithmParametersgetAlgorithmParameters()Returns algorithm parameters used in the process of encryption.StringgetEncodedIV()Returns encrypted IV (initial vector) as generated by AES algorithm in the process of encryption.
-
-
-
Method Detail
-
encryptAndEncode
public String encryptAndEncode(char[] payload) throws GeneralSecurityException
Encrypt a payload and encode the result usingAlphabetgiven to builder. All necessary parameters are supplied throughPasswordBasedEncryptionUtil.Builder.- Parameters:
payload- secret to encrypt- Returns:
- String encrypted and encoded using given parameters
- Throws:
GeneralSecurityException- when problem occurs like non-existent algorithm or similar problems
-
decodeAndDecrypt
public char[] decodeAndDecrypt(String encodedPayload) throws GeneralSecurityException
Decode given payload and decrypt it to original. All necessary parameters are supplied throughPasswordBasedEncryptionUtil.Builder.- Parameters:
encodedPayload- text to decode and decrypt- Returns:
- decrypted secret
- Throws:
GeneralSecurityException- when problem occurs like non-existent algorithm or similar problems
-
getAlgorithmParameters
public AlgorithmParameters getAlgorithmParameters()
Returns algorithm parameters used in the process of encryption. Might be useful to store them separately after encryption happened. It depends on used algorithm.- Returns:
AlgorithmParametersas generated by encryption process
-
getEncodedIV
public String getEncodedIV()
Returns encrypted IV (initial vector) as generated by AES algorithm in the process of encryption. Other algorithms are not using it. In case of no such data available it returnsnull. It uses already setAlphabetto encode it.- Returns:
- encoded form of IV or
nullwhen not available
-
-