connector/src/main/java/org/jboss/as/connector/security/ElytronSubjectFactory.java
private Subject createSubject(final AuthenticationContext authenticationContext) {
        final AuthenticationConfiguration configuration = AUTH_CONFIG_CLIENT.getAuthenticationConfiguration(this.targetURI, authenticationContext);
        final CallbackHandler handler = AUTH_CONFIG_CLIENT.getCallbackHandler(configuration);
        final NameCallback nameCallback = new NameCallback("Username: ");
        final PasswordCallback passwordCallback = new PasswordCallback("Password: ", false);
        final CredentialCallback credentialCallback = new CredentialCallback(GSSKerberosCredential.class);
        try {
            handler.handle(new Callback[]{nameCallback, passwordCallback, credentialCallback});
            Subject subject = new Subject();
            // if a GSSKerberosCredential was found, add the enclosed GSSCredential and KerberosTicket to the private set in the Subject.
            if (credentialCallback.getCredential() != null) {
                GSSKerberosCredential kerberosCredential = GSSKerberosCredential.class.cast(credentialCallback.getCredential());
                this.addPrivateCredential(subject, kerberosCredential.getKerberosTicket());
                this.addPrivateCredential(subject, kerberosCredential.getGssCredential());
                // use the GSSName to build a kerberos principal and set it in the Subject.
                GSSName gssName = kerberosCredential.getGssCredential().getName();
                subject.getPrincipals().add(new KerberosPrincipal(gssName.toString()));
            }
            // use the name from the callback, if available, to build a principal and set it in the Subject.
            if (nameCallback.getName() != null) {
                subject.getPrincipals().add(new NamePrincipal(nameCallback.getName()));
            }
            // use the password from the callback, if available, to build a credential and set it as a private credential in the Subject.
            if (passwordCallback.getPassword() != null) {
                this.addPrivateCredential(subject, new PasswordCredential(nameCallback.getName(), passwordCallback.getPassword()));
            }
            return subject;
        } catch(Exception e) {
            throw new SecurityException(e);
        }
    }
private Subject createSubject(final AuthenticationContext authenticationContext) {
        final AuthenticationConfiguration configuration = AUTH_CONFIG_CLIENT.getAuthenticationConfiguration(this.targetURI, authenticationContext);
        final CallbackHandler handler = AUTH_CONFIG_CLIENT.getCallbackHandler(configuration);
        final NameCallback nameCallback = new NameCallback("Username: ");
        final PasswordCallback passwordCallback = new PasswordCallback("Password: ", false);
        final CredentialCallback credentialCallback = new CredentialCallback(GSSKerberosCredential.class);
        try {
            handler.handle(new Callback[]{nameCallback, passwordCallback, credentialCallback});
            Subject subject = new Subject();
            // if a GSSKerberosCredential was found, add the enclosed GSSCredential and KerberosTicket to the private set in the Subject.
            if (credentialCallback.getCredential() != null) {
                GSSKerberosCredential kerberosCredential = GSSKerberosCredential.class.cast(credentialCallback.getCredential());
                this.addPrivateCredential(subject, kerberosCredential.getKerberosTicket());
                this.addPrivateCredential(subject, kerberosCredential.getGssCredential());
                // use the GSSName to build a kerberos principal and set it in the Subject.
                GSSName gssName = kerberosCredential.getGssCredential().getName();
                subject.getPrincipals().add(new KerberosPrincipal(gssName.toString()));
            }
            // use the name from the callback, if available, to build a principal and set it in the Subject.
            if (nameCallback.getName() != null) {
                subject.getPrincipals().add(new NamePrincipal(nameCallback.getName()));
            }
            // use the password from the callback, if available, to build a credential and set it as a private credential in the Subject.
            if (passwordCallback.getPassword() != null) {
                this.addPrivateCredential(subject, new PasswordCredential(nameCallback.getName(), passwordCallback.getPassword()));
            }
            return subject;
        } catch(Exception e) {
            throw new SecurityException(e);
        }
    }
Create a {@link Subject} with the principal and password credential obtained from the authentication configuration
that matches the target {@link URI}.

@param authenticationContext the {@link AuthenticationContext} used to select a configuration that matches the
target {@link URI}.
@return the constructed {@link Subject}. It contains a single principal and a {@link PasswordCredential}.