You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@openwebbeans.apache.org by "l.penet@senat.fr" <l....@senat.fr> on 2016/07/07 22:45:00 UTC

Tomcat Embedded, OpenWebBeans and Principal

Hi?.


Following John D. Ament and Romain Manni-Bucau advice, I use Tomcat 
embedded for integration tests and it works great.


I have, however, one question : what should I do so that Principal gets 
correctly injected ?

Any help or example welcome.


Thanks in advance,


Ludovic


|
| AVANT D'IMPRIMER, PENSEZ A L'ENVIRONNEMENT.
|


Re: Tomcat Embedded, OpenWebBeans and Principal

Posted by Romain Manni-Bucau <rm...@gmail.com>.
normally it is scanned from the classpath when creating the context from
META-INF/openwebbeans/openwebbeans.properties

See
https://github.com/apache/openwebbeans/blob/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java#L222

But seems we enforce the security service:
https://github.com/apache/openwebbeans/blob/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/TomcatWebPlugin.java
so until you use asynchronism it should work:
https://github.com/apache/openwebbeans/blob/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/TomcatSecurityService.java

Maybe you can check these few entry points.



Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://blog-rmannibucau.rhcloud.com> | Old Wordpress Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com> | JavaEE Factory
<https://javaeefactory-rmannibucau.rhcloud.com>

2016-07-08 14:38 GMT+02:00 l.penet@senat.fr <l....@senat.fr>:

> On 08/07/2016 00:50, Romain Manni-Bucau wrote:
>
> Bonjour Ludovic,
>
> you need to
> extend org.apache.webbeans.corespi.security.ManagedSecurityService to
> implement getCurrentPrincipal() using probably a thread local to get the
> request (or gettng it from CDI) to access the servlet principal.
>
> The configuration of that service is done through openwebbeans.properties.
>
> Thanks (again) for your kind and quick reply.
>
> I did not suceed to let openwebbeans.properties scanned when using tomcat
> embedded. I use openwebbeans.properties in other projects, but in "regular
> tomcat".
>
> I took another way : I use the servlet module and
>
>     @Inject @DeltaSpike
>     HttpServletRequest request;
>
> then request.getUserPrincipal() and zou.
>
> I would be interested however to find how to get openwebbeans.properties
> taken into account by tomcat embedded. :-)
>
> Thanks again;
>
> Ludovic
> |
> | AVANT D'IMPRIMER, PENSEZ A L'ENVIRONNEMENT.
> |
>

Re: Tomcat Embedded, OpenWebBeans and Principal

Posted by "l.penet@senat.fr" <l....@senat.fr>.
On 08/07/2016 00:50, Romain Manni-Bucau wrote:
> Bonjour Ludovic,
>
> you need to 
> extend org.apache.webbeans.corespi.security.ManagedSecurityService to 
> implement getCurrentPrincipal() using probably a thread local to get 
> the request (or gettng it from CDI) to access the servlet principal.
>
> The configuration of that service is done through openwebbeans.properties.
Thanks (again) for your kind and quick reply.

I did not suceed to let openwebbeans.properties scanned when using 
tomcat embedded. I use openwebbeans.properties in other projects, but in 
"regular tomcat".

I took another way : I use the servlet module and

     @Inject @DeltaSpike
     HttpServletRequest request;

then request.getUserPrincipal() and zou.

I would be interested however to find how to get openwebbeans.properties 
taken into account by tomcat embedded. :-)

Thanks again;

Ludovic

|
| AVANT D'IMPRIMER, PENSEZ A L'ENVIRONNEMENT.
|


Re: Tomcat Embedded, OpenWebBeans and Principal

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Bonjour Ludovic,

you need to
extend org.apache.webbeans.corespi.security.ManagedSecurityService to
implement getCurrentPrincipal() using probably a thread local to get the
request (or gettng it from CDI) to access the servlet principal.

The configuration of that service is done through openwebbeans.properties.


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://blog-rmannibucau.rhcloud.com> | Old Wordpress Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com> | JavaEE Factory
<https://javaeefactory-rmannibucau.rhcloud.com>

2016-07-08 0:45 GMT+02:00 l.penet@senat.fr <l....@senat.fr>:

> Hi?.
>
>
> Following John D. Ament and Romain Manni-Bucau advice, I use Tomcat
> embedded for integration tests and it works great.
>
>
> I have, however, one question : what should I do so that Principal gets
> correctly injected ?
>
> Any help or example welcome.
>
>
> Thanks in advance,
>
>
> Ludovic
>
>
> |
> | AVANT D'IMPRIMER, PENSEZ A L'ENVIRONNEMENT.
> |
>
>