private void fixKeyManagers ( ) { // If the key manager factory is null, do not continue if ( null == keyManagerFactory || null == keyManagerFactory . getKeyManagers ( ) ) { return ; } KeyManager [ ] defaultKeyManagers = keyManagerFactory . getKeyManagers ( ) ; KeyManager [ ] newKeyManagers = new KeyManager [ defaultKeyManagers . length ] ; KeyManager mgr = null ; for ( int i = 0 ; i < defaultKeyManagers . length ; i ++ ) { mgr = defaultKeyManagers [ i ] ; // If we're looking at an X509 Key manager, then wrap it in our // alias-selective manager if ( mgr instanceof X509KeyManager ) { mgr = new AliasSensitiveX509KeyManager ( this , ( X509KeyManager ) mgr ) ; } newKeyManagers [ i ] = mgr ; } keyManagers = newKeyManagers ; }
If a keystore alias is defined then override the key manager assigned to with an alias - sensitive wrapper that selects the proper key from your assigned key alias .