Hello,
May I make a comment on this.
Looking at https://docs.oracle.com/javaee/7/tutorial/cdi-adv004.htm, it looks
like you can't inject a Principal using @Inject annotation, right?
But using @Resource annotation, you are able to get the Principal.
So in your previous code:
@Named
@RequestScoped
public class PrincipalTest {
@Inject-> change @Inject by @Resource, does it work ?
private Principal principal;
public String userName(){
return principal.getName();
}
}
Best Regards.
-----Original Message-----
From: Richard Monson-Haefel [mailto:[email protected]]
Sent: mardi 15 octobre 2019 13:42
To: [email protected]
Subject: Re: Re: CDI Principal injection: object is not an instance of
declaring class
Hi Markus,
Do you want to try your hand at a doing a Pull-Request so you can get your
first commit on TomEE? I can help you with that. It's actually pretty easy to
do.
Richard
On Tue, Oct 15, 2019 at 6:36 AM makkus <[email protected]> wrote:
> Hi Richard,
>
> I have attached the source files here:
>
> leak2.zip <
> https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Ftomee
> -openejb.979440.n4.nabble.com%2Ffile%2Ft376354%2Fleak2.zip&data=02
> %7C01%7CFrancois.COURTAULT%40gemalto.com%7Ca4f5d66df05546eb376e08d7516
> 4be4b%7C37d0a9db7c464096bfe31add5b495d6d%7C0%7C1%7C637067365437190360&
> amp;sdata=IxxcqUuO7L1CStvRUS0HCU3zs9PgIa%2FKxG8ziESdPDs%3D&reserve
> d=0>
>
> Maybe it is worth a note that the injection of SecurityContext still works.
> So as a workaround the following will do the Job:
>
> @Context
> private SecurityContext securityCtx;
>
> public String userName(){
> return securityCtx.getUserPrincipal().getName();
> }
>
> Thanks for investigating this!
> Marcus
>
>
>
>
> --
> Sent from:
> https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Ftomee
> -openejb.979440.n4.nabble.com%2FTomEE-Users-f979441.html&data=02%7
> C01%7CFrancois.COURTAULT%40gemalto.com%7Ca4f5d66df05546eb376e08d75164b
> e4b%7C37d0a9db7c464096bfe31add5b495d6d%7C0%7C1%7C637067365437190360&am
> p;sdata=eiF1kL6x7QMtJgEgINI%2BEzdJ5zgrh0Vyqqyr0yhCRho%3D&reserved=
> 0
>
--
Richard Monson-Haefel
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Ftwitter.com%2Frmonson&data=02%7C01%7CFrancois.COURTAULT%40gemalto.com%7Ca4f5d66df05546eb376e08d75164be4b%7C37d0a9db7c464096bfe31add5b495d6d%7C0%7C0%7C637067365437190360&sdata=mGvDJ72pYWoeSKFMPxpOIwZFqK%2F4CWutWTpzpga2vys%3D&reserved=0
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.linkedin.com%2Fin%2Fmonsonhaefel%2F&data=02%7C01%7CFrancois.COURTAULT%40gemalto.com%7Ca4f5d66df05546eb376e08d75164be4b%7C37d0a9db7c464096bfe31add5b495d6d%7C0%7C1%7C637067365437190360&sdata=uaiPWx2%2BHL5c5lBlYhRqarcOP6eN5QDH0i0yShlDdYY%3D&reserved=0
________________________________
This message and any attachments are intended solely for the addressees and
may contain confidential information. Any unauthorized use or disclosure,
either whole or partial, is prohibited.
E-mails are susceptible to alteration. Our company shall not be liable for the
message if altered, changed or falsified. If you are not the intended recipient
of this message, please delete it and notify the sender.
Although all reasonable efforts have been made to keep this transmission free
from viruses, the sender will not be liable for damages caused by a transmitted
virus.