<div dir="ltr">Not sure, if I follow you on that?<div><br></div><div>java.security.Principal is not part of the CDI spec at all and only used by a special subclass of</div><div><span class="gmail-pl-en" style="box-sizing:border-box;color:rgb(121,93,163);font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:12px;white-space:pre">AbstractEEBean</span><span style="color:rgb(36,41,46);font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:12px;white-space:pre">&lt;T&gt;</span><br><div class="gmail_extra"><br></div><div class="gmail_extra">The problem seems the generic T which Java at this point is unable to know about at runtime.</div><div class="gmail_extra"><br></div><div class="gmail_extra">It makes no difference, if you had</div><div class="gmail_extra"><span class="gmail-pl-en" style="box-sizing:border-box;color:rgb(121,93,163);font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:12px;white-space:pre">PrincipalBean</span><span style="color:rgb(36,41,46);font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:12px;white-space:pre"> </span><span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93);font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:12px;white-space:pre">extends</span><span style="color:rgb(36,41,46);font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:12px;white-space:pre"> </span><span class="gmail-pl-e" style="box-sizing:border-box;color:rgb(121,93,163);font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:12px;white-space:pre">AbstractEEBean&lt;<span class="gmail-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">Principal</span>&gt;</span><br></div><div class="gmail_extra">or a<br></div><div class="gmail_extra"><span class="gmail-pl-en" style="box-sizing:border-box;color:rgb(121,93,163);font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:12px;white-space:pre">StringBean</span><span style="color:rgb(36,41,46);font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:12px;white-space:pre"> </span><span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93);font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:12px;white-space:pre">extends</span><span style="color:rgb(36,41,46);font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:12px;white-space:pre"> </span><span class="gmail-pl-e" style="box-sizing:border-box;color:rgb(121,93,163);font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:12px;white-space:pre">AbstractBuiltInBean&lt;<span class="gmail-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">String</span>&gt;</span></div><div class="gmail_extra"><font color="#795da3" face="sfmono-regular, consolas, liberation mono, menlo, courier, monospace"><span style="font-size:12px;white-space:pre"><br></span></font></div><div class="gmail_extra">Even created a JUnit test in<div><div class="gmail_signature"><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"><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"><a href="https://github.com/unitsofmeasurement/uom-se/blob/master/src/test/java/tec/uom/se/AbsUnitTest.java">https://github.com/unitsofmeasurement/uom-se/blob/master/src/test/java/tec/uom/se/AbsUnitTest.java</a><br></span></font></p><p style="margin:0px;border-collapse:collapse">Which under Java 8 returns<br></p><p style="margin:0px;border-collapse:collapse"><span class="gmail-pl-pds" style="box-sizing:border-box;color:rgb(24,54,145);font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:12px;white-space:pre">&quot;</span><span style="color:rgb(24,54,145);font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:12px;white-space:pre">java.lang.reflect.TypeVariable&lt;D&gt;</span><span class="gmail-pl-pds" style="box-sizing:border-box;color:rgb(24,54,145);font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:12px;white-space:pre">&quot;</span><br></p><p style="margin:0px;border-collapse:collapse">No sign of &quot;Length&quot; which is what you&#39;d hoped for (maybe we did not dig deep enough, maybe it won&#39;t work until a future Java version?)</p><p style="margin:0px;border-collapse:collapse"><font face="arial, helvetica, sans-serif" size="1"><span lang="EN-US"><br></span></font></p><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>
<br><div class="gmail_quote">On Wed, Apr 26, 2017 at 5:46 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:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);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 (Romain Manni-Bucau)<br>
   2. Re: Types of Principal object (Werner Keil)<br>
