javax.net.ssl.ManagerFactoryParameters Java Examples

The following examples show how to use javax.net.ssl.ManagerFactoryParameters. 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: KeyManagerFactoryImpl.java    From openjsse with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void engineInit(ManagerFactoryParameters params) throws
        InvalidAlgorithmParameterException {
    if (params instanceof KeyStoreBuilderParameters == false) {
        throw new InvalidAlgorithmParameterException(
        "Parameters must be instance of KeyStoreBuilderParameters");
    }
    if (OpenJSSE.isFIPS()) {
        throw new InvalidAlgorithmParameterException
            ("FIPS mode: KeyStoreBuilderParameters not supported");
    }
    List<Builder> builders =
        ((KeyStoreBuilderParameters)params).getParameters();
    keyManager = new X509KeyManagerImpl(builders);
    isInitialized = true;
}
 
Example #2
Source File: AcceptAnyTrustManager.java    From ditto with Eclipse Public License 2.0 6 votes vote down vote up
private Factory(final TrustManagerFactory delegate) {
    super(new TrustManagerFactorySpi() {
        @Override
        protected void engineInit(KeyStore keyStore) {
        }

        @Override
        protected void engineInit(ManagerFactoryParameters managerFactoryParameters) {
        }

        @Override
        protected TrustManager[] engineGetTrustManagers() {
            return new TrustManager[]{new AcceptAnyTrustManager()};
        }
    }, delegate.getProvider(), delegate.getAlgorithm());
}
 
Example #3
Source File: TrustManagerFactoryImpl.java    From openjsse with GNU General Public License v2.0 6 votes vote down vote up
@Override
X509TrustManager getInstance(ManagerFactoryParameters spec)
        throws InvalidAlgorithmParameterException {
    if (spec instanceof CertPathTrustManagerParameters == false) {
        throw new InvalidAlgorithmParameterException
            ("Parameters must be CertPathTrustManagerParameters");
    }
    CertPathParameters params =
        ((CertPathTrustManagerParameters)spec).getParameters();
    if (params instanceof PKIXBuilderParameters == false) {
        throw new InvalidAlgorithmParameterException
            ("Encapsulated parameters must be PKIXBuilderParameters");
    }
    PKIXBuilderParameters pkixParams = (PKIXBuilderParameters)params;
    return new X509TrustManagerImpl(Validator.TYPE_PKIX, pkixParams);
}
 
Example #4
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 #5
Source File: DittoTrustManagerFactory.java    From ditto with Eclipse Public License 2.0 6 votes vote down vote up
private DittoTrustManagerFactory(final TrustManagerFactory delegate, final String hostname) {
    super(new TrustManagerFactorySpi() {
        @Override
        protected void engineInit(KeyStore keyStore) throws KeyStoreException {
            delegate.init(keyStore);
        }

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

        @Override
        protected TrustManager[] engineGetTrustManagers() {
            return DittoTrustManager.wrapTrustManagers(delegate.getTrustManagers(), hostname);
        }
    }, delegate.getProvider(), delegate.getAlgorithm());
}
 
Example #6
Source File: SSLUtils.java    From ssltest with Apache License 2.0 5 votes vote down vote up
/**
 * Gets an array of TrustManagers for the specified trust store
 * and optional CRL file.
 *
 * @param trustStoreFilename
 * @param trustStorePassword
 * @param trustStoreType
 * @param trustStoreProvider
 * @param trustStoreAlgorithm
 * @param maxCertificatePathLength
 * @param crlFilename
 *
 * @return An array of TrustManagers
 *
 * @throws IOException
 * @throws KeyStoreException
 * @throws NoSuchProviderException
 * @throws NoSuchAlgorithmException
 * @throws CertificateException
 * @throws InvalidAlgorithmParameterException
 * @throws CRLException
 */
protected static TrustManager[] getTrustManagers(String trustStoreFilename,
                                                 String trustStorePassword,
                                                 String trustStoreType,
                                                 String trustStoreProvider,
                                                 String trustStoreAlgorithm,
                                                 Integer maxCertificatePathLength,
                                                 String crlFilename)
    throws IOException, KeyStoreException, NoSuchProviderException, NoSuchAlgorithmException, CertificateException, InvalidAlgorithmParameterException, CRLException
{
    KeyStore trustStore = getStore(trustStoreFilename,
                                   trustStorePassword,
                                   trustStoreType,
                                   trustStoreProvider);

    if(null == trustStoreAlgorithm)
        trustStoreAlgorithm = TrustManagerFactory.getDefaultAlgorithm();

    TrustManagerFactory tmf =
            TrustManagerFactory.getInstance(trustStoreAlgorithm);
    if (null == crlFilename)
    {
        tmf.init(trustStore);
    }
    else
    {
        CertPathParameters params =
            getParameters(trustStoreAlgorithm,
                          crlFilename,
                          maxCertificatePathLength,
                          trustStore);

        ManagerFactoryParameters mfp =
            new CertPathTrustManagerParameters(params);

        tmf.init(mfp);
    }

    return tmf.getTrustManagers();
}
 
Example #7
Source File: TrustManagerFactoryImpl.java    From openjsse with GNU General Public License v2.0 5 votes vote down vote up
@Override
X509TrustManager getInstance(ManagerFactoryParameters spec)
        throws InvalidAlgorithmParameterException {
    throw new InvalidAlgorithmParameterException
        ("SunX509 TrustManagerFactory does not use "
        + "ManagerFactoryParameters");
}
 
