You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by Olivier Paquet <ol...@atos.net> on 2014/08/06 16:12:08 UTC

Principal in EJB returns always "guest" even with JAAS module

Hi, 

Unfortunately even when following the way of other solutions found on this
forum, using JAAS or putting p.put("openejb.ejbd.authenticate-with-request",
"true"); in remote lookup properties, I'm getting always the principal
"guest" in my EJB using EJBContext.getCallerPrincipal().

I use the TomEE 1.7.0-SNAPSHOT version and I defined the JAAS module a
mentionned here
(http://rmannibucau.wordpress.com/2012/05/09/tomee-and-its-ssh-connector/) ,
before I tried the JDBCRealm and so on, but result is still the same ->
guest

I'm calling my remote EJB as follow:


It always works fine, I could see in the console(with JDBCRealm and
DatasourceRealm) that the correct EJB User has been authenticated, but in my
EJB the user is always guest and my @RolesAllowed does not work.

Any hints how to solve this issue?


Best regards, 

Olivier



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Principal-in-EJB-returns-always-guest-even-with-JAAS-module-tp4670862.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Principal in EJB returns always "guest" even with JAAS module

Posted by Romain Manni-Bucau <rm...@gmail.com>.
well with a filter when bringing the EjbServlet in your app it can
still be the case (but you are right surely only *my* case, hehe)


Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau


2014-08-06 17:31 GMT+02:00 Jean-Louis Monteiro <jl...@tomitribe.com>:
> yes, right but Olivier was only talking about EJB invocation using remote
> lookup, that's why ;-)
>
> --
> Jean-Louis Monteiro
> http://twitter.com/jlouismonteiro
> http://www.tomitribe.com
>
>
> On Wed, Aug 6, 2014 at 5:23 PM, Romain Manni-Bucau <rm...@gmail.com>
> wrote:
>
>> well depend the usage, can be needed for HttpServletRequest usage
>>
>>
>> Romain Manni-Bucau
>> Twitter: @rmannibucau
>> Blog: http://rmannibucau.wordpress.com/
>> LinkedIn: http://fr.linkedin.com/in/rmannibucau
>> Github: https://github.com/rmannibucau
>>
>>
>> 2014-08-06 17:19 GMT+02:00 Jean-Louis Monteiro <jl...@tomitribe.com>:
>> > Not sure to understand.
>> >
>> > The realmName property in the initial context must be a valid entry in
>> the
>> > jaas.config
>> > Tomcat realm appName when using JAAS realm is also used to retrieve the
>> > entry, but you actually don't need it here.
>> >
>> > --
>> > Jean-Louis Monteiro
>> > http://twitter.com/jlouismonteiro
>> > http://www.tomitribe.com
>> >
>> >
>> > On Wed, Aug 6, 2014 at 4:51 PM, Olivier Paquet <ol...@atos.net>
>> > wrote:
>> >
>> >> Thanks good hint, shoult I put the Reals appName as realmName?
>> >>
>> >> I tried it with PropertiesLoginModule, but it's not working.
>> >>
>> >> This is in my server.xml:
>> >>
>> >>
>> >>
>> >> My InitialContext:
>> >>
>> >>
>> >>
>> >>
>> >>
>> >> --
>> >> View this message in context:
>> >>
>> http://tomee-openejb.979440.n4.nabble.com/Principal-in-EJB-returns-always-guest-even-with-JAAS-module-tp4670862p4670865.html
>> >> Sent from the TomEE Users mailing list archive at Nabble.com.
>> >>
>>

Re: Principal in EJB returns always "guest" even with JAAS module

Posted by Jean-Louis Monteiro <jl...@tomitribe.com>.
yes, right but Olivier was only talking about EJB invocation using remote
lookup, that's why ;-)

--
Jean-Louis Monteiro
http://twitter.com/jlouismonteiro
http://www.tomitribe.com


On Wed, Aug 6, 2014 at 5:23 PM, Romain Manni-Bucau <rm...@gmail.com>
wrote:

> well depend the usage, can be needed for HttpServletRequest usage
>
>
> Romain Manni-Bucau
> Twitter: @rmannibucau
> Blog: http://rmannibucau.wordpress.com/
> LinkedIn: http://fr.linkedin.com/in/rmannibucau
> Github: https://github.com/rmannibucau
>
>
> 2014-08-06 17:19 GMT+02:00 Jean-Louis Monteiro <jl...@tomitribe.com>:
> > Not sure to understand.
> >
> > The realmName property in the initial context must be a valid entry in
> the
> > jaas.config
> > Tomcat realm appName when using JAAS realm is also used to retrieve the
> > entry, but you actually don't need it here.
> >
> > --
> > Jean-Louis Monteiro
> > http://twitter.com/jlouismonteiro
> > http://www.tomitribe.com
> >
> >
> > On Wed, Aug 6, 2014 at 4:51 PM, Olivier Paquet <ol...@atos.net>
> > wrote:
> >
> >> Thanks good hint, shoult I put the Reals appName as realmName?
> >>
> >> I tried it with PropertiesLoginModule, but it's not working.
> >>
> >> This is in my server.xml:
> >>
> >>
> >>
> >> My InitialContext:
> >>
> >>
> >>
> >>
> >>
> >> --
> >> View this message in context:
> >>
> http://tomee-openejb.979440.n4.nabble.com/Principal-in-EJB-returns-always-guest-even-with-JAAS-module-tp4670862p4670865.html
> >> Sent from the TomEE Users mailing list archive at Nabble.com.
> >>
>

Re: Principal in EJB returns always "guest" even with JAAS module

Posted by Romain Manni-Bucau <rm...@gmail.com>.
well depend the usage, can be needed for HttpServletRequest usage


Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau


2014-08-06 17:19 GMT+02:00 Jean-Louis Monteiro <jl...@tomitribe.com>:
> Not sure to understand.
>
> The realmName property in the initial context must be a valid entry in the
> jaas.config
> Tomcat realm appName when using JAAS realm is also used to retrieve the
> entry, but you actually don't need it here.
>
> --
> Jean-Louis Monteiro
> http://twitter.com/jlouismonteiro
> http://www.tomitribe.com
>
>
> On Wed, Aug 6, 2014 at 4:51 PM, Olivier Paquet <ol...@atos.net>
> wrote:
>
>> Thanks good hint, shoult I put the Reals appName as realmName?
>>
>> I tried it with PropertiesLoginModule, but it's not working.
>>
>> This is in my server.xml:
>>
>>
>>
>> My InitialContext:
>>
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://tomee-openejb.979440.n4.nabble.com/Principal-in-EJB-returns-always-guest-even-with-JAAS-module-tp4670862p4670865.html
>> Sent from the TomEE Users mailing list archive at Nabble.com.
>>

Re: Principal in EJB returns always "guest" even with JAAS module

Posted by Jean-Louis Monteiro <jl...@tomitribe.com>.
Not sure to understand.

The realmName property in the initial context must be a valid entry in the
jaas.config
Tomcat realm appName when using JAAS realm is also used to retrieve the
entry, but you actually don't need it here.

--
Jean-Louis Monteiro
http://twitter.com/jlouismonteiro
http://www.tomitribe.com


On Wed, Aug 6, 2014 at 4:51 PM, Olivier Paquet <ol...@atos.net>
wrote:

> Thanks good hint, shoult I put the Reals appName as realmName?
>
> I tried it with PropertiesLoginModule, but it's not working.
>
> This is in my server.xml:
>
>
>
> My InitialContext:
>
>
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/Principal-in-EJB-returns-always-guest-even-with-JAAS-module-tp4670862p4670865.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>

Re: Principal in EJB returns always "guest" even with JAAS module

Posted by Romain Manni-Bucau <rm...@gmail.com>.
I think so, should match the name you use in config.login


Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau


2014-08-06 16:51 GMT+02:00 Olivier Paquet <ol...@atos.net>:
> Thanks good hint, shoult I put the Reals appName as realmName?
>
> I tried it with PropertiesLoginModule, but it's not working.
>
> This is in my server.xml:
>
>
>
> My InitialContext:
>
>
>
>
>
> --
> View this message in context: http://tomee-openejb.979440.n4.nabble.com/Principal-in-EJB-returns-always-guest-even-with-JAAS-module-tp4670862p4670865.html
> Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Principal in EJB returns always "guest" even with JAAS module

Posted by Romain Manni-Bucau <rm...@gmail.com>.
actually once you created sample it was fast to run ;). Thanks you too
for it BTW


Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau


