<div dir="ltr">Btw. I think some aspects of this thread seem a little off-topic or more specific to the JSR 375 list instead (or at least it would be good to CC that one for detailed java.security discussions rather than if a generic type works or not)<div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><p style="margin:0px;border-collapse:collapse"><font face="arial, helvetica, sans-serif" size="1"><span lang="EN-US">Werner</span></font></p><span lang="EN-GB"><div style="font-family:arial,helvetica,sans-serif"><br></div></span></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>
<br><div class="gmail_quote">On Wed, Apr 26, 2017 at 6:11 PM,  <span dir="ltr">&lt;<a href="mailto:cdi-dev-request@lists.jboss.org" target="_blank">cdi-dev-request@lists.jboss.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Send cdi-dev mailing list submissions to<br>
        <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
        <a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/<wbr>mailman/listinfo/cdi-dev</a><br>
or, via email, send a message with subject or body &#39;help&#39; to<br>
        <a href="mailto:cdi-dev-request@lists.jboss.org">cdi-dev-request@lists.jboss.<wbr>org</a><br>
<br>
You can reach the person managing the list at<br>
        <a href="mailto:cdi-dev-owner@lists.jboss.org">cdi-dev-owner@lists.jboss.org</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than &quot;Re: Contents of cdi-dev digest...&quot;<br>
<br>
<br>
Today&#39;s Topics:<br>
<br>
   1. Re: Types of Principal object (arjan tijms)<br>
   2. Re: Types of Principal object (arjan tijms)<br>
   3. Re: Types of Principal object (Romain Manni-Bucau)<br>
<br>
<br>
------------------------------<wbr>------------------------------<wbr>----------<br>
<br>
Message: 1<br>
Date: Wed, 26 Apr 2017 18:00:40 +0200<br>
From: arjan tijms &lt;<a href="mailto:arjan.tijms@gmail.com">arjan.tijms@gmail.com</a>&gt;<br>
Subject: Re: [cdi-dev] Types of Principal object<br>
To: Matej Novotny &lt;<a href="mailto:manovotn@redhat.com">manovotn@redhat.com</a>&gt;<br>
Cc: cdi-dev &lt;<a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a>&gt;<br>
Message-ID:<br>
        &lt;CAE=-AhBp8cLUxWOpnT=<a href="mailto:oyp-h%2Bf2uYDgUvwJDfSkzYjRqha5HHA@mail.gmail.com">oyp-h+<wbr>f2uYDgUvwJDfSkzYjRqha5HHA@<wbr>mail.gmail.com</a>&gt;<br>
