<div dir="ltr">Hi,<div><br></div><div>We discussed this very issue in the Security API EG as well. In the Security API the actual type *MUST* be retained as per the spec definition.</div><div><br></div><div>The problem in CDI, at least in Weld, is that a proxy is injected. This happens via the build-in bean &quot;PrincipalBean extends AbstractEEBean&quot;, where AbstractEEBean does:</div><div><br></div><div><div>public abstract class AbstractEEBean&lt;T&gt; extends AbstractStaticallyDecorableBuiltInBean&lt;T&gt; {</div><div><br></div><div>    private final T proxy;</div><div><br></div><div>    protected AbstractEEBean(Class&lt;T&gt; type, Callable&lt;T&gt; callable, BeanManagerImpl beanManager) {</div><div>        super(beanManager, type);</div><div>        this.proxy = new ProxyFactory&lt;T&gt;(beanManager.getContextId(), type, getTypes(), this).create(new EnterpriseTargetBeanInstance(type, new CallableMethodHandler(callable)));</div><div>    }</div></div><div>    // ...</div><div>}</div><div><br></div><div>I&#39;m not even sure if it&#39;s possible to downcast the proxy to the required runtime type.</div><div><br></div><div>Also note that the Principal can change during the request. The simplest case is when during an http request HttpServletRequest#logout is called.</div><div><br></div><div>Kind regards,</div><div>Arjan Tijms</div><div><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 26, 2017 at 3:54 PM, John Ament <span dir="ltr">&lt;<a href="mailto:john.ament@spartasystems.com" target="_blank">john.ament@spartasystems.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">




<div dir="ltr">
<div id="m_-7940682118025092754divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif" dir="ltr">
<p>Hey guys</p>
<p><br>
</p>
<p>I raised a bug against the Weld guys, but think its worth an EG discussion.  When a Principal object is injected, the only type it has is Principal.  It does not retain the actual type used at runtime.  This threw me off on some Keycloak integration I&#39;m
 working on (in $dayjob).  So I was wondering, is this expected from our POV or should it retain the types of the actual runtime instance?</p>
<p><br>
</p>
<p>John</p>
<div id="m_-7940682118025092754Signature">
<div id="m_-7940682118025092754divtagdefaultwrapper" dir="ltr" style="font-size:12pt;color:#000000;background-color:#ffffff;font-family:Calibri,Arial,Helvetica,sans-serif">
<p></p>
</div>
</div>
</div>
<hr>
NOTICE: This e-mail message and any attachments may contain confidential, proprietary, and/or privileged information which should be treated accordingly. If you are not the intended recipient, please notify the sender immediately by return e-mail, delete this
 message, and destroy all physical and electronic copies. Thank you.
</div>

<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></blockquote></div><br></div>