<div dir="ltr">that's why security API needs a more typed API acting as an handler and not as a contextual instance, it would allow to unwrap the actual instance (like most specs do) but at CDI level it should also be possible. If not we have this built-in bean never working until you add another not mandatory spec - for CDI level. In other words either Principal is removed from CDI spec or it stays but it should be extended to be made usable IMHO.</div><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><div dir="ltr"><div><br><span style="font-size:small">Romain Manni-Bucau</span><br><a href="https://twitter.com/rmannibucau" target="_blank">@rmannibucau</a> | <a href="https://blog-rmannibucau.rhcloud.com" target="_blank">Blog</a> | <a href="http://rmannibucau.wordpress.com" target="_blank">Old Blog</a> | <a href="https://github.com/rmannibucau" target="_blank">Github</a> | <a href="https://www.linkedin.com/in/rmannibucau" target="_blank">LinkedIn</a> | <a href="https://javaeefactory-rmannibucau.rhcloud.com" target="_blank">JavaEE Factory</a></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>
<br><div class="gmail_quote">2017-04-26 17:11 GMT+02:00 arjan tijms <span dir="ltr"><<a href="mailto:arjan.tijms@gmail.com" target="_blank">arjan.tijms@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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 "PrincipalBean extends AbstractEEBean", where AbstractEEBean does:</div><div><br></div><div><div>public abstract class AbstractEEBean<T> extends AbstractStaticallyDecorableBui<wbr>ltInBean<T> {</div><div><br></div><div> private final T proxy;</div><div><br></div><div> protected AbstractEEBean(Class<T> type, Callable<T> callable, BeanManagerImpl beanManager) {</div><div> super(beanManager, type);</div><div> this.proxy = new ProxyFactory<T>(beanManager.<wbr>getContextId(), type, getTypes(), this).create(new EnterpriseTargetBeanInstance(<wbr>type, new CallableMethodHandler(<wbr>callable)));</div><div> }</div></div><div> // ...</div><div>}</div><div><br></div><div>I'm not even sure if it'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"><div><div class="h5">On Wed, Apr 26, 2017 at 3:54 PM, John Ament <span dir="ltr"><<a href="mailto:john.ament@spartasystems.com" target="_blank">john.ament@spartasystems.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
<div dir="ltr">
<div id="m_-6220285763532774275m_-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'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_-6220285763532774275m_-7940682118025092754Signature">
<div id="m_-6220285763532774275m_-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></div></div><span class="">______________________________<wbr>_________________<br>
cdi-dev mailing list<br>
<a href="mailto:cdi-dev@lists.jboss.org" target="_blank">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/mailma<wbr>n/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/license<wbr>s/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></span></blockquote></div><br></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>