2014-09-04 17:54 GMT+02:00 Olivier Paquet <ol...@atos.net>:
> Oh my God  that's it! Thanks for the time you dedicated to this issue...
>
>
> Thank you Romain! You can close this thread now ;)
>
> Greetings, Olivier
>
>
>
> --
> View this message in context: http://tomee-openejb.979440.n4.nabble.com/Principal-in-EJB-returns-always-guest-even-with-JAAS-module-tp4670862p4671645.html
> Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Principal in EJB returns always "guest" even with JAAS module

Posted by Olivier Paquet <ol...@atos.net>.
Oh my God  that's it! Thanks for the time you dedicated to this issue...  


Thank you Romain! You can close this thread now ;) 

Greetings, Olivier



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Principal-in-EJB-returns-always-guest-even-with-JAAS-module-tp4670862p4671645.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Principal in EJB returns always "guest" even with JAAS module

Posted by Romain Manni-Bucau <rm...@gmail.com>.
PS: last sentence meant instead of java:global/.... use global/....
and it should work


Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau


2014-09-04 17:09 GMT+02:00 Romain Manni-Bucau <rm...@gmail.com>:
> Ok
>
> issue is you are in tomee and new InitialContext is not resolved to
> remote context but to local one cause the name starts with java:.
>
>
> Romain Manni-Bucau
> Twitter: @rmannibucau
> Blog: http://rmannibucau.wordpress.com/
> LinkedIn: http://fr.linkedin.com/in/rmannibucau
> Github: https://github.com/rmannibucau
>
>
> 2014-09-04 17:03 GMT+02:00 Romain Manni-Bucau <rm...@gmail.com>:
>> just curious: did you try 2 tomee instances?
>>
>>
>> Romain Manni-Bucau
>> Twitter: @rmannibucau
>> Blog: http://rmannibucau.wordpress.com/
>> LinkedIn: http://fr.linkedin.com/in/rmannibucau
>> Github: https://github.com/rmannibucau
>>
>>
>> 2014-09-04 14:55 GMT+02:00 Olivier Paquet <ol...@atos.net>:
>>> CATALINA_OPTS is also not working(Linux / Windows), I mean if I provide a bad
>>> password it fails, but principal is not handed over to the EJB.
>>>
>>> Any other hints?
>>> Bad Java version (using jdk1.7.0_51)...
>>>
>>>
>>>
>>>
>>>
>>> --
>>> View this message in context: http://tomee-openejb.979440.n4.nabble.com/Principal-in-EJB-returns-always-guest-even-with-JAAS-module-tp4670862p4671622.html
>>> Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Principal in EJB returns always "guest" even with JAAS module

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Ok

