private RSAPublicKey getKeyForUser ( String userName ) throws KeyNotFoundException { RSAPublicKey key = null ; for ( final KeyProvider keyProvider : keyProviders ) { try { key = keyProvider . getKey ( userName ) ; break ; } catch ( KeyNotFoundException e ) { // that's fine, try the next provider } } if ( key == null ) { throw new KeyNotFoundException ( ) ; } return key ; }
Get the public key for a user by iterating through all key providers . The first matching key will be returned .