/** * Get the authentication configuration which matches the given URI, or {@link AuthenticationConfiguration#EMPTY} 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 configuration */ public AuthenticationConfiguration getAuthenticationConfiguration(URI uri, AuthenticationContext authenticationContext) { return getAuthenticationConfiguration(uri, authenticationContext, -1); }
/** * Get the authentication configuration which matches the given URI, or {@link AuthenticationConfiguration#EMPTY} if there is none, setting * a default protocol port. * * @param uri the URI to match (must not be {@code null}) * @param authenticationContext the authentication context to examine (must not be {@code null}) * @param protocolDefaultPort the protocol-default port * @return the matching configuration */ public AuthenticationConfiguration getAuthenticationConfiguration(URI uri, AuthenticationContext authenticationContext, int protocolDefaultPort) { return getAuthenticationConfiguration(uri, authenticationContext, protocolDefaultPort, null, null); }
void init() { if (eagerlyAcquireAffinity) { acquireAffinitiy(AUTH_CONTEXT_CLIENT.getAuthenticationConfiguration(uri, AuthenticationContext.captureCurrent())); } }
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); } }
/** * Creates a new {@link OAuth2CredentialSource} instance. * * @return a OAuth2 credential source */ public OAuth2CredentialSource build() { if (authenticationHandler == null) { authenticationHandler = parameters -> { AuthenticationContext context = AuthenticationContext.captureCurrent(); AuthenticationContextConfigurationClient client = AccessController.doPrivileged(AuthenticationContextConfigurationClient.ACTION); AuthenticationConfiguration configuration = client.getAuthenticationConfiguration(URI.create(tokenEndpointUrl.toString()), context); CallbackHandler handler = client.getCallbackHandler(configuration); NameCallback nameCallback = new NameCallback("Client ID"); PasswordCallback password1 = new PasswordCallback("Client Secret", false); try { handler.handle(new Callback[]{nameCallback, password1}); } catch (Exception ignore) { } String userName = nameCallback.getName(); char[] password = password1.getPassword(); configureClientCredentialsParameters(parameters, userName, password); }; } return new OAuth2CredentialSource(tokenEndpointUrl, authenticationHandler.andThen(parameters -> { if (!parameters.containsKey("client_id") || !parameters.containsKey("client_secret")) { throw saslOAuth2.oauth2ClientCredentialsNotProvided(); } }), scopes, sslContextSupplier, hostnameVerifierSupplier); }
final AuthenticationConfiguration configuration = AUTH_CONFIG_CLIENT.getAuthenticationConfiguration(uri, authContext, -1, null, null);
AuthenticationContext context = AuthenticationContext.captureCurrent(); AuthenticationContextConfigurationClient client = AccessController.doPrivileged(AuthenticationContextConfigurationClient.ACTION); AuthenticationConfiguration configuration = client.getAuthenticationConfiguration(URI.create(tokenEndpointUrl.toString()), context); CallbackHandler handler = client.getCallbackHandler(configuration);
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); }
final AuthenticationConfiguration configuration = AUTH_CONFIG_CLIENT.getAuthenticationConfiguration(this.targetURI, authenticationContext); final CallbackHandler handler = AUTH_CONFIG_CLIENT.getCallbackHandler(configuration); final NameCallback nameCallback = new NameCallback("Username: ");
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); }
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); }
AuthenticationContextConfigurationClient client = CLIENT; final int defaultPort = providerUri.getScheme().equals("https") ? 443 : 80; final AuthenticationConfiguration authenticationConfiguration = client.getAuthenticationConfiguration(providerUri, context, defaultPort, "jndi", "jboss"); final SSLContext sslContext; try {
final AuthenticationConfiguration authenticationConfiguration = client.getAuthenticationConfiguration(location, authenticationContext, - 1, "jta", "jboss"); final SSLContext sslContext; try {
/** * 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 OptionMap connectOptions = connectionSpec.getConnectOptions(); authenticationConfiguration = RemotingOptions.mergeOptionsIntoAuthenticationConfiguration(connectOptions, authenticationConfiguration); AuthenticationConfiguration ejbConfiguration = CLIENT.getAuthenticationConfiguration(destinationUri, context, - 1, "ejb", "jboss"); AuthenticationConfiguration jtaConfiguration = CLIENT.getAuthenticationConfiguration(destinationUri, context, - 1, "jta", "jboss"); if (sslContext == null) { try {
final AuthenticationContextConfigurationClient client = CLIENT; final int defaultPort = uri.getScheme().equals("https") ? 443 : 80; final AuthenticationConfiguration authenticationConfiguration = client.getAuthenticationConfiguration(uri, context, defaultPort, "jndi", "jboss"); final SSLContext sslContext; try {
final AuthenticationContextConfigurationClient client = CLIENT; 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();