public static byte [ ] decipher ( byte [ ] encrypted_bytes , String crypto_algorithm ) throws InvalidPasswordCipherException , UnsupportedCryptoAlgorithmException { if ( crypto_algorithm == null ) { logger . logp ( Level . SEVERE , PasswordCipherUtil . class . getName ( ) , "decipher" , "PASSWORDUTIL_UNKNOWN_ALGORITHM" , new Object [ ] { "null" , formatSupportedCryptoAlgorithms ( ) } ) ; throw new UnsupportedCryptoAlgorithmException ( ) ; } byte [ ] decrypted_bytes = null ; if ( AES . equalsIgnoreCase ( crypto_algorithm ) ) { decrypted_bytes = aesDecipher ( encrypted_bytes , decrypted_bytes ) ; } else if ( XOR . equalsIgnoreCase ( crypto_algorithm ) ) { decrypted_bytes = xor ( encrypted_bytes ) ; } else if ( HASH . equalsIgnoreCase ( crypto_algorithm ) ) { throw new InvalidPasswordCipherException ( MessageUtils . getMessage ( "PASSWORDUTIL_ERROR_UNSUPPORTED_OPERATION" , crypto_algorithm ) ) ; } else if ( CUSTOM . equalsIgnoreCase ( crypto_algorithm ) || crypto_algorithm . startsWith ( CUSTOM_COLON ) ) { CustomPasswordEncryption cpe = getCustomImpl ( ) ; if ( cpe != null ) { int index = crypto_algorithm . indexOf ( ' ' ) ; String keyAlias = null ; if ( index != - 1 ) { keyAlias = crypto_algorithm . substring ( index + 1 ) ; } try { decrypted_bytes = cpe . decrypt ( new EncryptedInfo ( encrypted_bytes , keyAlias ) ) ; if ( logger . isLoggable ( Level . FINE ) ) logger . fine ( "Successfully decrypted password using custom encryption plug point." ) ; } catch ( Exception e ) { logger . logp ( Level . SEVERE , PasswordCipherUtil . class . getName ( ) , "decipher" , "PASSWORDUTIL_CUSTOM_DECRYPTION_ERROR" , e ) ; throw ( InvalidPasswordCipherException ) new InvalidPasswordCipherException ( e . getMessage ( ) ) . initCause ( e ) ; } } else { logger . logp ( Level . SEVERE , PasswordCipherUtil . class . getName ( ) , "decipher" , "PASSWORDUTIL_CUSTOM_SERVICE_DOES_NOT_EXIST" ) ; throw new UnsupportedCryptoAlgorithmException ( ) ; } } else { logger . logp ( Level . SEVERE , PasswordCipherUtil . class . getName ( ) , "decipher" , "PASSWORDUTIL_UNKNOWN_ALGORITHM" , new Object [ ] { crypto_algorithm , formatSupportedCryptoAlgorithms ( ) } ) ; throw new UnsupportedCryptoAlgorithmException ( ) ; } if ( decrypted_bytes == null ) { throw new InvalidPasswordCipherException ( "The output is null." ) ; } return decrypted_bytes ; }
Decipher the input password using the provided algorithm .