issue is you are in tomee and new InitialContext is not resolved to
remote context but to local one cause the name starts with java:.


Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau


2014-09-04 17:03 GMT+02:00 Romain Manni-Bucau <rm...@gmail.com>:
> just curious: did you try 2 tomee instances?
>
>
> Romain Manni-Bucau
> Twitter: @rmannibucau
> Blog: http://rmannibucau.wordpress.com/
> LinkedIn: http://fr.linkedin.com/in/rmannibucau
> Github: https://github.com/rmannibucau
>
>
> 2014-09-04 14:55 GMT+02:00 Olivier Paquet <ol...@atos.net>:
>> CATALINA_OPTS is also not working(Linux / Windows), I mean if I provide a bad
>> password it fails, but principal is not handed over to the EJB.
>>
>> Any other hints?
>> Bad Java version (using jdk1.7.0_51)...
>>
>>
>>
>>
>>
>> --
>> View this message in context: http://tomee-openejb.979440.n4.nabble.com/Principal-in-EJB-returns-always-guest-even-with-JAAS-module-tp4670862p4671622.html
>> Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Principal in EJB returns always "guest" even with JAAS module

Posted by Romain Manni-Bucau <rm...@gmail.com>.
just curious: did you try 2 tomee instances?


Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau


2014-09-04 14:55 GMT+02:00 Olivier Paquet <ol...@atos.net>:
> CATALINA_OPTS is also not working(Linux / Windows), I mean if I provide a bad
> password it fails, but principal is not handed over to the EJB.
>
> Any other hints?
> Bad Java version (using jdk1.7.0_51)...
>
>
>
>
>
> --
> View this message in context: http://tomee-openejb.979440.n4.nabble.com/Principal-in-EJB-returns-always-guest-even-with-JAAS-module-tp4670862p4671622.html
> Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Principal in EJB returns always "guest" even with JAAS module

