コード例 #1
0
 /**
  * Decrypts the encrypted secret using the Blowfish algorithm and the same hard-coded passphrase
  * the JBoss application server uses to decrypt database passwords.
  *
  * @param encryptedSecret the encrypted secret
  * @return the decrypted secret.
  */
 private static String decrypt(String encryptedSecret) {
   CipherInformation cipherInformation = new CipherInformation();
   cipherInformation.setAlgorithm(ALGORITHM);
   cipherInformation.setCipherOperationMode(CipherOperationMode.DECRYPT);
   cipherInformation.setInType(EncodingType.BIGINTEGER16); // TODO
   DecryptionProvider decryptionProvider = CipherFactory.createCipher(cipherInformation, key);
   return new String(decryptionProvider.decrypt(encryptedSecret.getBytes()));
 }
コード例 #2
0
  protected void initCipherDecryptProvider() {
    if (decryptionProvider != null) return;
    Properties properties = SecureVaultUtil.loadProperties();
    StringBuffer sb = new StringBuffer();
    // sb.append(id);
    sb.append(DOT);
    sb.append(LOCATION);

    StringBuffer sbTwo = new StringBuffer();
    // sbTwo.append(id);
    sbTwo.append(DOT);
    sbTwo.append(ALGORITHM);
    // Load algorithm
    String algorithm =
        MiscellaneousUtil.getProperty(properties, sbTwo.toString(), DEFAULT_ALGORITHM);
    StringBuffer buffer = new StringBuffer();
    buffer.append(DOT);
    buffer.append(KEY_STORE);

    // Load keyStore
    String keyStore = MiscellaneousUtil.getProperty(properties, buffer.toString(), null);

    KeyStoreWrapper keyStoreWrapper;

    if (TRUSTED.equals(keyStore)) {
      keyStoreWrapper = trustKeyStoreWrapper;

    } else {
      keyStoreWrapper = identityKeyStoreWrapper;
    }

    CipherInformation cipherInformation = new CipherInformation();
    cipherInformation.setAlgorithm(algorithm);
    cipherInformation.setCipherOperationMode(CipherOperationMode.DECRYPT);
    cipherInformation.setInType(EncodingType.BASE64); // TODO
    decryptionProvider = CipherFactory.createCipher(cipherInformation, keyStoreWrapper);
  }