Source:
private String decryptProperty(String propValue) throws CryptoException { String cipherTransformation = System.getProperty(CIPHER_TRANSFORMATION_SYSTEM_PROPERTY); byte[] cipherTextBytes = Base64.decode(propValue.trim()); String algorithm = null; byte[] decryptedValue; CryptoService cryptoService = UserStoreMgtDataHolder.getInstance().getCryptoService(); if (cipherTransformation != null) { CipherMetaDataHolder cipherHolder = cipherTextToCipherHolder(cipherTextBytes); if (cipherHolder != null) { if (log.isDebugEnabled()) { log.debug("Cipher transformation for decryption : " + cipherHolder.getTransformation()); } algorithm = cipherHolder.getTransformation(); cipherTextBytes = cipherHolder.getCipherBase64Decoded(); } else { algorithm = cipherTransformation; } } if (cipherTextBytes.length == 0) { decryptedValue = StringUtils.EMPTY.getBytes(); if (log.isDebugEnabled()) { log.debug("Ciphertext is empty. An empty array will be used as the plaintext bytes."); } } else { decryptedValue = cryptoService.decrypt(cipherTextBytes, algorithm, CRYPTO_API_PROVIDER_BC); } return new String(decryptedValue); }

Target:
private String decryptProperty(String propValue) throws CryptoException { CryptoService cryptoService = UserStoreMgtDataHolder.getInstance().getCryptoService(); String cipherTransformation = System.getProperty(CIPHER_TRANSFORMATION_SYSTEM_PROPERTY); byte[] cipherTextBytes = Base64.decode(propValue.trim()); String algorithm = null; byte[] decryptedValue; boolean isInternalKeyStoreEncryptionEnabled = false; boolean isSymmetricKeyEncryptionEnabled = false; ServerConfigurationService config = UserStoreMgtDSComponent.getServerConfigurationService(); if (config != null) { String encryptionKeyStore = config.getFirstProperty(ENCRYPTION_KEYSTORE); if (INTERNAL_KEYSTORE.equalsIgnoreCase(encryptionKeyStore)) { isInternalKeyStoreEncryptionEnabled = true; } String cryptoProvider = config.getFirstProperty(CRYPTO_PROVIDER); if (SYMMETRIC_KEY_CRYPTO_PROVIDER.equalsIgnoreCase(cryptoProvider)) { isSymmetricKeyEncryptionEnabled = true; } } if (isInternalKeyStoreEncryptionEnabled && isSymmetricKeyEncryptionEnabled) { throw new CryptoException(String.format("Userstore encryption can not be supported due to " + "conflicting configurations: '%s' and '%s'. When using internal keystore, assymetric crypto " + "provider should be used.", INTERNAL_KEYSTORE, SYMMETRIC_KEY_CRYPTO_PROVIDER)); } else if (isInternalKeyStoreEncryptionEnabled || isSymmetricKeyEncryptionEnabled) { if (cipherTransformation != null) { CipherMetaDataHolder cipherHolder = cipherTextToCipherHolder(cipherTextBytes); if (cipherHolder != null) { if (log.isDebugEnabled()) { log.debug("Cipher transformation for decryption : " + cipherHolder.getTransformation()); } algorithm = cipherHolder.getTransformation(); cipherTextBytes = cipherHolder.getCipherBase64Decoded(); } else { algorithm = cipherTransformation; } } if (cipherTextBytes.length == 0) { decryptedValue = StringUtils.EMPTY.getBytes(); if (log.isDebugEnabled()) { log.debug("Ciphertext is empty. An empty array will be used as the plaintext bytes."); } } else { decryptedValue = cryptoService.decrypt(cipherTextBytes, algorithm, CRYPTO_API_PROVIDER_BC); } return new String(decryptedValue); } else { return decryptWithPrimaryKeyStore(propValue); } }