Posted by Olivier Paquet <ol...@atos.net>.
CATALINA_OPTS is also not working(Linux / Windows), I mean if I provide a bad
password it fails, but principal is not handed over to the EJB. 

Any other hints?
Bad Java version (using jdk1.7.0_51)...





--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Principal-in-EJB-returns-always-guest-even-with-JAAS-module-tp4670862p4671622.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Principal in EJB returns always "guest" even with JAAS module

Posted by Romain Manni-Bucau <rm...@gmail.com>.
set CATALINA_OPTS instead of set JAVA_OPTS maybe ;)


Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau


2014-09-04 14:02 GMT+02:00 Olivier Paquet <ol...@atos.net>:
> And in catalina.out it logs "-sayHello invoked by [admin]" ? I also tried is
> now on a linux, but still the same result.
>
> I uploaded my TomEE : perhaps you can check it also?
>
> http://we.tl/oVg9302BKP  it's a exact copy , just add the setenv.sh and
> start it ;)
>
> Can you provide me the content of your setenv.sh pls?
>
>
>
>
>
> --
> View this message in context: http://tomee-openejb.979440.n4.nabble.com/Principal-in-EJB-returns-always-guest-even-with-JAAS-module-tp4670862p4671608.html
> Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Principal in EJB returns always "guest" even with JAAS module

Posted by Olivier Paquet <ol...@atos.net>.
And in catalina.out it logs "-sayHello invoked by [admin]" ? I also tried is
now on a linux, but still the same result. 

I uploaded my TomEE : perhaps you can check it also?

http://we.tl/oVg9302BKP  it's a exact copy , just add the setenv.sh and
start it ;)

Can you provide me the content of your setenv.sh pls?





--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Principal-in-EJB-returns-always-guest-even-with-JAAS-module-tp4670862p4671608.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Principal in EJB returns always "guest" even with JAAS module

Posted by Romain Manni-Bucau <rm...@gmail.com>.
tested on linux with setenv.sh but otherwise no changes


Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau


2014-09-04 13:06 GMT+02:00 Olivier Paquet <ol...@atos.net>:
> Ok strange, I tested it with the new TomEE 1.7.0 plus but I still got guest,
> and you just configured it as I described in my Email or is there something
> I forgot?
>
>
>
> --
> View this message in context: http://tomee-openejb.979440.n4.nabble.com/Principal-in-EJB-returns-always-guest-even-with-JAAS-module-tp4670862p4671599.html
> Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Principal in EJB returns always "guest" even with JAAS module

Posted by Olivier Paquet <ol...@atos.net>.
Ok strange, I tested it with the new TomEE 1.7.0 plus but I still got guest,
and you just configured it as I described in my Email or is there something
I forgot? 



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Principal-in-EJB-returns-always-guest-even-with-JAAS-module-tp4670862p4671599.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Principal in EJB returns always "guest" even with JAAS module

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi

your sample works in 1.7.0


Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau


2014-09-04 11:08 GMT+02:00 Olivier Paquet <ol...@atos.net>:
> I also uploaded the both war files ;)
>
> ejb-remote.war
> <http://tomee-openejb.979440.n4.nabble.com/file/n4671592/ejb-remote.war>
>
> and  ejb-client.war
> <http://tomee-openejb.979440.n4.nabble.com/file/n4671592/ejb-client.war>
>
>
>
> --
> View this message in context: http://tomee-openejb.979440.n4.nabble.com/Principal-in-EJB-returns-always-guest-even-with-JAAS-module-tp4670862p4671592.html
> Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Principal in EJB returns always "guest" even with JAAS module

