Source:
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(securityIdentity.getPrincipal() == AnonymousPrincipal.getInstance() ? forwardSecurityDomain : 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; }

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; }