public void setPassword ( final String password ) { this.passwords.clear (); for ( final List<PasswordEncoding> group : this.requestedTypes ) { if ( !group.isEmpty () ) { final PasswordEncoding encoding = group.get ( 0 ); try { // we encode only the first known type ... since this is best this.passwords.put ( encoding, encoding.encodeToHexString ( password ) ); } catch ( final Exception e ) { logger.debug ( "Failed to encode type: " + encoding, e ); } } } }
public String encodeToHexString ( final String password ) throws Exception { return encodeToString ( password, "UTF-8", new HexCodec () ); }
private byte[] makeDigest ( final String plainPassword ) throws NoSuchAlgorithmException { final MessageDigest digest = this.storedEncoding.getDigest (); final ByteBuffer data = this.passwordCharset.encode ( plainPassword ); digest.update ( data.array (), 0, data.remaining () ); return digest.digest (); } }
public String encodeToString ( final String password, final String characterEncoding, final PasswordDigestCodec codec ) throws Exception { return getEncoder ( characterEncoding, codec ).encodePassword ( password ); }
@Override public void parseResponseAttributes ( final Map<String, String> attributes ) { super.parseResponseAttributes ( attributes ); this.passwords.clear (); for ( final Map.Entry<String, String> entry : attributes.entrySet () ) { if ( entry.getKey ().startsWith ( PASSWORD_PREFIX ) ) { final String type = entry.getKey ().substring ( PASSWORD_PREFIX.length () ); try { this.passwords.put ( PasswordEncoding.valueOf ( type ), entry.getValue () ); } catch ( final Exception e ) { logger.debug ( "Failed to decode password encoding: " + type, e ); } } } }
public String encodeToString ( final String password, final String characterEncoding, final PasswordDigestCodec codec ) throws Exception { return getEncoder ( characterEncoding, codec ).encodePassword ( password ); }
@Override public void parseResponseAttributes ( final Map<String, String> attributes ) { super.parseResponseAttributes ( attributes ); this.passwords.clear (); for ( final Map.Entry<String, String> entry : attributes.entrySet () ) { if ( entry.getKey ().startsWith ( PASSWORD_PREFIX ) ) { final String type = entry.getKey ().substring ( PASSWORD_PREFIX.length () ); try { this.passwords.put ( PasswordEncoding.valueOf ( type ), entry.getValue () ); } catch ( final Exception e ) { logger.debug ( "Failed to decode password encoding: " + type, e ); } } } }
public void setPassword ( final String password ) { this.passwords.clear (); for ( final List<PasswordEncoding> group : this.requestedTypes ) { if ( !group.isEmpty () ) { final PasswordEncoding encoding = group.get ( 0 ); try { // we encode only the first known type ... since this is best this.passwords.put ( encoding, encoding.encodeToHexString ( password ) ); } catch ( final Exception e ) { logger.debug ( "Failed to encode type: " + encoding, e ); } } } }
@Override public PasswordEncoder createEncoder () throws Exception { return getEncoding ().getEncoder ( "UTF-8", new HexCodec () ); } };
@Override public void parseRequestAttributes ( final Map<String, String> attributes ) { super.parseRequestAttributes ( attributes ); this.requestedTypes.clear (); for ( final Map.Entry<String, String> entry : attributes.entrySet () ) { if ( entry.getKey ().startsWith ( REQUESTED_TYPES_PREFIX ) ) { final String str = entry.getValue (); if ( str != null ) { final List<PasswordEncoding> encodings = new LinkedList<PasswordEncoding> (); for ( final String tok : Arrays.asList ( str.split ( "\\s*,\\s*" ) ) ) { try { encodings.add ( PasswordEncoding.valueOf ( tok ) ); } catch ( final Exception e ) { logger.debug ( "Failed to parse requested encoding: " + tok, e ); } } this.requestedTypes.add ( encodings ); } } } }
private byte[] makeDigest ( final String plainPassword ) throws NoSuchAlgorithmException { final MessageDigest digest = this.storedEncoding.getDigest (); final ByteBuffer data = this.passwordCharset.encode ( plainPassword ); digest.update ( data.array (), 0, data.remaining () ); return digest.digest (); } }
public String encodeToHexString ( final String password ) throws Exception { return encodeToString ( password, "UTF-8", new HexCodec () ); }
@Override public boolean validatePassword ( final Map<PasswordEncoding, String> passwords, final String storedPassword ) throws Exception { for ( final PasswordEncoding encoding : ENCODINGS ) { final String providedPassword = passwords.get ( encoding ); if ( providedPassword == null ) { continue; } final String storedEncoded = encoding.encodeToHexString ( storedPassword ); return comparePassword ( providedPassword, storedEncoded ); } return false; }
@Override public PasswordEncoder createEncoder () throws Exception { return getEncoding ().getEncoder ( "UTF-8", new HexCodec () ); } },
@Override public void parseRequestAttributes ( final Map<String, String> attributes ) { super.parseRequestAttributes ( attributes ); this.requestedTypes.clear (); for ( final Map.Entry<String, String> entry : attributes.entrySet () ) { if ( entry.getKey ().startsWith ( REQUESTED_TYPES_PREFIX ) ) { final String str = entry.getValue (); if ( str != null ) { final List<PasswordEncoding> encodings = new LinkedList<PasswordEncoding> (); for ( final String tok : Arrays.asList ( str.split ( "\\s*,\\s*" ) ) ) { try { encodings.add ( PasswordEncoding.valueOf ( tok ) ); } catch ( final Exception e ) { logger.debug ( "Failed to parse requested encoding: " + tok, e ); } } this.requestedTypes.add ( encodings ); } } } }
@Override public boolean validatePassword ( final Map<PasswordEncoding, String> passwords, final String storedPassword ) throws Exception { for ( final PasswordEncoding encoding : ENCODINGS ) { final String providedPassword = passwords.get ( encoding ); if ( providedPassword == null ) { continue; } final String storedEncoded = encoding.encodeToHexString ( storedPassword ); return comparePassword ( providedPassword, storedEncoded ); } return false; }
@Override public PasswordEncoder createEncoder () throws Exception { return getEncoding ().getEncoder ( "UTF-8", new HexCodec () ); } },
@Override public PasswordEncoder createEncoder () throws Exception { return getEncoding ().getEncoder ( "UTF-8", new HexCodec () ); } },
@Override public PasswordEncoder createEncoder () throws Exception { return getEncoding ().getEncoder ( "UTF-8", new HexCodec () ); } },
@Override public PasswordEncoder createEncoder () throws Exception { return getEncoding ().getEncoder ( "UTF-8", new HexCodec () ); } },