@Test public void testEquals() { Authentication auth1 = new SecretAuthentication( "key", "value" ); Authentication auth2 = new SecretAuthentication( "key", "value" ); Authentication auth3 = new SecretAuthentication( "key", "Value" ); assertEquals( auth1, auth2 ); assertFalse( auth1.equals( auth3 ) ); assertFalse( auth1.equals( null ) ); }
@Override public boolean equals( Object obj ) { if ( this == obj ) { return true; } if ( obj == null || !getClass().equals( obj.getClass() ) ) { return false; } SecretAuthentication that = (SecretAuthentication) obj; if ( !eq( key, that.key ) || secretHash != that.secretHash ) { return false; } char[] secret = copy( value ); char[] thatSecret = copy( that.value ); try { xor( secret ); that.xor( thatSecret ); return Arrays.equals( secret, thatSecret ); } finally { clear( secret ); clear( thatSecret ); } }
SecretAuthentication implements Authentication { @Override public boolean equals( Object obj ) { if ( this == obj ) { return true; } if ( obj == null || !getClass().equals( obj.getClass() ) ) { return false; } SecretAuthentication that = (SecretAuthentication) obj; if ( !eq( key, that.key ) || secretHash != that.secretHash ) { return false; } char[] secret = copy( value ); char[] thatSecret = copy( that.value ); try { xor( secret ); that.xor( thatSecret ); return Arrays.equals( secret, thatSecret ); } finally { clear( secret ); clear( thatSecret ); } } }
SecretAuthentication implements Authentication { @Override public boolean equals( Object obj ) { if ( this == obj ) { return true; } if ( obj == null || !getClass().equals( obj.getClass() ) ) { return false; } SecretAuthentication that = (SecretAuthentication) obj; if ( !eq( key, that.key ) || secretHash != that.secretHash ) { return false; } char[] secret = copy( value ); char[] thatSecret = copy( that.value ); try { xor( secret ); that.xor( thatSecret ); return Arrays.equals( secret, thatSecret ); } finally { clear( secret ); clear( thatSecret ); } } SecretAuthentication( String key, String value );  SecretAuthentication( String key, char[] value ); private  SecretAuthentication( char[] value, String key ); }
SecretAuthentication implements Authentication { @Override public boolean equals( Object obj ) { if ( this == obj ) { return true; } if ( obj == null || !getClass().equals( obj.getClass() ) ) { return false; } SecretAuthentication that = (SecretAuthentication) obj; if ( !eq( key, that.key ) || secretHash != that.secretHash ) { return false; } char[] secret = copy( value ); char[] thatSecret = copy( that.value ); try { xor( secret ); that.xor( thatSecret ); return Arrays.equals( secret, thatSecret ); } finally { clear( secret ); clear( thatSecret ); } } SecretAuthentication( String key, String value );  SecretAuthentication( String key, char[] value ); private  SecretAuthentication( char[] value, String key ); void fill( AuthenticationContext context, String key, Map<String, String> data ); void digest( AuthenticationDigest digest ); @Override boolean equals( Object obj ); @Override int hashCode(); @Override String toString(); }
SecretAuthentication implements Authentication { @Override public boolean equals( Object obj ) { if ( this == obj ) { return true; } if ( obj == null || !getClass().equals( obj.getClass() ) ) { return false; } SecretAuthentication that = (SecretAuthentication) obj; if ( !eq( key, that.key ) || secretHash != that.secretHash ) { return false; } char[] secret = copy( value ); char[] thatSecret = copy( that.value ); try { xor( secret ); that.xor( thatSecret ); return Arrays.equals( secret, thatSecret ); } finally { clear( secret ); clear( thatSecret ); } } SecretAuthentication( String key, String value );  SecretAuthentication( String key, char[] value ); private  SecretAuthentication( char[] value, String key ); void fill( AuthenticationContext context, String key, Map<String, String> data ); void digest( AuthenticationDigest digest ); @Override boolean equals( Object obj ); @Override int hashCode(); @Override String toString();  }