I am currently gathering together some information regarding how the JCA subsystem handles the requirement of populating a Subject for propagation into a resource adapter, however there is a general question about what is attempting to be achieved here.

Once an EJB is secured using WildFly Elytron the associated identity is not accessed as a Subject instead it is accessed a SecurityIdentity the current SecurityIdentity can always be retrieved by calling the current SecurityDomain: -

http://wildfly-security.github.io/wildfly-elytron/1.3.x/api-javadoc/org/wildfly/security/auth/server/SecurityDomain.html#getCurrent--
http://wildfly-security.github.io/wildfly-elytron/1.3.x/api-javadoc/org/wildfly/security/auth/server/SecurityDomain.html#getCurrentSecurityIdentity--

The SecurityIdentity has some similarity with the Subject in that amongst other things it also contains a collection of public credentials and a collection of private credentials: -

http://wildfly-security.github.io/wildfly-elytron/1.3.x/api-javadoc/org/wildfly/security/auth/server/SecurityIdentity.html#getPublicCredentials--
http://wildfly-security.github.io/wildfly-elytron/1.3.x/api-javadoc/org/wildfly/security/auth/server/SecurityIdentity.html#getPrivateCredentials--

So I think the very first question is has the SecurityIdentity been correctly populated with any delegated credentials?  If not that is going to be a pre-requisite for any follow on steps regardless.

Then secondly what is it that is making use of this identity?  Why can't it be ported to make use of the Elytron authentication client APIs which amongst other things provide support for delegation from the current identity.

If we need to we can look at a conversion to a Subject but we are only doing that where it is really required.

Regards,
Darran Lofthouse.


On Wed, 30 May 2018 at 10:27 Alessio Soldano <asoldano@redhat.com> wrote:
As suggested by Darran, I'm forwarding the message below to the list on behalf of Jim.
The classes Jim is referring to are at https://github.com/wildfly/wildfly/tree/master/webservices/server-integration/src/main/java/org/jboss/as/webservices/security


---------- Forwarded message ----------
From: Jim Ma <ema@redhat.com>
Date: Wed, May 30, 2018 at 9:03 AM
Subject: Set an authorized identity to EltyronSecurity Context
To: Darran Lofthouse <darran.lofthouse@redhat.com>
Cc: Alessio Soldano <asoldano@redhat.com>


Hi Darran,

We are helping look at a customer issue which requires propagate the authenticated subject from webservice subsystem to

ejb subystem. With old security domain , we can do this with creating a subject :

    @Override
    public void pushSubjectContext(final Subject subject, final Principal principal, final Object credential) {
        AccessController.doPrivileged(new PrivilegedAction<Void>() {

            public Void run() {
                SecurityContext securityContext = SecurityContextAssociation.getSecurityContext();
                if (securityContext == null) {
                    securityContext = createSecurityContext(getSecurityDomain());
setSecurityContextOnAssociation(securityContext);
                }
securityContext.getUtil().createSubjectInfo(principal, credential, subject);
                return null;
            }
        });
    }


After Elytron,  what is the equivalent thing to do this  then ejb can retrieve this security without check this twice ?

Thanks,

Jim




--

Alessio Soldano

Associate Manager

Red Hat