<br>
<br>
------------------------------<wbr>------------------------------<wbr>----------<br>
<br>
Message: 1<br>
Date: Wed, 26 Apr 2017 17:41:08 +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=7OK-<wbr>JWXptMQxM8BUAvE2ab5gOwNiNBHCDb<wbr>jy=<a href="mailto:UNkuEGQg@mail.gmail.com">UNkuEGQg@mail.gmail.com</a>&gt;<br>
Content-Type: text/plain; charset=&quot;utf-8&quot;<br>
<br>
that&#39;s why security API needs a more typed API acting as an handler and not<br>
as a contextual instance, it would allow to unwrap the actual instance<br>
(like most specs do) but at CDI level it should also be possible. If not we<br>
have this built-in bean never working until you add another not mandatory<br>
spec - for CDI level. In other words either Principal is removed from CDI<br>
spec or it stays but it should be extended to be made usable IMHO.<br>
<br>
<br>
Romain Manni-Bucau<br>
@rmannibucau &lt;<a href="https://twitter.com/rmannibucau" rel="noreferrer" target="_blank">https://twitter.com/<wbr>rmannibucau</a>&gt; |  Blog<br>
&lt;<a href="https://blog-rmannibucau.rhcloud.com" rel="noreferrer" target="_blank">https://blog-rmannibucau.<wbr>rhcloud.com</a>&gt; | Old Blog<br>
&lt;<a href="http://rmannibucau.wordpress.com" rel="noreferrer" target="_blank">http://rmannibucau.wordpress.<wbr>com</a>&gt; | Github &lt;<a href="https://github.com/rmannibucau" rel="noreferrer" target="_blank">https://github.com/<wbr>rmannibucau</a>&gt; |<br>
LinkedIn &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>
&lt;<a href="https://javaeefactory-rmannibucau.rhcloud.com" rel="noreferrer" target="_blank">https://javaeefactory-<wbr>rmannibucau.rhcloud.com</a>&gt;<br>
<br>
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>
<br>
&gt; Hi,<br>
&gt;<br>
&gt; We discussed this very issue in the Security API EG as well. In the<br>
&gt; Security API the actual type *MUST* be retained as per the spec definition.<br>
&gt;<br>
&gt; The problem in CDI, at least in Weld, is that a proxy is injected. This<br>
&gt; happens via the build-in bean &quot;PrincipalBean extends AbstractEEBean&quot;, where<br>
&gt; AbstractEEBean does:<br>
&gt;<br>
&gt; public abstract class AbstractEEBean&lt;T&gt; extends<br>
&gt; AbstractStaticallyDecorableBui<wbr>ltInBean&lt;T&gt; {<br>
&gt;<br>
&gt;     private final T proxy;<br>
&gt;<br>
&gt;     protected AbstractEEBean(Class&lt;T&gt; type, Callable&lt;T&gt; callable,<br>
&gt; BeanManagerImpl beanManager) {<br>
&gt;         super(beanManager, type);<br>
&gt;         this.proxy = new ProxyFactory&lt;T&gt;(beanManager.<wbr>getContextId(),<br>
&gt; type, getTypes(), this).create(new EnterpriseTargetBeanInstance(<wbr>type, new<br>
&gt; CallableMethodHandler(<wbr>callable)));<br>
&gt;     }<br>
&gt;     // ...<br>
&gt; }<br>
&gt;<br>
&gt; I&#39;m not even sure if it&#39;s possible to downcast the proxy to the required<br>
&gt; runtime type.<br>
&gt;<br>
&gt; Also note that the Principal can change during the request. The simplest<br>
&gt; case is when during an http request HttpServletRequest#logout is called.<br>
&gt;<br>
&gt; Kind regards,<br>
&gt; Arjan Tijms<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&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>&gt;<br>
&gt; wrote:<br>
&gt;<br>
&gt;&gt; Hey guys<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;&gt; discussion.  When a Principal object is injected, the only type it has is<br>
&gt;&gt; Principal.  It does not retain the actual type used at runtime.  This threw<br>
&gt;&gt; me off on some Keycloak integration I&#39;m working on (in $dayjob).  So I was<br>
&gt;&gt; wondering, is this expected from our POV or should it retain the types of<br>
&gt;&gt; the actual runtime instance?<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; John<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;&gt; sender immediately by return e-mail, delete this message, and destroy all<br>
&gt;&gt; physical 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;&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>
&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/ad930662/attachment-0001.html" rel="noreferrer" target="_blank">http://lists.jboss.org/<wbr>pipermail/cdi-dev/attachments/<wbr>20170426/ad930662/attachment-<wbr>0001.html</a><br>
<br>
------------------------------<br>
<br>
Message: 2<br>
Date: Wed, 26 Apr 2017 17:44:04 +0200<br>
From: Werner Keil &lt;<a href="mailto:werner.keil@gmail.com">werner.keil@gmail.com</a>&gt;<br>
Subject: Re: [cdi-dev] Types of Principal object<br>
To: cdi-dev &lt;<a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a>&gt;<br>
Message-ID:<br>
        &lt;CAAGawe1dmVUmgnrnmtV_oS0==<wbr>fttYOe44ZhG4YfO+yme2=<a href="mailto:oT_A@mail.gmail.com">oT_A@<wbr>mail.gmail.com</a>&gt;<br>