Posted by Olivier Paquet <ol...@atos.net>.
I also uploaded the both war files ;)

ejb-remote.war
<http://tomee-openejb.979440.n4.nabble.com/file/n4671592/ejb-remote.war>  

and  ejb-client.war
<http://tomee-openejb.979440.n4.nabble.com/file/n4671592/ejb-client.war>  



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Principal-in-EJB-returns-always-guest-even-with-JAAS-module-tp4670862p4671592.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Principal in EJB returns always "guest" even with JAAS module

Posted by Olivier Paquet <ol...@atos.net>.
ejb-security.zip
<http://tomee-openejb.979440.n4.nabble.com/file/n4671591/ejb-security.zip>  

server.xml:

<Realm className="org.apache.catalina.realm.JAASRealm"
appName="PropertiesLogin"
         
userClassNames="org.apache.openejb.core.security.AbstractSecurityService$User"
         
roleClassNames="org.apache.openejb.core.security.AbstractSecurityService$Group">
      </Realm>

login.config
<http://tomee-openejb.979440.n4.nabble.com/file/n4671591/login.config>  
users.properties
<http://tomee-openejb.979440.n4.nabble.com/file/n4671591/users.properties>  
groups.properties
<http://tomee-openejb.979440.n4.nabble.com/file/n4671591/groups.properties>  

added "-Djava.security.auth.login.config=$CATALINA_BASE/conf/login.config"
to setenv.bat

After deploying both war archives, just call: 

http://localhost:TOMEE_PORT/ejb-client/clientservice?host=localhost&port=TOMEE_PORT&user=admin&pass=changeit

And you should see in the logs, that the remote EJB is called with a
principal named "guest" and not admin .

It would be very nice and helpful if you cna take a look at my examples, I
packaged both archives as maven projects, so you can also check the sources.

Our aim is that we need the name of the principal which call the EJB,
because we do some further checks on it.


Best regards, Olivier



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Principal-in-EJB-returns-always-guest-even-with-JAAS-module-tp4670862p4671591.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Principal in EJB returns always "guest" even with JAAS module

Posted by Romain Manni-Bucau <rm...@gmail.com>.
if you don't set webapp security (in web.xml) then tomcat is not used
for security but just jaas (through openejb). So no log is normal.

Best would surely be to reproduce it to let us dig into your particular issue


Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau


2014-08-07 10:42 GMT+02:00 Olivier Paquet <ol...@atos.net>:
> And the EJB Servlet is deployed with my application :
>
>
>
>
>
> --
> View this message in context: http://tomee-openejb.979440.n4.nabble.com/Principal-in-EJB-returns-always-guest-even-with-JAAS-module-tp4670862p4670895.html
> Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Principal in EJB returns always "guest" even with JAAS module

Posted by Olivier Paquet <ol...@atos.net>.
And the EJB Servlet is deployed with my application :





--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Principal-in-EJB-returns-always-guest-even-with-JAAS-module-tp4670862p4670895.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Principal in EJB returns always "guest" even with JAAS module

Posted by Olivier Paquet <ol...@atos.net>.
And I provide an incorrect password for the remote lookup, so it shoudl fail
somewhere I would say...



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Principal-in-EJB-returns-always-guest-even-with-JAAS-module-tp4670862p4670894.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Principal in EJB returns always "guest" even with JAAS module

Posted by Andy Gumbrecht <ag...@tomitribe.com>.
Hi Olivier,

Did this discussion resolve the issue for you?

Andy

-- 
   Andy Gumbrecht

   http://www.tomitribe.com
   agumbrecht@tomitribe.com
   https://twitter.com/AndyGeeDe

   TomEE treibt Tomitribe! | http://tomee.apache.org


Re: Principal in EJB returns always "guest" even with JAAS module

Posted by Olivier Paquet <ol...@atos.net>.
Thanks good hint, shoult I put the Reals appName as realmName? 

I tried it with PropertiesLoginModule, but it's not working.

This is in my server.xml:



My InitialContext:





