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 with CredentialStore.
Author:
Peter Skopek
  • Field Details

    • PICKETBOX_COMPATIBILITY

      public static final Base64Alphabet PICKETBOX_COMPATIBILITY
      The alphabet used by PicketBox project base 64 encoding. 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz./
  • Method Details

    • encryptAndEncode

      public String encryptAndEncode(char[] payload) throws GeneralSecurityException
      Encrypt a payload and encode the result using Alphabet given to builder. All necessary parameters are supplied through PasswordBasedEncryptionUtil.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 through PasswordBasedEncryptionUtil.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:
      AlgorithmParameters as 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 returns null. It uses already set Alphabet to encode it.
      Returns:
      encoded form of IV or null when not available