Content-Type: text/plain; charset=&quot;utf-8&quot;<br>
<br>
Hi,<br>
<br>
On Wed, Apr 26, 2017 at 4:48 PM, Matej Novotny &lt;<a href="mailto:manovotn@redhat.com">manovotn@redhat.com</a>&gt; wrote:<br>
<br>
&gt; And spec requires all built-in beans to be decorable - e.g. you need them<br>
&gt; to be proxyable (although the added value of principal decorator is ...eh,<br>
&gt; disputable at best?).<br>
&gt;<br>
<br>
That would be kinda disputable indeed :O<br>
<br>
<br>
&gt; Therefore, it is safer/viable to create a proxyable wrapper object which<br>
&gt; implements Principal only and delegetas calls (that&#39;s what Weld does).<br>
&gt;<br>
<br>
As i mentioned, the proxy has to be there as just injecting a non-proxy<br>
Principal would not work correctly. If a logout call is done, the injected<br>
Principal would still be the principal that it was before, let alone what<br>
happens if the Principal is inject in application scoped beans...<br>
<br>
Kind regards,<br>
Arjan Tijms<br>
<br>
<br>
<br>
&gt;<br>
&gt; Otherwise I agree it could be nice to ahve a way to cast the object as the<br>
&gt; pure Principal interface doesn&#39;t help much.<br>
&gt;<br>
&gt; Matej<br>
&gt;<br>
&gt; ----- Original Message -----<br>
&gt; &gt; From: &quot;John Ament&quot; &lt;<a href="mailto:john.ament@spartasystems.com">john.ament@spartasystems.com</a>&gt;<br>
&gt; &gt; To: &quot;cdi-dev&quot; &lt;<a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a>&gt;<br>
&gt; &gt; Sent: Wednesday, April 26, 2017 3:54:57 PM<br>
&gt; &gt; Subject: [cdi-dev] Types of Principal object<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; Hey guys<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; I raised a bug against the Weld guys, but think its worth an EG<br>
&gt; discussion.<br>
&gt; &gt; When a Principal object is injected, the only type it has is Principal.<br>
&gt; It<br>
&gt; &gt; does not retain the actual type used at runtime. This threw me off on<br>
&gt; some<br>
&gt; &gt; Keycloak integration I&#39;m working on (in $dayjob). So I was wondering, is<br>
&gt; &gt; this expected from our POV or should it retain the types of the actual<br>
&gt; &gt; runtime instance?<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; John<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; NOTICE: This e-mail message and any attachments may contain confidential,<br>
&gt; &gt; proprietary, and/or privileged information which should be treated<br>
&gt; &gt; accordingly. If you are not the intended recipient, please notify the<br>
&gt; sender<br>
&gt; &gt; immediately by return e-mail, delete this message, and destroy all<br>
&gt; physical<br>
&gt; &gt; and electronic copies. Thank you.<br>
&gt; &gt;<br>
&gt; &gt; ______________________________<wbr>_________________<br>
&gt; &gt; cdi-dev mailing list<br>
&gt; &gt; <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
&gt; &gt; <a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/<wbr>mailman/listinfo/cdi-dev</a><br>
&gt; &gt;<br>
&gt; &gt; Note that for all code provided on this list, the provider licenses the<br>
&gt; code<br>
&gt; &gt; under the Apache License, Version 2<br>
&gt; &gt; (<a href="http://www.apache.org/licenses/LICENSE-2.0.html" rel="noreferrer" target="_blank">http://www.apache.org/<wbr>licenses/LICENSE-2.0.html</a>). For all other ideas<br>
&gt; &gt; provided on this list, the provider waives all patent and other<br>
&gt; intellectual<br>
&gt; &gt; property rights inherent in such information.<br>
&gt; ______________________________<wbr>_________________<br>
&gt; cdi-dev mailing list<br>
&gt; <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/<wbr>mailman/listinfo/cdi-dev</a><br>
&gt;<br>
&gt; Note that for all code provided on this list, the provider licenses the<br>
&gt; code under the Apache License, Version 2 (<a href="http://www.apache.org/" rel="noreferrer" target="_blank">http://www.apache.org/</a><br>
&gt; licenses/LICENSE-2.0.html). For all other ideas provided on this list,<br>
&gt; the provider waives all patent and other intellectual property rights<br>
&gt; inherent in such information.<br>
&gt;<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <a href="http://lists.jboss.org/pipermail/cdi-dev/attachments/20170426/1b8d735a/attachment-0001.html" rel="noreferrer" target="_blank">http://lists.jboss.org/<wbr>pipermail/cdi-dev/attachments/<wbr>20170426/1b8d735a/attachment-<wbr>0001.html</a><br>
<br>
------------------------------<br>
<br>
Message: 2<br>
Date: Wed, 26 Apr 2017 18:07:52 +0200<br>
From: arjan tijms &lt;<a href="mailto:arjan.tijms@gmail.com">arjan.tijms@gmail.com</a>&gt;<br>
Subject: Re: [cdi-dev] Types of Principal object<br>
To: Romain Manni-Bucau &lt;<a href="mailto:rmannibucau@gmail.com">rmannibucau@gmail.com</a>&gt;<br>
Cc: cdi-dev &lt;<a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a>&gt;<br>
Message-ID:<br>
        &lt;CAE=-<a href="mailto:AhC2YBs0biFaRPpxrpiXy4WTaKU_Xsm%2BnxSCk3mUkhZYQg@mail.gmail.com">AhC2YBs0biFaRPpxrpiXy4WT<wbr>aKU_Xsm+nxSCk3mUkhZYQg@mail.<wbr>gmail.com</a>&gt;<br>
Content-Type: text/plain; charset=&quot;utf-8&quot;<br>
<br>
Hi,<br>
<br>
On Wed, Apr 26, 2017 at 5:41 PM, Romain Manni-Bucau &lt;<a href="mailto:rmannibucau@gmail.com">rmannibucau@gmail.com</a>&gt;<br>
wrote:<br>
<br>
&gt; that&#39;s why security API needs a more typed API acting as an handler and<br>
&gt; not as a contextual instance, it would allow to unwrap the actual instance<br>
&gt; (like most specs do)<br>
&gt;<br>
<br>
I think that would require a new Principal type, which can be done, but<br>
who&#39;s going to put time into it to discuss it, spec it, implement it, etc?<br>
<br>
Also, the difference with the current situation is not that much then.<br>
<br>
Extended Principal:<br>
<br>
<br>
@Inject CallerPrincipal callerPrincipal;<br>
<br>
...<br>
<br>
MyPrincipal myPrincipal = callerPrincipal.unwrap();<br>
<br>
<br>
vs<br>
<br>
<br>
Security context:<br>
<br>
@Inject SecurityContext securityContext;<br>
<br>
...<br>
<br>
MyPrincipal myPrincipal = securityContext.<wbr>getCallerPrincipal();<br>
<br>
Spot the differences ;)<br>
<br>
<br>
<br>
&gt; In other words either Principal is removed from CDI spec<br>
&gt;<br>
<br>
I think this should be done anyway. The build-in bean for Principal would<br>
be more at home with the Security API spec. I would be happy to take it in<br>
;)<br>
<br>
(likewise, the build-in bean for HttpServletRequest etc should be with the<br>
Servlet spec)<br>
<br>
<br>
<br>
&gt; or it stays but it should be extended to be made usable IMHO.<br>
&gt;<br>
<br>
What CDI could provide and which has been discussed before, is a method to<br>
get the real bean from a proxy. E.g.<br>
<br>
@Inject CallerPrincipal callerPrincipal;<br>
@Inject BeanManager beanManager;<br>
<br>
...<br>
<br>
MyPrincipal myPrincipal = beanManager.unwrap(<wbr>callerPrincipal);<br>
<br>
Kind regards,<br>
Arjan Tijms<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
&gt;<br>
&gt;<br>
&gt; Romain Manni-Bucau<br>
&gt; @rmannibucau &lt;<a href="https://twitter.com/rmannibucau" rel="noreferrer" target="_blank">https://twitter.com/<wbr>rmannibucau</a>&gt; |  Blog<br>
&gt; &lt;<a href="https://blog-rmannibucau.rhcloud.com" rel="noreferrer" target="_blank">https://blog-rmannibucau.<wbr>rhcloud.com</a>&gt; | Old Blog<br>
&gt; &lt;<a href="http://rmannibucau.wordpress.com" rel="noreferrer" target="_blank">http://rmannibucau.wordpress.<wbr>com</a>&gt; | Github<br>
&gt; &lt;<a href="https://github.com/rmannibucau" rel="noreferrer" target="_blank">https://github.com/<wbr>rmannibucau</a>&gt; | LinkedIn<br>
&gt; &lt;<a href="https://www.linkedin.com/in/rmannibucau" rel="noreferrer" target="_blank">https://www.linkedin.com/in/<wbr>rmannibucau</a>&gt; | JavaEE Factory<br>
&gt; &lt;<a href="https://javaeefactory-rmannibucau.rhcloud.com" rel="noreferrer" target="_blank">https://javaeefactory-<wbr>rmannibucau.rhcloud.com</a>&gt;<br>
&gt;<br>
&gt; 2017-04-26 17:11 GMT+02:00 arjan tijms &lt;<a href="mailto:arjan.tijms@gmail.com">arjan.tijms@gmail.com</a>&gt;:<br>
&gt;<br>
&gt;&gt; Hi,<br>
&gt;&gt;<br>
&gt;&gt; We discussed this very issue in the Security API EG as well. In the<br>
&gt;&gt; Security API the actual type *MUST* be retained as per the spec definition.<br>
&gt;&gt;<br>
&gt;&gt; The problem in CDI, at least in Weld, is that a proxy is injected. This<br>
&gt;&gt; happens via the build-in bean &quot;PrincipalBean extends AbstractEEBean&quot;, where<br>
&gt;&gt; AbstractEEBean does:<br>
&gt;&gt;<br>
&gt;&gt; public abstract class AbstractEEBean&lt;T&gt; extends<br>
&gt;&gt; AbstractStaticallyDecorableBui<wbr>ltInBean&lt;T&gt; {<br>
&gt;&gt;<br>
&gt;&gt;     private final T proxy;<br>
&gt;&gt;<br>
&gt;&gt;     protected AbstractEEBean(Class&lt;T&gt; type, Callable&lt;T&gt; callable,<br>
&gt;&gt; BeanManagerImpl beanManager) {<br>
&gt;&gt;         super(beanManager, type);<br>
&gt;&gt;         this.proxy = new ProxyFactory&lt;T&gt;(beanManager.<wbr>getContextId(),<br>
&gt;&gt; type, getTypes(), this).create(new EnterpriseTargetBeanInstance(<wbr>type,<br>
&gt;&gt; new CallableMethodHandler(<wbr>callable)));<br>
&gt;&gt;     }<br>
&gt;&gt;     // ...<br>
&gt;&gt; }<br>
&gt;&gt;<br>
&gt;&gt; I&#39;m not even sure if it&#39;s possible to downcast the proxy to the required<br>
&gt;&gt; runtime type.<br>
&gt;&gt;<br>
&gt;&gt; Also note that the Principal can change during the request. The simplest<br>
&gt;&gt; case is when during an http request HttpServletRequest#logout is called.<br>
&gt;&gt;<br>
&gt;&gt; Kind regards,<br>
&gt;&gt; Arjan Tijms<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; On Wed, Apr 26, 2017 at 3:54 PM, John Ament &lt;<a href="mailto:john.ament@spartasystems.com">john.ament@spartasystems.com</a><br>
&gt;&gt; &gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt;&gt; Hey guys<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; I raised a bug against the Weld guys, but think its worth an EG<br>
&gt;&gt;&gt; discussion.  When a Principal object is injected, the only type it has is<br>
&gt;&gt;&gt; Principal.  It does not retain the actual type used at runtime.  This threw<br>
&gt;&gt;&gt; me off on some Keycloak integration I&#39;m working on (in $dayjob).  So I was<br>
&gt;&gt;&gt; wondering, is this expected from our POV or should it retain the types of<br>
&gt;&gt;&gt; the actual runtime instance?<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; John<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; ------------------------------<br>
&gt;&gt;&gt; NOTICE: This e-mail message and any attachments may contain<br>
&gt;&gt;&gt; confidential, proprietary, and/or privileged information which should be<br>
&gt;&gt;&gt; treated accordingly. If you are not the intended recipient, please notify<br>
&gt;&gt;&gt; the sender immediately by return e-mail, delete this message, and destroy<br>
&gt;&gt;&gt; all physical and electronic copies. Thank you.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; ______________________________<wbr>_________________<br>
&gt;&gt;&gt; cdi-dev mailing list<br>
&gt;&gt;&gt; <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
&gt;&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/<wbr>mailman/listinfo/cdi-dev</a><br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Note that for all code provided on this list, the provider licenses the<br>
&gt;&gt;&gt; code under the Apache License, Version 2 (<a href="http://www.apache.org/license" rel="noreferrer" target="_blank">http://www.apache.org/license</a><br>
&gt;&gt;&gt; s/LICENSE-2.0.html). For all other ideas provided on this list, the<br>
&gt;&gt;&gt; provider waives all patent and other intellectual property rights inherent<br>
&gt;&gt;&gt; in such information.<br>
&gt;&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; ______________________________<wbr>_________________<br>
&gt;&gt; cdi-dev mailing list<br>
&gt;&gt; <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/<wbr>mailman/listinfo/cdi-dev</a><br>
&gt;&gt;<br>
&gt;&gt; Note that for all code provided on this list, the provider licenses the<br>
&gt;&gt; code under the Apache License, Version 2 (<a href="http://www.apache.org/license" rel="noreferrer" target="_blank">http://www.apache.org/license</a><br>
&gt;&gt; s/LICENSE-2.0.html). For all other ideas provided on this list, the<br>
&gt;&gt; provider waives all patent and other intellectual property rights inherent<br>
&gt;&gt; in such information.<br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <a href="http://lists.jboss.org/pipermail/cdi-dev/attachments/20170426/9cd63650/attachment-0001.html" rel="noreferrer" target="_blank">http://lists.jboss.org/<wbr>pipermail/cdi-dev/attachments/<wbr>20170426/9cd63650/attachment-<wbr>0001.html</a><br>
<br>
------------------------------<br>
<br>
Message: 3<br>
Date: Wed, 26 Apr 2017 18:10:10 +0200<br>
From: Romain Manni-Bucau &lt;<a href="mailto:rmannibucau@gmail.com">rmannibucau@gmail.com</a>&gt;<br>
Subject: Re: [cdi-dev] Types of Principal object<br>
To: arjan tijms &lt;<a href="mailto:arjan.tijms@gmail.com">arjan.tijms@gmail.com</a>&gt;<br>
Cc: cdi-dev &lt;<a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a>&gt;<br>
Message-ID:<br>
        &lt;CACLE=<a href="mailto:7MCs1XrpCnNjSXSM92aXW31kKLdb1EnmER7Z6MTkGnFXw@mail.gmail.com">7MCs1XrpCnNjSXSM92aXW31<wbr>kKLdb1EnmER7Z6MTkGnFXw@mail.<wbr>gmail.com</a>&gt;<br>