--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Principal-in-EJB-returns-always-guest-even-with-JAAS-module-tp4670862p4670865.html
Sent from the TomEE Users mailing list archive at Nabble.com.

Re: Principal in EJB returns always "guest" even with JAAS module

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi

here is a sample initial context init:

final Context context = new InitialContext(new Properties() {{
                put(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.client.RemoteInitialContextFactory);
                put(Context.PROVIDER_URL, "http://localhost:8080/tomee/ejb");
                put("java.naming.security.principal", "foo");
                put("java.naming.security.credentials", "bar");
                put("openejb.authentication.realmName", "FooBar");

                put("openejb.ejbd.authenticate-with-request", "true");
            }});

Maybe you forget realmName property and then use the default realm?



Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau


2014-08-06 16:18 GMT+02:00 Jean-Louis Monteiro <jl...@tomitribe.com>:
> Can you provide us with the InitialContext creation?
>
> You should do before calling new InitialContext (...)
> And provide some properties.
>
> Jean-Louis
>
> --
> Jean-Louis Monteiro
> http://twitter.com/jlouismonteiro
> http://www.tomitribe.com
>
>
> On Wed, Aug 6, 2014 at 4:12 PM, Olivier Paquet <ol...@atos.net>
> wrote:
>
>> Hi,
>>
>> Unfortunately even when following the way of other solutions found on this
>> forum, using JAAS or putting
>> p.put("openejb.ejbd.authenticate-with-request",
>> "true"); in remote lookup properties, I'm getting always the principal
>> "guest" in my EJB using EJBContext.getCallerPrincipal().
>>
>> I use the TomEE 1.7.0-SNAPSHOT version and I defined the JAAS module a
>> mentionned here
>> (http://rmannibucau.wordpress.com/2012/05/09/tomee-and-its-ssh-connector/)
>> ,
>> before I tried the JDBCRealm and so on, but result is still the same ->
>> guest
>>
>> I'm calling my remote EJB as follow:
>>
>>
>> It always works fine, I could see in the console(with JDBCRealm and
>> DatasourceRealm) that the correct EJB User has been authenticated, but in
>> my
>> EJB the user is always guest and my @RolesAllowed does not work.
>>
>> Any hints how to solve this issue?
>>
>>
>> Best regards,
>>
>> Olivier
>>
>>
>>
>> --
>> View this message in context:
>> http://tomee-openejb.979440.n4.nabble.com/Principal-in-EJB-returns-always-guest-even-with-JAAS-module-tp4670862.html
>> Sent from the TomEE Users mailing list archive at Nabble.com.
>>

Re: Principal in EJB returns always "guest" even with JAAS module

Posted by Jean-Louis Monteiro <jl...@tomitribe.com>.
Can you provide us with the InitialContext creation?

You should do before calling new InitialContext (...)
And provide some properties.

Jean-Louis

--
Jean-Louis Monteiro
http://twitter.com/jlouismonteiro
http://www.tomitribe.com


On Wed, Aug 6, 2014 at 4:12 PM, Olivier Paquet <ol...@atos.net>
wrote:

> Hi,
>
> Unfortunately even when following the way of other solutions found on this
> forum, using JAAS or putting
> p.put("openejb.ejbd.authenticate-with-request",
> "true"); in remote lookup properties, I'm getting always the principal
> "guest" in my EJB using EJBContext.getCallerPrincipal().
>
> I use the TomEE 1.7.0-SNAPSHOT version and I defined the JAAS module a
> mentionned here
> (http://rmannibucau.wordpress.com/2012/05/09/tomee-and-its-ssh-connector/)
> ,
> before I tried the JDBCRealm and so on, but result is still the same ->
> guest
>
> I'm calling my remote EJB as follow:
>
>
> It always works fine, I could see in the console(with JDBCRealm and
> DatasourceRealm) that the correct EJB User has been authenticated, but in
> my
> EJB the user is always guest and my @RolesAllowed does not work.
>
> Any hints how to solve this issue?
>
>
> Best regards,
>
> Olivier
>
>
>
> --
> View this message in context:
> http://tomee-openejb.979440.n4.nabble.com/Principal-in-EJB-returns-always-guest-even-with-JAAS-module-tp4670862.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>