<div dir="ltr">Hi,<br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 26, 2017 at 5:41 PM, Romain Manni-Bucau <span dir="ltr"><<a href="mailto:rmannibucau@gmail.com" target="_blank">rmannibucau@gmail.com</a>></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"><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)</div></blockquote><div><br></div><div>I think that would require a new Principal type, which can be done, but who's going to put time into it to discuss it, spec it, implement it, etc?</div><div><br></div><div>Also, the difference with the current situation is not that much then. </div><div><br></div><div>Extended Principal:</div><div><br></div><div><br></div><div>@Inject CallerPrincipal callerPrincipal;</div><div><br></div><div>...</div><div><br></div><div>MyPrincipal myPrincipal = callerPrincipal.unwrap();</div><div><br></div><div><br></div><div>vs</div><div><br></div><div><br></div><div>Security context:</div><div><br></div><div>@Inject SecurityContext securityContext;<br></div><div><br></div><div>...</div><div><br></div><div>MyPrincipal myPrincipal = securityContext.getCallerPrincipal();<br></div><div><br></div><div>Spot the differences ;)</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">In other words either Principal is removed from CDI spec </div></blockquote><div><br></div><div>I think this should be done anyway. The build-in bean for Principal would be more at home with the Security API spec. I would be happy to take it in ;)</div><div><br></div><div>(likewise, the build-in bean for HttpServletRequest etc should be with the Servlet spec)</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">or it stays but it should be extended to be made usable IMHO.</div></blockquote><div><br></div><div>What CDI could provide and which has been discussed before, is a method to get the real bean from a proxy. E.g.</div><div><br></div><div>@Inject CallerPrincipal callerPrincipal;<br></div><div>@Inject BeanManager beanManager;</div><div><br></div><div>...</div><div><br></div><div>MyPrincipal myPrincipal = beanManager.unwrap(callerPrincipal);</div><div><br></div><div>Kind regards,</div><div>Arjan Tijms</div><div><br></div><div><br></div><div> </div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail_extra"><span class="gmail-"><br clear="all"><div><div class="gmail-m_-5104628441580598949gmail_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></span><div><div class="gmail-h5"><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:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);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.ge<wbr>tContextId(), type, getTypes(), this).create(new EnterpriseTargetBeanInstance(t<wbr>ype, new CallableMethodHandler(callable<wbr>)));</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="gmail-m_-5104628441580598949h5">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:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div class="gmail-m_-5104628441580598949h5">
<div dir="ltr">
<div id="gmail-m_-5104628441580598949m_-6220285763532774275m_-7940682118025092754divtagdefaultwrapper" style="font-size:12pt;color:rgb(0,0,0);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="gmail-m_-5104628441580598949m_-6220285763532774275m_-7940682118025092754Signature">
<div id="gmail-m_-5104628441580598949m_-6220285763532774275m_-7940682118025092754divtagdefaultwrapper" dir="ltr" style="font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255);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>______________________________<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" 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></blockquote></div><br></div></div></div>
</blockquote></div><br></div></div>