Example #8
Source File: RootTrustManagerFactorySpi.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public void engineInit(ManagerFactoryParameters spec)
        throws InvalidAlgorithmParameterException {
    if (!(spec instanceof ApplicationConfigParameters)) {
        throw new InvalidAlgorithmParameterException("Unsupported spec: " +  spec + ". Only "
                + ApplicationConfigParameters.class.getName() + " supported");

    }
    mApplicationConfig = ((ApplicationConfigParameters) spec).config;
}
 
Example #9
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());
}
 
Example #10
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 #11
Source File: BogusTrustManagerFactory.java    From red5-client with Apache License 2.0 4 votes vote down vote up
@Override
protected void engineInit(ManagerFactoryParameters managerFactoryParameters) throws InvalidAlgorithmParameterException {
    // noop
}
 
Example #12
Source File: ValidityOnlyTrustManagerFactory.java    From hono with Eclipse Public License 2.0 4 votes vote down vote up
@Override
protected void engineInit(final ManagerFactoryParameters managerFactoryParameters) throws Exception {
    // nothing to do
}
 
Example #13
Source File: SdsTrustManagerFactory.java    From grpc-java with Apache License 2.0 4 votes vote down vote up
@Override
protected void engineInit(ManagerFactoryParameters managerFactoryParameters) throws Exception {
  throw new UnsupportedOperationException();
}
 
Example #14
Source File: XTrustProvider.java    From apigee-deploy-maven-plugin with Apache License 2.0 4 votes vote down vote up
protected void engineInit(ManagerFactoryParameters mgrparams)
   throws InvalidAlgorithmParameterException
{ 
    throw new InvalidAlgorithmParameterException(
        XTrustProvider.NAME + " does not use ManagerFactoryParameters"); 
 }
 
Example #15
Source File: XioTrustManagerFactory.java    From xio with Apache License 2.0 4 votes vote down vote up
@Override
protected void engineInit(ManagerFactoryParameters managerFactoryParameters) throws Exception {}
 
Example #16
Source File: BogusTrustManagerFactory.java    From james-project with Apache License 2.0 4 votes vote down vote up
@Override
protected void engineInit(ManagerFactoryParameters managerFactoryParameters)
        throws InvalidAlgorithmParameterException {
    // Unused
}
 
Example #17
Source File: ClientTrustManagerFactory.java    From game-server with MIT License 4 votes vote down vote up
@Override
protected void engineInit(ManagerFactoryParameters managerFactoryParameters)
        throws InvalidAlgorithmParameterException {
    // noop
}
 
Example #18
Source File: FingerprintTrustManagerFactorySHA256.java    From GreenBits with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void engineInit(final ManagerFactoryParameters managerFactoryParameters) { }
 
Example #19
Source File: XTrustProvider.java    From CrawlerPack with Apache License 2.0 4 votes vote down vote up
protected void engineInit(ManagerFactoryParameters mgrparams)
        throws InvalidAlgorithmParameterException
{
    throw new InvalidAlgorithmParameterException(
            XTrustProvider.NAME + " does not use ManagerFactoryParameters");
}
 
Example #20
Source File: CustomTrustManagerFactory.java    From openhab-core with Eclipse Public License 2.0 4 votes vote down vote up
@Override
protected void engineInit(@Nullable ManagerFactoryParameters managerFactoryParameters) throws Exception {
}
 
Example #21
Source File: TrustManagerFactory.java    From archistar-core with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void engineInit(ManagerFactoryParameters managerFactoryParameters)
        throws InvalidAlgorithmParameterException {
    // Unused
}
 
Example #22
Source File: AbstractReactiveWebServerCustomKeyAliasTest.java    From armeria with Apache License 2.0 4 votes vote down vote up
@Override
protected void engineInit(ManagerFactoryParameters managerFactoryParameters) {}
 
Example #23
Source File: InsecureTrustManagerFactory.java    From AndroidHttpCapture with MIT License 4 votes vote down vote up
@Override
protected void engineInit(ManagerFactoryParameters managerFactoryParameters) throws Exception {
}
 
Example #24
Source File: SecureChatTrustManagerFactory.java    From netty-learning with Apache License 2.0 4 votes vote down vote up
@Override
protected void engineInit(ManagerFactoryParameters managerFactoryParameters)
        throws InvalidAlgorithmParameterException {
    // Unused
}
 
Example #25
Source File: InsecureTrustManagerFactory.java    From Dream-Catcher with MIT License 4 votes vote down vote up
@Override
protected void engineInit(ManagerFactoryParameters managerFactoryParameters) throws Exception {
}
 
Example #26
Source File: InsecureTrustManagerFactory.java    From netty4.0.27Learn with Apache License 2.0 4 votes vote down vote up
@Override
protected void engineInit(ManagerFactoryParameters managerFactoryParameters) throws Exception { }
 
Example #27
Source File: AcceptAllTrustManagerFactory.java    From mqtt-jmeter with Apache License 2.0 4 votes vote down vote up
@Override
protected void engineInit(ManagerFactoryParameters spec) throws InvalidAlgorithmParameterException {
}
 
Example #28
Source File: StaticKeyManagerFactorySpi.java    From aws-sdk-java-v2 with Apache License 2.0 4 votes vote down vote up
@Override
protected void engineInit(ManagerFactoryParameters spec) {
    throw new UnsupportedOperationException("engineInit not supported by this KeyManagerFactory");
}
 
Example #29
Source File: StaticTrustManagerFactory.java    From aws-sdk-java-v2 with Apache License 2.0 4 votes vote down vote up
@Override
protected void engineInit(ManagerFactoryParameters managerFactoryParameters) {
}
 
Example #30
Source File: BogusTrustManagerFactory.java    From neoscada with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected void engineInit(ManagerFactoryParameters managerFactoryParameters)
        throws InvalidAlgorithmParameterException {
    // noop
}