/** * Get the SSL context which matches the given URI, or {@link SSLContext#getDefault()} if there is none. * * @param uri the URI to match (must not be {@code null}) * @param authenticationContext the authentication context to examine (must not be {@code null}) * @return the matching SSL context */ public SSLContext getSSLContext(URI uri, AuthenticationContext authenticationContext) throws GeneralSecurityException { return getSSLContext(uri, authenticationContext, null, null); }
@Override public SSLContext get() { AuthenticationContextConfigurationClient contextConfigurationClient = AccessController.doPrivileged(AuthenticationContextConfigurationClient.ACTION); try { return contextConfigurationClient.getSSLContext(tokenEndpointUrl.toURI(), AuthenticationContext.captureCurrent()); } catch (Exception cause) { throw saslOAuth2.failedToObtainSSLContext(cause); } } };
private IoFuture<ConnectionPeerIdentity> getFuturePeerIdentityPrivileged(final URI location) { final Supplier<AuthenticationContext> supplier = providerEnvironment.getAuthenticationContextSupplier(); final AuthenticationContext context = supplier.get(); final SSLContext sslContext; try { sslContext = CLIENT.getSSLContext(location, context, "jndi", "jboss"); } catch (GeneralSecurityException e) { return new FailedIoFuture<>(new IOException(e)); } final AuthenticationConfiguration authenticationConfiguration = CLIENT.getAuthenticationConfiguration(location, context, -1, "jndi", "jboss"); return endpoint.getConnectedIdentity(location, sslContext, authenticationConfiguration); } }
public IoFuture<Connection> connect(final URI destination, final InetSocketAddress bindAddress, final OptionMap connectOptions, final AuthenticationContext authenticationContext) { final AuthenticationContextConfigurationClient client = AUTH_CONFIGURATION_CLIENT; final AuthenticationConfiguration configuration = client.getAuthenticationConfiguration(destination, authenticationContext, - 1, null, null); final SSLContext sslContext; try { sslContext = client.getSSLContext(destination, authenticationContext, null, null); } catch (GeneralSecurityException e) { return new FailedIoFuture<>(Messages.conn.failedToConfigureSslContext(e)); } return connect(destination, bindAddress, connectOptions, configuration, sslContext); }
private void acquireSessionAffinity(CountDownLatch latch, AuthenticationConfiguration authenticationConfiguration) { ClientRequest clientRequest = new ClientRequest(); clientRequest.setMethod(Methods.GET); clientRequest.setPath(uri.getPath() + "/common/v1/affinity"); AuthenticationContext context = AuthenticationContext.captureCurrent(); SSLContext sslContext; try { sslContext = AUTH_CONTEXT_CLIENT.getSSLContext(uri, context); } catch (GeneralSecurityException e) { latch.countDown(); HttpClientMessages.MESSAGES.failedToAcquireSession(e); return; } sendRequest(clientRequest, sslContext, authenticationConfiguration, null, null, (e) -> { latch.countDown(); HttpClientMessages.MESSAGES.failedToAcquireSession(e); }, null, latch::countDown); }
ConnectionPeerIdentity getPeerIdentity() throws IOException { SSLContext finalSslContext; if (sslContext == null) { try { finalSslContext = CLIENT.getSSLContext(location, AuthenticationContext.captureCurrent(), "jta", "jboss"); } catch (GeneralSecurityException e) { throw new IOException(e); } } else { finalSslContext = sslContext; } AuthenticationConfiguration finalAuthenticationConfiguration; if (authenticationConfiguration == null) { finalAuthenticationConfiguration = CLIENT.getAuthenticationConfiguration(location, AuthenticationContext.captureCurrent(), -1, "jta", "jboss"); } else { finalAuthenticationConfiguration = authenticationConfiguration; } return endpoint.getConnectedIdentity(location, finalSslContext, finalAuthenticationConfiguration).get(); }
/** * Get a pre-existing connection to the destination. * <p> * If no existing connection was found, {@code null} is returned. If a non-{@code null} {@code IoFuture} is * returned, it may represent a complete connection, a failed attempt, or an in-progress attempt. * * @param destination the destination URI (must not be {@code null}) * @param abstractType the abstract type of the connection (may be {@code null}) * @param abstractTypeAuthority the authority name of the abstract type of the connection (may be {@code null}) * @return the existing connection, or {@code null} if no connection currently exists */ @Deprecated default IoFuture<Connection> getConnectionIfExists(URI destination, String abstractType, String abstractTypeAuthority) { final AuthenticationContext context = AuthenticationContext.captureCurrent(); final AuthenticationContextConfigurationClient client = AUTH_CONFIGURATION_CLIENT; final SSLContext sslContext; try { sslContext = client.getSSLContext(destination, context); } catch (GeneralSecurityException e) { return new FailedIoFuture<>(Messages.conn.failedToConfigureSslContext(e)); } final AuthenticationConfiguration authenticationConfiguration = client.getAuthenticationConfiguration(destination, context, -1, abstractType, abstractTypeAuthority); return getConnectionIfExists(destination, sslContext, authenticationConfiguration, authenticationConfiguration); }
tempContext = AUTH_CONFIGURATION_CLIENT.getSSLContext(uri, captured); } catch (GeneralSecurityException e) { log.trace("No SSLContext available", e);
IoFuture<ConnectionPeerIdentity> getConnectedIdentityUsingClusterEffective(Endpoint endpoint, URI destination, String abstractType, String abstractTypeAuthority, AuthenticationContext context, String clusterName) { Assert.checkNotNullParam("destination", destination); Assert.checkNotNullParam("context", context); URI effectiveAuth = clusterName != null ? effectiveAuthURIs.get(clusterName) : null; boolean updateAuth = effectiveAuth != null; if (!updateAuth) { effectiveAuth = destination; } final AuthenticationContextConfigurationClient client = AUTH_CONFIGURATION_CLIENT; final SSLContext sslContext; try { sslContext = client.getSSLContext(destination, context); } catch (GeneralSecurityException e) { return new FailedIoFuture<>(Logs.REMOTING.failedToConfigureSslContext(e)); } final AuthenticationConfiguration authenticationConfiguration = client.getAuthenticationConfiguration(effectiveAuth, context, -1, abstractType, abstractTypeAuthority); return endpoint.getConnectedIdentity(destination, sslContext, updateAuth ? fixupOverrides(authenticationConfiguration, destination) : authenticationConfiguration); }
/** * See JBEAP-14783 */ @Deprecated public IoFuture<Connection> connect(URI destination, OptionMap connectOptions, CallbackHandler callbackHandler) throws IOException { final AuthenticationContextConfigurationClient client = AUTH_CONFIGURATION_CLIENT; AuthenticationContext authenticationContext = AuthenticationContext.captureCurrent(); AuthenticationConfiguration connectionConfiguration = client .getAuthenticationConfiguration(destination, authenticationContext).useCallbackHandler(callbackHandler); connectionConfiguration = RemotingOptions.mergeOptionsIntoAuthenticationConfiguration(connectOptions, connectionConfiguration); final SSLContext sslContext; try { sslContext = client.getSSLContext(destination, authenticationContext); } catch (GeneralSecurityException e) { return new FailedIoFuture<>(Messages.conn.failedToConfigureSslContext(e)); } return connect(destination, null, connectOptions, sslContext, connectionConfiguration); }
final SSLContext sslContext; try { sslContext = client.getSSLContext(providerUri, context, "jndi", "jboss"); } catch (GeneralSecurityException e) { final CommunicationException e2 = new CommunicationException(e.toString());
final SSLContext sslContext; try { sslContext = client.getSSLContext(location, authenticationContext, "jta", "jboss"); } catch (GeneralSecurityException e) { throw new IllegalArgumentException(e);
/** * Get a possibly shared, possibly existing connection to the destination. The authentication and SSL configuration is selected from * the given context with the given abstract type (if specified). * * @param destination the destination URI (must not be {@code null}) * @param abstractType the abstract type of the connection (may be {@code null}) * @param abstractTypeAuthority the authority name of the abstract type of the connection (may be {@code null}) * @param context the authentication context to use (must not be {@code null}) * @return the future connection identity (not {@code null}) */ default IoFuture<ConnectionPeerIdentity> getConnectedIdentity(URI destination, String abstractType, String abstractTypeAuthority, AuthenticationContext context) { Assert.checkNotNullParam("destination", destination); Assert.checkNotNullParam("context", context); final AuthenticationContextConfigurationClient client = AUTH_CONFIGURATION_CLIENT; final SSLContext sslContext; try { sslContext = client.getSSLContext(destination, context); } catch (GeneralSecurityException e) { return new FailedIoFuture<>(Messages.conn.failedToConfigureSslContext(e)); } final AuthenticationConfiguration authenticationConfiguration = client.getAuthenticationConfiguration(destination, context, -1, abstractType, abstractTypeAuthority); return getConnectedIdentity(destination, sslContext, authenticationConfiguration); }
/** * Get a possibly shared, possibly existing connection to the destination, if the connection was already established. * The authentication and SSL configuration is specified directly. * <p> * If no existing connection was found, {@code null} is returned. If a non-{@code null} {@code IoFuture} is * returned, it may represent a complete connection, a failed attempt, or an in-progress attempt. * * @param destination the destination URI (must not be {@code null}) * @param abstractType the abstract type of the connection (may be {@code null}) * @param abstractTypeAuthority the authority name of the abstract type of the connection (may be {@code null}) * @param context the authentication context to use (must not be {@code null}) * @return the existing connection, or {@code null} if no connection currently exists */ default IoFuture<ConnectionPeerIdentity> getConnectedIdentityIfExists(URI destination, String abstractType, String abstractTypeAuthority, AuthenticationContext context) { Assert.checkNotNullParam("destination", destination); Assert.checkNotNullParam("context", context); final AuthenticationContextConfigurationClient client = AUTH_CONFIGURATION_CLIENT; final SSLContext sslContext; try { sslContext = client.getSSLContext(destination, context); } catch (GeneralSecurityException e) { return new FailedIoFuture<>(Messages.conn.failedToConfigureSslContext(e)); } final AuthenticationConfiguration authenticationConfiguration = client.getAuthenticationConfiguration(destination, context, -1, abstractType, abstractTypeAuthority); return getConnectedIdentityIfExists(destination, sslContext, authenticationConfiguration); }
final SSLContext sslContext; try { sslContext = client.getSSLContext(providerUri, context, "jndi", "jboss"); } catch (GeneralSecurityException e) { final CommunicationException e2 = new CommunicationException(e.toString());
if (sslContext == null) { try { sslContext = CLIENT.getSSLContext(destinationUri, context); } catch (GeneralSecurityException e) { throw EjbLogger.ROOT_LOGGER.failedToObtainSSLContext(e);
final SSLContext sslContext; try { sslContext = client.getSSLContext(uri, context, "jndi", "jboss"); } catch (GeneralSecurityException e) {
final int defaultPort = uri.getScheme().equals("https") ? 443 : 80; final AuthenticationConfiguration authenticationConfiguration = client.getAuthenticationConfiguration(uri, context, defaultPort, "jndi", "jboss"); final SSLContext sslContext = client.getSSLContext(uri, context, "jndi", "jboss"); WildflyHttpContext current = WildflyHttpContext.getCurrent(); HttpTargetContext targetContext = current.getTargetContext(uri);
final int defaultPort = uri.getScheme().equals("https") ? 443 : 80; final AuthenticationConfiguration authenticationConfiguration = client.getAuthenticationConfiguration(uri, context, defaultPort, "jndi", "jboss"); final SSLContext sslContext = client.getSSLContext(uri, context, "jndi", "jboss"); targetContext.sendRequest(request, sslContext, authenticationConfiguration, (output -> { OutputStream data = output;
public IoFuture<Connection> connect(final URI destination, final InetSocketAddress bindAddress, final OptionMap connectOptions, final AuthenticationContext authenticationContext) { final AuthenticationContextConfigurationClient client = AUTH_CONFIGURATION_CLIENT; final AuthenticationConfiguration configuration = client.getAuthenticationConfiguration(destination, authenticationContext, - 1, null, null); final SSLContext sslContext; try { sslContext = client.getSSLContext(destination, authenticationContext, null, null); } catch (GeneralSecurityException e) { return new FailedIoFuture<>(Messages.conn.failedToConfigureSslContext(e)); } return connect(destination, bindAddress, connectOptions, configuration, sslContext); }