javax.net.ssl.KeyManagerFactorySpi Java Examples

The following examples show how to use javax.net.ssl.KeyManagerFactorySpi. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CustomAliasKeyManagerFactory.java    From armeria with Apache License 2.0 6 votes vote down vote up
CustomAliasKeyManagerFactory(KeyManagerFactory delegate, String alias) {
    super(new KeyManagerFactorySpi() {
        @Override
        protected void engineInit(KeyStore ks, char[] password)
                throws KeyStoreException, NoSuchAlgorithmException, UnrecoverableKeyException {
            delegate.init(ks, password);
        }

        @Override
        protected void engineInit(ManagerFactoryParameters spec) throws InvalidAlgorithmParameterException {
            delegate.init(spec);
        }

        @Override
        protected KeyManager[] engineGetKeyManagers() {
            final KeyManager[] keyManagers = delegate.getKeyManagers().clone();
            for (int i = 0; i < keyManagers.length; i++) {
                if (keyManagers[i] instanceof X509ExtendedKeyManager) {
                    final X509ExtendedKeyManager keyManager = (X509ExtendedKeyManager) keyManagers[i];
                    keyManagers[i] = new CustomAliasX509ExtendedKeyManager(keyManager, alias);
                }
            }
            return keyManagers;
        }
    }, delegate.getProvider(), delegate.getAlgorithm());
}
 
Example #2
Source File: ClientHttpRequestFactoryFactory.java    From spring-vault with Apache License 2.0 5 votes vote down vote up
KeySelectingKeyManagerFactory(KeyManagerFactory factory, KeyConfiguration keyConfiguration) {
	super(new KeyManagerFactorySpi() {
		@Override
		protected void engineInit(KeyStore keyStore, char[] chars)
				throws KeyStoreException, NoSuchAlgorithmException, UnrecoverableKeyException {
			factory.init(keyStore, chars);
		}

		@Override
		protected void engineInit(ManagerFactoryParameters managerFactoryParameters)
				throws InvalidAlgorithmParameterException {
			factory.init(managerFactoryParameters);
		}

		@Override
		protected KeyManager[] engineGetKeyManagers() {

			KeyManager[] keyManagers = factory.getKeyManagers();

			if (keyManagers.length == 1 && keyManagers[0] instanceof X509ExtendedKeyManager) {

				return new KeyManager[] { new KeySelectingX509KeyManager(
						(X509ExtendedKeyManager) keyManagers[0], keyConfiguration) };
			}

			return keyManagers;
		}
	}, factory.getProvider(), factory.getAlgorithm());
}
 
Example #3
Source File: CustomAliasKeyManagerFactory.java    From armeria with Apache License 2.0 5 votes vote down vote up
CustomAliasKeyManagerFactory(KeyManagerFactory delegate, String alias) {
    super(new KeyManagerFactorySpi() {
        @Override
        protected void engineInit(KeyStore ks, char[] password)
                throws KeyStoreException, NoSuchAlgorithmException, UnrecoverableKeyException {
            delegate.init(ks, password);
        }

        @Override
        protected void engineInit(ManagerFactoryParameters spec) throws
                                                                 InvalidAlgorithmParameterException {
            delegate.init(spec);
        }

        @Override
        protected KeyManager[] engineGetKeyManagers() {
            final KeyManager[] keyManagers = delegate.getKeyManagers().clone();
            for (int i = 0; i < keyManagers.length; i++) {
                if (keyManagers[i] instanceof X509ExtendedKeyManager) {
                    final X509ExtendedKeyManager keyManager = (X509ExtendedKeyManager) keyManagers[i];
                    keyManagers[i] = new CustomAliasX509ExtendedKeyManager(keyManager, alias);
                }
            }
            return keyManagers;
        }
    }, delegate.getProvider(), delegate.getAlgorithm());
}