Content-Type: text/plain; charset=&quot;utf-8&quot;<br>
<br>
2017-04-26 18:07 GMT+02:00 arjan tijms &lt;<a href="mailto:arjan.tijms@gmail.com">arjan.tijms@gmail.com</a>&gt;:<br>
<br>
&gt; Hi,<br>
&gt;<br>
&gt; On Wed, Apr 26, 2017 at 5:41 PM, Romain Manni-Bucau &lt;<a href="mailto:rmannibucau@gmail.com">rmannibucau@gmail.com</a><br>
&gt; &gt; wrote:<br>
&gt;<br>
&gt;&gt; that&#39;s why security API needs a more typed API acting as an handler and<br>
&gt;&gt; not as a contextual instance, it would allow to unwrap the actual instance<br>
&gt;&gt; (like most specs do)<br>
&gt;&gt;<br>
&gt;<br>
&gt; I think that would require a new Principal type, which can be done, but<br>
&gt; who&#39;s going to put time into it to discuss it, spec it, implement it, etc?<br>
&gt;<br>
&gt; Also, the difference with the current situation is not that much then.<br>
&gt;<br>
&gt; Extended Principal:<br>
&gt;<br>
&gt;<br>
&gt; @Inject CallerPrincipal callerPrincipal;<br>
&gt;<br>
&gt; ...<br>
&gt;<br>
&gt; MyPrincipal myPrincipal = callerPrincipal.unwrap();<br>
&gt;<br>
<br>
Was more thinking about:<br>
<br>
MyPrincipal myPrincipal = callerPrincipal.unwrap(<wbr>MyPrincipal.class);<br>
<br>
<br>
&gt;<br>
&gt;<br>
&gt; vs<br>
&gt;<br>
&gt;<br>
&gt; Security context:<br>
&gt;<br>
&gt; @Inject SecurityContext securityContext;<br>
&gt;<br>
&gt; ...<br>
&gt;<br>
&gt; MyPrincipal myPrincipal = securityContext.<wbr>getCallerPrincipal();<br>
&gt;<br>
&gt; Spot the differences ;)<br>
&gt;<br>
<br>
Here you can get a PrincipalFacade which limits MyPrincipal to getName()<br>
only, this is perfectly valid per spec.<br>
<br>
<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;&gt; In other words either Principal is removed from CDI spec<br>
&gt;&gt;<br>
&gt;<br>
&gt; I think this should be done anyway. The build-in bean for Principal would<br>
&gt; be more at home with the Security API spec. I would be happy to take it in<br>
&gt; ;)<br>
&gt;<br>
&gt; (likewise, the build-in bean for HttpServletRequest etc should be with the<br>
&gt; Servlet spec)<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;&gt; or it stays but it should be extended to be made usable IMHO.<br>
&gt;&gt;<br>
&gt;<br>
&gt; What CDI could provide and which has been discussed before, is a method to<br>
&gt; get the real bean from a proxy. E.g.<br>
&gt;<br>
&gt; @Inject CallerPrincipal callerPrincipal;<br>
&gt; @Inject BeanManager beanManager;<br>
&gt;<br>
&gt; ...<br>
&gt;<br>
&gt; MyPrincipal myPrincipal = beanManager.unwrap(<wbr>callerPrincipal);<br>
&gt;<br>
<br>
Well this would assume we can do it for all beans and a lot of cases would<br>
be problematic cause it is just not doable :s...but would help if we find a<br>
compromise for other beans too :)<br>
<br>
<br>
&gt;<br>
&gt; Kind regards,<br>
&gt; Arjan Tijms<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; Romain Manni-Bucau<br>
&gt;&gt; @rmannibucau &lt;<a href="https://twitter.com/rmannibucau" rel="noreferrer" target="_blank">https://twitter.com/<wbr>rmannibucau</a>&gt; |  Blog<br>
&gt;&gt; &lt;<a href="https://blog-rmannibucau.rhcloud.com" rel="noreferrer" target="_blank">https://blog-rmannibucau.<wbr>rhcloud.com</a>&gt; | Old Blog<br>
&gt;&gt; &lt;<a href="http://rmannibucau.wordpress.com" rel="noreferrer" target="_blank">http://rmannibucau.wordpress.<wbr>com</a>&gt; | Github<br>
&gt;&gt; &lt;<a href="https://github.com/rmannibucau" rel="noreferrer" target="_blank">https://github.com/<wbr>rmannibucau</a>&gt; | LinkedIn<br>
&gt;&gt; &lt;<a href="https://www.linkedin.com/in/rmannibucau" rel="noreferrer" target="_blank">https://www.linkedin.com/in/<wbr>rmannibucau</a>&gt; | JavaEE Factory<br>
&gt;&gt; &lt;<a href="https://javaeefactory-rmannibucau.rhcloud.com" rel="noreferrer" target="_blank">https://javaeefactory-<wbr>rmannibucau.rhcloud.com</a>&gt;<br>
&gt;&gt;<br>
&gt;&gt; 2017-04-26 17:11 GMT+02:00 arjan tijms &lt;<a href="mailto:arjan.tijms@gmail.com">arjan.tijms@gmail.com</a>&gt;:<br>
&gt;&gt;<br>
&gt;&gt;&gt; Hi,<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; We discussed this very issue in the Security API EG as well. In the<br>
&gt;&gt;&gt; Security API the actual type *MUST* be retained as per the spec definition.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; The problem in CDI, at least in Weld, is that a proxy is injected. This<br>
&gt;&gt;&gt; happens via the build-in bean &quot;PrincipalBean extends AbstractEEBean&quot;, where<br>
&gt;&gt;&gt; AbstractEEBean does:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; public abstract class AbstractEEBean&lt;T&gt; extends<br>
&gt;&gt;&gt; AbstractStaticallyDecorableBui<wbr>ltInBean&lt;T&gt; {<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;     private final T proxy;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;     protected AbstractEEBean(Class&lt;T&gt; type, Callable&lt;T&gt; callable,<br>
&gt;&gt;&gt; BeanManagerImpl beanManager) {<br>
&gt;&gt;&gt;         super(beanManager, type);<br>
&gt;&gt;&gt;         this.proxy = new ProxyFactory&lt;T&gt;(beanManager.<wbr>getContextId(),<br>
&gt;&gt;&gt; type, getTypes(), this).create(new EnterpriseTargetBeanInstance(<wbr>type,<br>
&gt;&gt;&gt; new CallableMethodHandler(<wbr>callable)));<br>
&gt;&gt;&gt;     }<br>
&gt;&gt;&gt;     // ...<br>
&gt;&gt;&gt; }<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; I&#39;m not even sure if it&#39;s possible to downcast the proxy to the required<br>
&gt;&gt;&gt; runtime type.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Also note that the Principal can change during the request. The simplest<br>
&gt;&gt;&gt; case is when during an http request HttpServletRequest#logout is called.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Kind regards,<br>
&gt;&gt;&gt; Arjan Tijms<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; On Wed, Apr 26, 2017 at 3:54 PM, John Ament &lt;<br>
&gt;&gt;&gt; <a href="mailto:john.ament@spartasystems.com">john.ament@spartasystems.com</a>&gt; wrote:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Hey guys<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; I raised a bug against the Weld guys, but think its worth an EG<br>
&gt;&gt;&gt;&gt; discussion.  When a Principal object is injected, the only type it has is<br>
&gt;&gt;&gt;&gt; Principal.  It does not retain the actual type used at runtime.  This threw<br>
&gt;&gt;&gt;&gt; me off on some Keycloak integration I&#39;m working on (in $dayjob).  So I was<br>
&gt;&gt;&gt;&gt; wondering, is this expected from our POV or should it retain the types of<br>
&gt;&gt;&gt;&gt; the actual runtime instance?<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; John<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; ------------------------------<br>
&gt;&gt;&gt;&gt; NOTICE: This e-mail message and any attachments may contain<br>
&gt;&gt;&gt;&gt; confidential, proprietary, and/or privileged information which should be<br>
&gt;&gt;&gt;&gt; treated accordingly. If you are not the intended recipient, please notify<br>
&gt;&gt;&gt;&gt; the sender immediately by return e-mail, delete this message, and destroy<br>
&gt;&gt;&gt;&gt; all physical and electronic copies. Thank you.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; ______________________________<wbr>_________________<br>
&gt;&gt;&gt;&gt; cdi-dev mailing list<br>
&gt;&gt;&gt;&gt; <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
&gt;&gt;&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/<wbr>mailman/listinfo/cdi-dev</a><br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Note that for all code provided on this list, the provider licenses the<br>
&gt;&gt;&gt;&gt; code under the Apache License, Version 2 (<a href="http://www.apache.org/license" rel="noreferrer" target="_blank">http://www.apache.org/license</a><br>
&gt;&gt;&gt;&gt; s/LICENSE-2.0.html). For all other ideas provided on this list, the<br>
&gt;&gt;&gt;&gt; provider waives all patent and other intellectual property rights inherent<br>
&gt;&gt;&gt;&gt; in such information.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; ______________________________<wbr>_________________<br>
&gt;&gt;&gt; cdi-dev mailing list<br>
&gt;&gt;&gt; <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
&gt;&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/<wbr>mailman/listinfo/cdi-dev</a><br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Note that for all code provided on this list, the provider licenses the<br>
&gt;&gt;&gt; code under the Apache License, Version 2 (<a href="http://www.apache.org/license" rel="noreferrer" target="_blank">http://www.apache.org/license</a><br>
&gt;&gt;&gt; s/LICENSE-2.0.html). For all other ideas provided on this list, the<br>
&gt;&gt;&gt; provider waives all patent and other intellectual property rights inherent<br>
&gt;&gt;&gt; in such information.<br>
&gt;&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <a href="http://lists.jboss.org/pipermail/cdi-dev/attachments/20170426/1afdba6f/attachment.html" rel="noreferrer" target="_blank">http://lists.jboss.org/<wbr>pipermail/cdi-dev/attachments/<wbr>20170426/1afdba6f/attachment.<wbr>html</a><br>
<br>
------------------------------<br>
<br>
______________________________<wbr>_________________<br>
cdi-dev mailing list<br>
<a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/<wbr>mailman/listinfo/cdi-dev</a><br>
<br>
Note that for all code provided on this list, the provider licenses the code under the Apache License, Version 2 (<a href="http://www.apache.org/licenses/LICENSE-2.0.html" rel="noreferrer" target="_blank">http://www.apache.org/<wbr>licenses/LICENSE-2.0.html</a>).  For all other ideas provided on this list, the provider waives all patent and other intellectual property rights inherent in such information.<br>
<br>
End of cdi-dev Digest, Vol 77, Issue 11<br>
******************************<wbr>*********<br>
</blockquote></div><br></div></div>