コード例 #1
0
 /**
  * Set and encrypt the secret.
  *
  * @param pSecret The plain secret.
  * @throws SecretEncryptionException if the encryption fails.
  */
 public void setSecret(String pSecret) throws SecretEncryptionException {
   try {
     setTokenSecret(CryptUtil.getSingleton().encrypt(pSecret));
   } catch (NoSuchAlgorithmException
       | NoSuchPaddingException
       | InvalidKeyException
       | ShortBufferException
       | IllegalBlockSizeException
       | BadPaddingException ex) {
     throw new SecretEncryptionException("Failed to set secret", ex);
   }
 }
コード例 #2
0
 /**
  * Get the decrypted secret.
  *
  * @return The secret.
  * @throws SecretDecryptionException if the decryption fails.
  */
 public String getSecret() throws SecretDecryptionException {
   try {
     return CryptUtil.getSingleton().decrypt(getTokenSecret());
   } catch (NoSuchAlgorithmException
       | NoSuchPaddingException
       | InvalidKeyException
       | ShortBufferException
       | IllegalBlockSizeException
       | BadPaddingException ex) {
     throw new SecretDecryptionException("Failed to decrypt secret", ex);
   }
 }