public synchronized KeyManagerFactory getKeyManagerFactory() throws UnrecoverableKeyException, NoSuchAlgorithmException, KeyStoreException
    {
        try
        {
            if ( keyManagerFactory == null )
            {
                try
                {
                    // OF-1501: If multiple certificates are available, the 'NewSunX509' implementation in the SunJSSE
                    // provider makes the effort to pick a certificate with the appropriate key usage and prefers valid
                    // to expired certificates.
                    keyManagerFactory = KeyManagerFactory.getInstance( "NewSunX509" );
                }
                catch ( NoSuchAlgorithmException e )
                {
                    Log.info( "Unable to load the 'NewSunX509' KeyManager implementation. Will fall back to the default." );
                    keyManagerFactory = KeyManagerFactory.getInstance( KeyManagerFactory.getDefaultAlgorithm() );
                }

                keyManagerFactory.init( configuration.getIdentityStore().getStore(), configuration.getIdentityStoreConfiguration().getPassword() );
            }

            return keyManagerFactory;
        }
        catch ( UnrecoverableKeyException | NoSuchAlgorithmException | KeyStoreException | RuntimeException ex )
        {
            // Allow initialization to restart upon next iteration.
            keyManagerFactory = null;
            throw ex;
        }
    }
Generates a KeyManager factory suitable for connections that are created based on a particular configuration.

@return KeyManagers applicable to a connection that is established using the provided configuration.
@throws UnrecoverableKeyException if the key could not be recovered
@throws NoSuchAlgorithmException if the algorithm was unrecognised
@throws KeyStoreException if there was a problem loading the keystore
xmppserver/src/main/java/org/jivesoftware/openfire/spi/EncryptionArtifactFactory.java