Source:
<code>public AuthenticationConfiguration getAuthenticationConfiguration(URI uri, AuthenticationContext authenticationContext, int protocolDefaultPort, String abstractType, String abstractTypeAuthority) { Assert.checkNotNullParam("uri", uri); Assert.checkNotNullParam("authenticationContext", authenticationContext); final RuleNode<AuthenticationConfiguration> node = authenticationContext.authRuleMatching(uri, abstractType, abstractTypeAuthority); AuthenticationConfiguration configuration = node != null ? node.getConfiguration() : AuthenticationConfiguration.empty(); final String uriHost = uri.getHost(); if (uriHost != null && configuration.setHost == null) { configuration = configuration.useHost(uriHost); } int port = uri.getPort(); if (port == -1) port = protocolDefaultPort; if (port != -1 && configuration.setPort == -1) { configuration = configuration.usePort(port); } final String userInfo = uri.getUserInfo(); if (userInfo != null && configuration.getPrincipal() == AnonymousPrincipal.getInstance()) { configuration = configuration.useName(userInfo); } final SecurityDomain forwardSecurityDomain = configuration.forwardSecurityDomain; if (forwardSecurityDomain != null) { final SecurityIdentity securityIdentity = forwardSecurityDomain.getCurrentSecurityIdentity(); final IdentityCredentials privateCredentials = securityIdentity.getPrivateCredentials(); final IdentityCredentials publicCredentials = securityIdentity.getPublicCredentials(); <START> configuration = configuration.useForwardedIdentity(securityIdentity.getPrincipal() == AnonymousPrincipal.getInstance() ? forwardSecurityDomain : null).usePrincipal(securityIdentity.getPrincipal()).useCredentials(publicCredentials.with(privateCredentials)); <END> } final AccessControlContext capturedContext = configuration.getCapturedContext(); if (capturedContext == null) { configuration = configuration.withCapturedAccessControlContext(); } log.tracef("getAuthenticationConfiguration uri=%s, protocolDefaultPort=%d, abstractType=%s, abstractTypeAuthority=%s, MatchRule=[%s], AuthenticationConfiguration=[%s]", uri, protocolDefaultPort, abstractType, abstractTypeAuthority, node != null ? node.rule : null, configuration); return configuration; }</code><technical_language>point of capturing is identity sticks configuration if configuration moves threads. stable point of capture. code in RemoteOutboundConnectionService is is incorrect; I original code is correct. is correct RemoteOutboundConnectionService for propagating identity; work. RemoteOutboundConnectionService is purely a legacy construct. Outbound authentication configured in Elytron subsystem</technical_language>

Target:
public AuthenticationConfiguration getAuthenticationConfiguration(URI uri, AuthenticationContext authenticationContext, int protocolDefaultPort, String abstractType, String abstractTypeAuthority) { Assert.checkNotNullParam("uri", uri); Assert.checkNotNullParam("authenticationContext", authenticationContext); final RuleNode<AuthenticationConfiguration> node = authenticationContext.authRuleMatching(uri, abstractType, abstractTypeAuthority); AuthenticationConfiguration configuration = node != null ? node.getConfiguration() : AuthenticationConfiguration.empty(); final String uriHost = uri.getHost(); if (uriHost != null && configuration.setHost == null) { configuration = configuration.useHost(uriHost); } int port = uri.getPort(); if (port == -1) port = protocolDefaultPort; if (port != -1 && configuration.setPort == -1) { configuration = configuration.usePort(port); } final String userInfo = uri.getUserInfo(); if (userInfo != null && configuration.getPrincipal() == AnonymousPrincipal.getInstance()) { configuration = configuration.useName(userInfo); } final SecurityDomain forwardSecurityDomain = configuration.forwardSecurityDomain; if (forwardSecurityDomain != null) { final SecurityIdentity securityIdentity = forwardSecurityDomain.getCurrentSecurityIdentity(); final IdentityCredentials privateCredentials = securityIdentity.getPrivateCredentials(); final IdentityCredentials publicCredentials = securityIdentity.getPublicCredentials(); configuration = configuration.useForwardedIdentity(null).usePrincipal(securityIdentity.getPrincipal()).useCredentials(publicCredentials.with(privateCredentials)); } final AccessControlContext capturedContext = configuration.getCapturedContext(); if (capturedContext == null) { configuration = configuration.withCapturedAccessControlContext(); } log.tracef("getAuthenticationConfiguration uri=%s, protocolDefaultPort=%d, abstractType=%s, abstractTypeAuthority=%s, MatchRule=[%s], AuthenticationConfiguration=[%s]", uri, protocolDefaultPort, abstractType, abstractTypeAuthority, node != null ? node.rule : null, configuration); return configuration; }