/** * Find the first provider from the supplier which provides the given service type and algorithm name. The simple * name of the service type class is used to identify the service. * * If a providerName is specified the match will only be tested against providers with the name specified. * * @param providerSupplier the provider supplier (must not be {@code null}) * @param providerName the name of the provider, can be {@code null} * @param serviceType the service type as a class name (must not be {@code null}) * @param algorithm the algorithm name (must not be {@code null}) * @return the provider, or {@code null} if none is found */ public static Provider findProvider(Supplier<Provider[]> providerSupplier, String providerName, Class<?> serviceType, String algorithm) { Assert.checkNotNullParam("serviceType", serviceType); return findProvider(providerSupplier, providerName, serviceType.getSimpleName(), algorithm); }
public KeyStore get() throws ConfigXMLParseException { Provider provider = findProvider(providers, providerName, KeyStore.class, type); if (provider == null) { throw xmlLog.xmlUnableToIdentifyProvider(location, providerName, "KeyStore", type); } try { return KeyStore.getInstance(type, provider); } catch (GeneralSecurityException e) { throw xmlLog.xmlFailedToCreateKeyStore(location, e); } } }
X509ExtendedKeyManager build() throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException, ConfigXMLParseException { final String algorithm = this.algorithm != null ? this.algorithm : KeyManagerFactory.getDefaultAlgorithm(); Provider provider = findProvider(providers, providerName, KeyManagerFactory.class, algorithm); if (provider == null) { throw xmlLog.xmlUnableToIdentifyProvider(xmlLocation, providerName, "KeyManagerFactory", algorithm); } KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(algorithm, provider); keyManagerFactory.init(keyStoreSupplier != null ? keyStoreSupplier.get() : null, null); for (KeyManager keyManager : keyManagerFactory.getKeyManagers()) { if (keyManager instanceof X509ExtendedKeyManager) { return (X509ExtendedKeyManager) keyManager; } } throw ElytronMessages.log.noDefaultKeyManager(); } }
X509TrustManager build() throws NoSuchAlgorithmException, KeyStoreException, ConfigXMLParseException { final String algorithm = this.algorithm != null ? this.algorithm : TrustManagerFactory.getDefaultAlgorithm(); Provider provider = findProvider(providers, providerName, TrustManagerFactory.class, algorithm); if (provider == null) { throw xmlLog.xmlUnableToIdentifyProvider(xmlLocation, providerName, "TrustManagerFactory", algorithm); } final TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(algorithm, provider); if (crl) { return new X509CRLExtendedTrustManager(trustStore, trustManagerFactory, crlStream, maxCertPath, null); } else { trustManagerFactory.init(trustStore); } for (TrustManager trustManager : trustManagerFactory.getTrustManagers()) { if (trustManager instanceof X509TrustManager) { return (X509TrustManager) trustManager; } } throw ElytronMessages.log.noDefaultTrustManager(); } }
Provider provider = findProvider(providers, finalProviderName, KeyManagerFactory.class, algorithmResolved); if (provider == null) { throw xmlLog.xmlUnableToIdentifyProvider(location, finalProviderName, "KeyManagerFactory", algorithmResolved);
/** * Find the first provider from the supplier which provides the given service type and algorithm name. The simple * name of the service type class is used to identify the service. * * If a providerName is specified the match will only be tested against providers with the name specified. * * @param providerSupplier the provider supplier (must not be {@code null}) * @param providerName the name of the provider, can be {@code null} * @param serviceType the service type as a class name (must not be {@code null}) * @param algorithm the algorithm name (must not be {@code null}) * @return the provider, or {@code null} if none is found */ public static Provider findProvider(Supplier<Provider[]> providerSupplier, String providerName, Class<?> serviceType, String algorithm) { Assert.checkNotNullParam("serviceType", serviceType); return findProvider(providerSupplier, providerName, serviceType.getSimpleName(), algorithm); }
/** * Find the first provider from the supplier which provides the given service type and algorithm name. The simple * name of the service type class is used to identify the service. * * If a providerName is specified the match will only be tested against providers with the name specified. * * @param providerSupplier the provider supplier (must not be {@code null}) * @param providerName the name of the provider, can be {@code null} * @param serviceType the service type as a class name (must not be {@code null}) * @param algorithm the algorithm name (must not be {@code null}) * @return the provider, or {@code null} if none is found */ public static Provider findProvider(Supplier<Provider[]> providerSupplier, String providerName, Class<?> serviceType, String algorithm) { Assert.checkNotNullParam("serviceType", serviceType); return findProvider(providerSupplier, providerName, serviceType.getSimpleName(), algorithm); }
/** * Find the first provider from the supplier which provides the given service type and algorithm name. The simple * name of the service type class is used to identify the service. * * If a providerName is specified the match will only be tested against providers with the name specified. * * @param providerSupplier the provider supplier (must not be {@code null}) * @param providerName the name of the provider, can be {@code null} * @param serviceType the service type as a class name (must not be {@code null}) * @param algorithm the algorithm name (must not be {@code null}) * @return the provider, or {@code null} if none is found */ public static Provider findProvider(Supplier<Provider[]> providerSupplier, String providerName, Class<?> serviceType, String algorithm) { Assert.checkNotNullParam("serviceType", serviceType); return findProvider(providerSupplier, providerName, serviceType.getSimpleName(), algorithm); }
public KeyStore get() throws ConfigXMLParseException { Provider provider = findProvider(providers, providerName, KeyStore.class, type); if (provider == null) { throw xmlLog.xmlUnableToIdentifyProvider(location, providerName, "KeyStore", type); } try { return KeyStore.getInstance(type, provider); } catch (GeneralSecurityException e) { throw xmlLog.xmlFailedToCreateKeyStore(location, e); } } }
public KeyStore get() throws ConfigXMLParseException { Provider provider = findProvider(providers, providerName, KeyStore.class, type); if (provider == null) { throw xmlLog.xmlUnableToIdentifyProvider(location, providerName, "KeyStore", type); } try { return KeyStore.getInstance(type, provider); } catch (GeneralSecurityException e) { throw xmlLog.xmlFailedToCreateKeyStore(location, e); } } }
private Provider resolveProvider() throws StartException { Provider[] candidates = providers.getOptionalValue(); Supplier<Provider[]> providersSupplier = () -> candidates == null ? Security.getProviders() : candidates; Provider identified = findProvider(providersSupplier, provider, KeyStore.class, type); if (identified == null) { throw ROOT_LOGGER.noSuitableProvider(type); } return identified; }
public KeyStore get() throws ConfigXMLParseException { Provider provider = findProvider(providers, providerName, KeyStore.class, type); if (provider == null) { throw xmlLog.xmlUnableToIdentifyProvider(location, providerName, "KeyStore", type); } try { return KeyStore.getInstance(type, provider); } catch (GeneralSecurityException e) { throw xmlLog.xmlFailedToCreateKeyStore(location, e); } } }
X509ExtendedKeyManager build() throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException, ConfigXMLParseException { final String algorithm = this.algorithm != null ? this.algorithm : KeyManagerFactory.getDefaultAlgorithm(); Provider provider = findProvider(providers, providerName, KeyManagerFactory.class, algorithm); if (provider == null) { throw xmlLog.xmlUnableToIdentifyProvider(xmlLocation, providerName, "KeyManagerFactory", algorithm); } KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(algorithm, provider); keyManagerFactory.init(keyStoreSupplier != null ? keyStoreSupplier.get() : null, null); for (KeyManager keyManager : keyManagerFactory.getKeyManagers()) { if (keyManager instanceof X509ExtendedKeyManager) { return (X509ExtendedKeyManager) keyManager; } } throw ElytronMessages.log.noDefaultKeyManager(); } }
X509ExtendedKeyManager build() throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException, ConfigXMLParseException { final String algorithm = this.algorithm != null ? this.algorithm : KeyManagerFactory.getDefaultAlgorithm(); Provider provider = findProvider(providers, providerName, KeyManagerFactory.class, algorithm); if (provider == null) { throw xmlLog.xmlUnableToIdentifyProvider(xmlLocation, providerName, "KeyManagerFactory", algorithm); } KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(algorithm, provider); keyManagerFactory.init(keyStoreSupplier != null ? keyStoreSupplier.get() : null, null); for (KeyManager keyManager : keyManagerFactory.getKeyManagers()) { if (keyManager instanceof X509ExtendedKeyManager) { return (X509ExtendedKeyManager) keyManager; } } throw ElytronMessages.log.noDefaultKeyManager(); } }
X509ExtendedKeyManager build() throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException, ConfigXMLParseException { final String algorithm = this.algorithm != null ? this.algorithm : KeyManagerFactory.getDefaultAlgorithm(); Provider provider = findProvider(providers, providerName, KeyManagerFactory.class, algorithm); if (provider == null) { throw xmlLog.xmlUnableToIdentifyProvider(xmlLocation, providerName, "KeyManagerFactory", algorithm); } KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(algorithm, provider); keyManagerFactory.init(keyStoreSupplier != null ? keyStoreSupplier.get() : null, null); for (KeyManager keyManager : keyManagerFactory.getKeyManagers()) { if (keyManager instanceof X509ExtendedKeyManager) { return (X509ExtendedKeyManager) keyManager; } } throw ElytronMessages.log.noDefaultKeyManager(); } }
X509TrustManager build() throws NoSuchAlgorithmException, KeyStoreException, ConfigXMLParseException { final String algorithm = this.algorithm != null ? this.algorithm : TrustManagerFactory.getDefaultAlgorithm(); Provider provider = findProvider(providers, providerName, TrustManagerFactory.class, algorithm); if (provider == null) { throw xmlLog.xmlUnableToIdentifyProvider(xmlLocation, providerName, "TrustManagerFactory", algorithm); } final TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(algorithm, provider); if (crl) { return new X509CRLExtendedTrustManager(trustStore, trustManagerFactory, crlStream, maxCertPath, null); } else { trustManagerFactory.init(trustStore); } for (TrustManager trustManager : trustManagerFactory.getTrustManagers()) { if (trustManager instanceof X509TrustManager) { return (X509TrustManager) trustManager; } } throw ElytronMessages.log.noDefaultTrustManager(); } }
X509TrustManager build() throws NoSuchAlgorithmException, KeyStoreException, ConfigXMLParseException { final String algorithm = this.algorithm != null ? this.algorithm : TrustManagerFactory.getDefaultAlgorithm(); Provider provider = findProvider(providers, providerName, TrustManagerFactory.class, algorithm); if (provider == null) { throw xmlLog.xmlUnableToIdentifyProvider(xmlLocation, providerName, "TrustManagerFactory", algorithm); } final TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(algorithm, provider); if (crl) { return new X509CRLExtendedTrustManager(trustStore, trustManagerFactory, crlStream, maxCertPath, null); } else { trustManagerFactory.init(trustStore); } for (TrustManager trustManager : trustManagerFactory.getTrustManagers()) { if (trustManager instanceof X509TrustManager) { return (X509TrustManager) trustManager; } } throw ElytronMessages.log.noDefaultTrustManager(); } }
X509TrustManager build() throws NoSuchAlgorithmException, KeyStoreException, ConfigXMLParseException { final String algorithm = this.algorithm != null ? this.algorithm : TrustManagerFactory.getDefaultAlgorithm(); Provider provider = findProvider(providers, providerName, TrustManagerFactory.class, algorithm); if (provider == null) { throw xmlLog.xmlUnableToIdentifyProvider(xmlLocation, providerName, "TrustManagerFactory", algorithm); } final TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(algorithm, provider); if (crl) { return new X509CRLExtendedTrustManager(trustStore, trustManagerFactory, crlStream, maxCertPath, null); } else { trustManagerFactory.init(trustStore); } for (TrustManager trustManager : trustManagerFactory.getTrustManagers()) { if (trustManager instanceof X509TrustManager) { return (X509TrustManager) trustManager; } } throw ElytronMessages.log.noDefaultTrustManager(); } }
private static KeyStore tryLoadKeystore(final Supplier<Provider[]> providers, final String providerName, InputStream is, char[] password, String... types) { for (String type : types) { try { log.debug("Searching provider for: " + type); Provider provider = findProvider(providers, providerName, KeyStore.class, type); if (provider == null) { log.debug("Provider not found"); continue; } log.debug("Provider found: " + provider.getName()); KeyStore keystore = KeyStore.getInstance(type, provider); is.reset(); keystore.load(is, password); return keystore; } catch (Exception e) { log.debug("KeyStore is not of type " + type); continue; } } return null; }
Provider provider = findProvider(providers, finalProviderName, KeyManagerFactory.class, algorithmResolved); if (provider == null) { throw xmlLog.xmlUnableToIdentifyProvider(location, finalProviderName, "KeyManagerFactory", algorithmResolved);