Content-Type: text/plain; charset=&quot;utf-8&quot;<br>
<br>
Seems the title of the thread was also not &quot;reified&quot; in this case.<br>
Sometimes reply just works, but if it was lost, sorry for that.<br>
<br>
Werner<br>
<br>
<br>
On Wed, Apr 26, 2017 at 5:41 PM, Werner Keil &lt;<a href="mailto:werner.keil@gmail.com">werner.keil@gmail.com</a>&gt; wrote:<br>
<br>
&gt; We had similar challenges and discussions even before JSR 363 about<br>
&gt; knowing what type of quantity you&#39;re dealing with types like<br>
&gt;<br>
&gt; Unit&lt;Q extends Quantity &lt;<a href="http://unitsofmeasurement.github.io/unit-api/site/apidocs/javax/measure/Quantity.html" rel="noreferrer" target="_blank">http://unitsofmeasurement.<wbr>github.io/unit-api/site/<wbr>apidocs/javax/measure/<wbr>Quantity.html</a>&gt;&lt;Q&gt;&gt;<br>
&gt;<br>
&gt; I can only confirm Arjan&#39;s impression. And I had numerous conversations<br>
&gt; with Andrew Kennedy, the Chief Architect behind the F# Units of Measurement<br>
&gt; support and other .NET libraries about it. Where he mentioned shortcomings<br>
&gt; of the Java language especially the lack of Reified Generics (<br>
&gt; <a href="http://stackoverflow.com/questions/31876372/what-is-reification" rel="noreferrer" target="_blank">http://stackoverflow.com/<wbr>questions/31876372/what-is-<wbr>reification</a>), which<br>
&gt; C#, F# or other .NET languages got, but Java won&#39;t at least not until Java<br>
&gt; 10, 11 or even later.<br>
&gt;<br>
&gt; I tried a lot between 2010 and now but so far none of these Reflection<br>
&gt; tricks and approaches were stable enough, so not sure, if it&#39;ll work any<br>
&gt; better in this case (unless you implement CDI in C#;-)<br>
&gt;<br>
&gt; Werner<br>
&gt;<br>
&gt;<br>
&gt; On Wed, Apr 26, 2017 at 5:29 PM, &lt;<a href="mailto:cdi-dev-request@lists.jboss.org">cdi-dev-request@lists.jboss.<wbr>org</a>&gt; wrote:<br>
&gt;<br>
&gt;&gt; Send cdi-dev mailing list submissions to<br>
&gt;&gt;         <a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
&gt;&gt;<br>
&gt;&gt; To subscribe or unsubscribe via the World Wide Web, visit<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; or, via email, send a message with subject or body &#39;help&#39; to<br>
&gt;&gt;         <a href="mailto:cdi-dev-request@lists.jboss.org">cdi-dev-request@lists.jboss.<wbr>org</a><br>
&gt;&gt;<br>
&gt;&gt; You can reach the person managing the list at<br>
&gt;&gt;         <a href="mailto:cdi-dev-owner@lists.jboss.org">cdi-dev-owner@lists.jboss.org</a><br>
&gt;&gt;<br>
&gt;&gt; When replying, please edit your Subject line so it is more specific<br>
&gt;&gt; than &quot;Re: Contents of cdi-dev digest...&quot;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; Today&#39;s Topics:<br>
&gt;&gt;<br>
&gt;&gt;    1. Types of Principal object (John Ament)<br>
&gt;&gt;    2. Re: Types of Principal object (Romain Manni-Bucau)<br>
&gt;&gt;    3. Re: Types of Principal object (Matej Novotny)<br>
&gt;&gt;    4. Re: Types of Principal object (arjan tijms)<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; ------------------------------<wbr>------------------------------<wbr>----------<br>
&gt;&gt;<br>
&gt;&gt; Message: 1<br>
&gt;&gt; Date: Wed, 26 Apr 2017 13:54:57 +0000<br>
&gt;&gt; From: John Ament &lt;<a href="mailto:john.ament@spartasystems.com">john.ament@spartasystems.com</a>&gt;<br>
&gt;&gt; Subject: [cdi-dev] Types of Principal object<br>
&gt;&gt; To: cdi-dev &lt;<a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a>&gt;<br>
&gt;&gt; Message-ID:<br>
&gt;&gt;         &lt;<wbr>CY4PR04MB048607BF779F8680ED5CE<wbr>53898110@CY4PR04MB0486.namprd<br>
&gt;&gt; <a href="http://04.prod.outlook.com" rel="noreferrer" target="_blank">04.prod.outlook.com</a>&gt;<br>
&gt;&gt;<br>
&gt;&gt; Content-Type: text/plain; charset=&quot;iso-8859-1&quot;<br>
&gt;&gt;<br>
&gt;&gt; Hey guys<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;&gt; discussion.  When a Principal object is injected, the only type it has is<br>
&gt;&gt; Principal.  It does not retain the actual type used at runtime.  This threw<br>
&gt;&gt; me off on some Keycloak integration I&#39;m working on (in $dayjob).  So I was<br>
&gt;&gt; wondering, is this expected from our POV or should it retain the types of<br>
&gt;&gt; the actual runtime instance?<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; John<br>
&gt;&gt;<br>
&gt;&gt; ______________________________<wbr>__<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;&gt; sender immediately by return e-mail, delete this message, and destroy all<br>
&gt;&gt; physical and electronic copies. Thank you.<br>
&gt;&gt; -------------- next part --------------<br>
&gt;&gt; An HTML attachment was scrubbed...<br>
&gt;&gt; URL: <a href="http://lists.jboss.org/pipermail/cdi-dev/attachments/2017042" rel="noreferrer" target="_blank">http://lists.jboss.org/<wbr>pipermail/cdi-dev/attachments/<wbr>2017042</a><br>
&gt;&gt; 6/b6740722/attachment-0001.<wbr>html<br>
&gt;&gt;<br>
&gt;&gt; ------------------------------<br>
&gt;&gt;<br>
&gt;&gt; Message: 2<br>
&gt;&gt; Date: Wed, 26 Apr 2017 16:38:01 +0200<br>
&gt;&gt; From: Romain Manni-Bucau &lt;<a href="mailto:rmannibucau@gmail.com">rmannibucau@gmail.com</a>&gt;<br>
&gt;&gt; Subject: Re: [cdi-dev] Types of Principal object<br>
&gt;&gt; To: John Ament &lt;<a href="mailto:john.ament@spartasystems.com">john.ament@spartasystems.com</a>&gt;<br>
&gt;&gt; Cc: cdi-dev &lt;<a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a>&gt;<br>
&gt;&gt; Message-ID:<br>
&gt;&gt;         &lt;CACLE=7N=<a href="mailto:pkvZDX3ULCFAK2Fhw8-bH0pbOsqctqsbkPhKk8i1VA@mail.gm">pkvZDX3ULCFAK2Fhw8-<wbr>bH0pbOsqctqsbkPhKk8i1VA@mail.<wbr>gm</a><br>
&gt;&gt; <a href="http://ail.com" rel="noreferrer" target="_blank">ail.com</a>&gt;<br>
&gt;&gt; Content-Type: text/plain; charset=&quot;utf-8&quot;<br>
&gt;&gt;<br>
&gt;&gt; Hi John,<br>
&gt;&gt;<br>
&gt;&gt; agree CDI/security integration (mainly through Principal bean) is<br>
&gt;&gt; completely unusable in practise cause Principal type is too simple (name<br>
&gt;&gt; only) and casting is needed in 99.99% of apps. AFAIK It is tracked at<br>
&gt;&gt; <a href="https://issues.jboss.org/browse/CDI-597" rel="noreferrer" target="_blank">https://issues.jboss.org/<wbr>browse/CDI-597</a>.<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 &lt;<br>
&gt;&gt; <a href="https://github.com/rmannibucau" rel="noreferrer" target="_blank">https://github.com/rmannibucau</a><wbr>&gt; |<br>
&gt;&gt; LinkedIn &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 15:54 GMT+02:00 John Ament &lt;<a href="mailto:john.ament@spartasystems.com">john.ament@spartasystems.com</a>&gt;<wbr>:<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<br>
&gt;&gt; is<br>
&gt;&gt; &gt; Principal.  It does not retain the actual type used at runtime.  This<br>
&gt;&gt; threw<br>
&gt;&gt; &gt; me off on some Keycloak integration I&#39;m working on (in $dayjob).  So I<br>
&gt;&gt; was<br>
&gt;&gt; &gt; wondering, is this expected from our POV or should it retain the types<br>
&gt;&gt; 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; confidential,<br>
&gt;&gt; &gt; proprietary, and/or privileged information which should be treated<br>
&gt;&gt; &gt; accordingly. If you are not the intended recipient, please notify the<br>
&gt;&gt; &gt; sender immediately by return e-mail, delete this message, and destroy<br>
&gt;&gt; all<br>
&gt;&gt; &gt; 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/" rel="noreferrer" target="_blank">http://www.apache.org/</a><br>
&gt;&gt; &gt; licenses/LICENSE-2.0.html). For all other ideas provided on this list,<br>
&gt;&gt; &gt; the provider waives all patent and other intellectual property rights<br>
&gt;&gt; &gt; inherent in such information.<br>
&gt;&gt; &gt;<br>
&gt;&gt; -------------- next part --------------<br>
&gt;&gt; An HTML attachment was scrubbed...<br>
&gt;&gt; URL: <a href="http://lists.jboss.org/pipermail/cdi-dev/attachments/2017042" rel="noreferrer" target="_blank">http://lists.jboss.org/<wbr>pipermail/cdi-dev/attachments/<wbr>2017042</a><br>
&gt;&gt; 6/19976ebd/attachment-0001.<wbr>html<br>
&gt;&gt;<br>
&gt;&gt; ------------------------------<br>
&gt;&gt;<br>
&gt;&gt; Message: 3<br>
&gt;&gt; Date: Wed, 26 Apr 2017 10:48:40 -0400 (EDT)<br>
&gt;&gt; From: Matej Novotny &lt;<a href="mailto:manovotn@redhat.com">manovotn@redhat.com</a>&gt;<br>
&gt;&gt; Subject: Re: [cdi-dev] Types of Principal object<br>
&gt;&gt; To: John Ament &lt;<a href="mailto:john.ament@spartasystems.com">john.ament@spartasystems.com</a>&gt;<br>
&gt;&gt; Cc: cdi-dev &lt;<a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a>&gt;<br>
&gt;&gt; Message-ID:<br>
&gt;&gt;         &lt;<a href="mailto:1098875365.1348630.1493218120014.JavaMail.zimbra@redhat.com">1098875365.1348630.<wbr>1493218120014.JavaMail.zimbra@<wbr>redhat.com</a>&gt;<br>
&gt;&gt; Content-Type: text/plain; charset=utf-8<br>
&gt;&gt;<br>
&gt;&gt; Hey John,<br>
&gt;&gt;<br>
&gt;&gt; just to shed some light.<br>
&gt;&gt; One of the reasons it works this way is because the types the actual<br>
&gt;&gt; Principal has might not be proxyable.<br>
&gt;&gt; And spec requires all built-in beans to be decorable - e.g. you need them<br>
&gt;&gt; to be proxyable (although the added value of principal decorator is ...eh,<br>
&gt;&gt; disputable at best?).<br>
&gt;&gt;<br>
&gt;&gt; Therefore, it is safer/viable to create a proxyable wrapper object which<br>
&gt;&gt; implements Principal only and delegetas calls (that&#39;s what Weld does).<br>
&gt;&gt;<br>
&gt;&gt; Otherwise I agree it could be nice to ahve a way to cast the object as<br>
&gt;&gt; the pure Principal interface doesn&#39;t help much.<br>
&gt;&gt;<br>
&gt;&gt; Matej<br>
&gt;&gt;<br>
&gt;&gt; ----- Original Message -----<br>
&gt;&gt; &gt; From: &quot;John Ament&quot; &lt;<a href="mailto:john.ament@spartasystems.com">john.ament@spartasystems.com</a>&gt;<br>
&gt;&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; &gt; Sent: Wednesday, April 26, 2017 3:54:57 PM<br>
&gt;&gt; &gt; Subject: [cdi-dev] Types of Principal object<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Hey guys<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<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; discussion.<br>
&gt;&gt; &gt; When a Principal object is injected, the only type it has is Principal.<br>
&gt;&gt; It<br>
&gt;&gt; &gt; does not retain the actual type used at runtime. This threw me off on<br>
&gt;&gt; some<br>
&gt;&gt; &gt; Keycloak integration I&#39;m working on (in $dayjob). So I was wondering, is<br>
&gt;&gt; &gt; this expected from our POV or should it retain the types of the actual<br>
&gt;&gt; &gt; runtime instance?<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<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;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; NOTICE: This e-mail message and any attachments may contain<br>
&gt;&gt; confidential,<br>
&gt;&gt; &gt; proprietary, and/or privileged information which should be treated<br>
&gt;&gt; &gt; accordingly. If you are not the intended recipient, please notify the<br>
&gt;&gt; sender<br>
&gt;&gt; &gt; immediately by return e-mail, delete this message, and destroy all<br>
&gt;&gt; physical<br>
&gt;&gt; &gt; 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; code<br>
&gt;&gt; &gt; under the Apache License, Version 2<br>
&gt;&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; &gt; provided on this list, the provider waives all patent and other<br>
&gt;&gt; intellectual<br>
&gt;&gt; &gt; property rights inherent in such information.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; ------------------------------<br>
&gt;&gt;<br>
&gt;&gt; Message: 4<br>
&gt;&gt; Date: Wed, 26 Apr 2017 17:11:11 +0200<br>
&gt;&gt; From: arjan tijms &lt;<a href="mailto:arjan.tijms@gmail.com">arjan.tijms@gmail.com</a>&gt;<br>
&gt;&gt; Subject: Re: [cdi-dev] Types of Principal object<br>
&gt;&gt; To: John Ament &lt;<a href="mailto:john.ament@spartasystems.com">john.ament@spartasystems.com</a>&gt;<br>
&gt;&gt; Cc: cdi-dev &lt;<a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a>&gt;<br>
&gt;&gt; Message-ID:<br>
&gt;&gt;         &lt;CAE=-<wbr>AhA0PiXZpSKmy0XYoMxCFuyxjV3Wt=<wbr>jjFzhC=G+LOc9TDA@mail.<br>
&gt;&gt; <a href="http://gmail.com" rel="noreferrer" target="_blank">gmail.com</a>&gt;<br>
&gt;&gt; Content-Type: text/plain; charset=&quot;utf-8&quot;<br>
&gt;&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<br>
&gt;&gt; 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;,<br>
&gt;&gt; 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,<br>
&gt;&gt; getTypes(), this).create(new EnterpriseTargetBeanInstance(<wbr>type, new<br>
&gt;&gt; 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;<br>
&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<br>
&gt;&gt; is<br>
&gt;&gt; &gt; Principal.  It does not retain the actual type used at runtime.  This<br>
&gt;&gt; threw<br>
&gt;&gt; &gt; me off on some Keycloak integration I&#39;m working on (in $dayjob).  So I<br>
&gt;&gt; was<br>
&gt;&gt; &gt; wondering, is this expected from our POV or should it retain the types<br>
&gt;&gt; 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; confidential,<br>
&gt;&gt; &gt; proprietary, and/or privileged information which should be treated<br>
&gt;&gt; &gt; accordingly. If you are not the intended recipient, please notify the<br>
&gt;&gt; &gt; sender immediately by return e-mail, delete this message, and destroy<br>
&gt;&gt; all<br>
&gt;&gt; &gt; 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/" rel="noreferrer" target="_blank">http://www.apache.org/</a><br>
&gt;&gt; &gt; licenses/LICENSE-2.0.html). For all other ideas provided on this list,<br>
&gt;&gt; &gt; the provider waives all patent and other intellectual property rights<br>
&gt;&gt; &gt; inherent in such information.<br>
&gt;&gt; &gt;<br>
&gt;&gt; -------------- next part --------------<br>
&gt;&gt; An HTML attachment was scrubbed...<br>
&gt;&gt; URL: <a href="http://lists.jboss.org/pipermail/cdi-dev/attachments/2017042" rel="noreferrer" target="_blank">http://lists.jboss.org/<wbr>pipermail/cdi-dev/attachments/<wbr>2017042</a><br>
&gt;&gt; 6/206ff811/attachment.html<br>
&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;&gt; End of cdi-dev Digest, Vol 77, Issue 8<br>
&gt;&gt; ******************************<wbr>********<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/ebea1962/attachment.html" rel="noreferrer" target="_blank">http://lists.jboss.org/<wbr>pipermail/cdi-dev/attachments/<wbr>20170426/ebea1962/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 10<br>
******************************<wbr>*********<br>
</blockquote></div><br></div></div></div>