### Question:
PasswordUtil { public static boolean compareCredentials( byte[] receivedCredentials, byte[] storedCredentials ) { LdapSecurityConstants algorithm = findAlgorithm( storedCredentials ); if ( algorithm != null ) { PasswordDetails passwordDetails = PasswordUtil.splitCredentials( storedCredentials ); byte[] userPassword = PasswordUtil.encryptPassword( receivedCredentials, passwordDetails.getAlgorithm(), passwordDetails.getSalt() ); return compareBytes( userPassword, passwordDetails.getPassword() ); } else { return compareBytes( receivedCredentials, storedCredentials ); } } private  PasswordUtil(); static LdapSecurityConstants findAlgorithm( byte[] credentials ); static byte[] createStoragePassword( String credentials, LdapSecurityConstants algorithm ); static byte[] createStoragePassword( byte[] credentials, LdapSecurityConstants algorithm ); static boolean compareCredentials( byte[] receivedCredentials, byte[] storedCredentials ); static PasswordDetails splitCredentials( byte[] credentials ); static boolean isPwdExpired( String pwdChangedZtime, int pwdMaxAgeSec, TimeProvider timeProvider ); static final int SHA1_LENGTH; static final int SHA256_LENGTH; static final int SHA384_LENGTH; static final int SHA512_LENGTH; static final int MD5_LENGTH; static final int PKCS5S2_LENGTH; static final int CRYPT_LENGTH; static final int CRYPT_MD5_LENGTH; static final int CRYPT_SHA256_LENGTH; static final int CRYPT_SHA512_LENGTH; static final int CRYPT_BCRYPT_LENGTH; }### Answer:
@Test public void compareCredentialTest() { assertTrue( PasswordUtil.compareCredentials( null, null ) ); assertTrue( PasswordUtil.compareCredentials( new byte[] {}, new byte[] {} ) ); assertTrue( PasswordUtil.compareCredentials( new byte[] { 0x01 }, new byte[] { 0x01 } ) ); assertFalse( PasswordUtil.compareCredentials( null, new byte[] { 0x01 } ) ); assertFalse( PasswordUtil.compareCredentials( new byte[] { 0x01 }, null ) ); assertFalse( PasswordUtil.compareCredentials( new byte[] { 0x01 }, new byte[] { 0x02 } ) ); assertFalse( PasswordUtil.compareCredentials( Strings.getBytesUtf8( "Password1" ), Strings.getBytesUtf8( "Password1 " ) ) ); assertFalse( PasswordUtil.compareCredentials( Strings.getBytesUtf8( "Password1" ), Strings.getBytesUtf8( "password1" ) ) ); assertTrue( PasswordUtil.compareCredentials( Strings.getBytesUtf8( "Password1" ), Strings.getBytesUtf8( "Password1" ) ) ); }