tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Blevins <david.blev...@visi.com>
Subject Re: Antwort: Re: Using OpenEJB Security for JAAS LoginModule
Date Mon, 09 Jun 2008 20:55:10 GMT

On Jun 9, 2008, at 5:26 AM, Josef.Eisele@bgs-ag.de wrote:

> Hi David,
>
> thank you very much for the link. I got it twice and I read it  
> twice ;-)
> but it doesn't help concerning my actual problem.
>
> To run our business code it is necessary to login into an
> 'SecurityService' with user/password/realm and as result there must  
> be a
> Secuity-Object (javax.security.auth.Subject). This Security-Object is
> nessary to invoke our business code. The magic @RunAs("Employee")won't
> work in our case.

If you could give me some more detail here, that'd be great.  Both  
login and runas result in a javax.security.auth.Subject being created  
by and enforced by the SecurityService.  The creation is slightly  
different, but the subject is tracked and enforced by the  
SecurityService in exactly the same way.

If you have any sample code on what doesn't work that would also be  
helpful.

> The default implementation from the security service with the  
> parameters
> user/password is fine, but we miss the realm-Parameter. And if we  
> add it,
> the Security Service says
>
> Exception bei Login:Fr vesuv-db-sha256 sind keine Anmeldemodule
> konfiguriert.
>
> Anmeldemodule = Login module

The realm in OpenEJB refers to the JAAS LoginModule.  The login module  
that is setup in the SecurityServices login.config file is called  
"PropertiesLogin".  This is the default value for realm when left  
unspecified.

If you have a custom javax.security.auth.spi.LoginModule there is a  
way to set one up.  Let me know if that is what you're trying to do  
and I'll see if I can get an example working.

-David


>
>
>
> cu Josef
>
>
>
>
>
> David Blevins <david.blevins@visi.com>
> 06.06.2008 23:06
> Bitte antworten an
> users@openejb.apache.org
>
>
> An
> users@openejb.apache.org
> Kopie
>
> Thema
> Re: Using OpenEJB Security for JAAS LoginModule
>
>
>
>
>
>
> Hi Josef,
>
> Looks this post arrived at about the same time as my last response, so
> this might be repeat information :)
>
> This example shows a good technique for unit testing various security
> permissions.
>
>   http://openejb.apache.org/3.0/testing-security-example.html
>
> The JNDI login approach isn't really optimal as there is no "logout"
> option and it tends to make a mess of things.  With the above approach
> you can wrap your calls with any security context you like and test
> accessing your bean via secured and unsecured "clients" and check that
> permissions for various roles are as they need to be.
>
> -David
>
>
> On Jun 6, 2008, at 1:24 AM, Josef.Eisele@bgs-ag.de wrote:
>
>> Hi All,
>>
>> we use embedded openejb to test our JavaEE-5 (Geronimo App.server)
>> Application. With the great help of David Blevins the JUNIT-Tests can
>> invoke our session beans and even Transaction Handling is working
>> fine.
>> At the moment I use a trick to avoid the Login-Procedure, but this
>> won't
>> work on the long run.
>>
>> With Geronimo 2.1.1 we use the JAAS API. Our usage is described in
>> http://cwiki.apache.org/GMOxDOC10/geronimo-and-jaas.html. For my
>> junit-testcase I need therefore anything which can provide me a
>> javax.security.auth.Subject after successful login. With the  
>> default -
>> Security Service
>> <SecurityService id="Default Security Service"/>
>> and the configuration in users.properties and groups.properties I
>> get the
>> error:
>>
>> Exception bei Login:Fr vesuv-db-sha256 sind keine Anmeldemodule
>> konfiguriert.
>>
>> (Anmeldemodule = security realm, I think...)
>>
>> I tried also PseudoSecurityService, but I got an exception as well.
>>
>> JUNIT-Testcase
>>                               Properties properties = new
>> Properties();
>> ....
>>               // Minimum required for login
>>               properties.setProperty(Context.SECURITY_PRINCIPAL,
>> benutzer);
>>               properties.setProperty(Context.SECURITY_CREDENTIALS,
>> passwort);
>>
>>               // Optional param for specifying a specific Geronimo
>> security realm
>>               properties.put("openejb.authentication.realmName",
>> "vesuv-db-sha256");
>>
>>               properties.put("mySecurityService",
>> "new://PseudoSecurityService");
>> ....
>>                       loginManager = (LoginManager)
>> initialContext.lookup("LoginManagerImplLocal");
>>                       loginManager.loginContainer(benutzer,
>> passwort);
>> ....
>>
>> LoginManager-Session Bean:
>> ...
>>               try {
>>                       LoginCallback logcb = new
>> LoginCallback(benutzer,
>> passwort);
>>                       LoginContext lc = new
>> LoginContext("vesuv-db-sha256",logcb);
>>                       lc.login();
>>                       subject = lc.getSubject();
>>               }
>> ...
>>
>> The realm "vesuv-db-sha256" is defined under
>> Geronimo-Applicationserver-Console Security - Security Realms.
>>
>> I read  http://openejb.apache.org/3.0/security.html, but I don't
>> understand how to configure the Security for embedded openejb.
>>
>> Thanx in advance for any help on this.
>>
>> Mit freundlichen Grüßen / Kind regards
>> Josef Eisele
>>
>> Direkt: +49 (0) 6131 / 914-180
>>
>> BGS Beratungsgesellschaft
>> Software Systemplanung AG         Niederlassung Rhein/Main
>> Robert-Koch-Straße 41
>> 55129 Mainz
>> Fon: +49 (0) 6131 / 914-0
>> Fax: +49 (0) 6131 / 914-400
>> www.bgs-ag.de Geschäftssitz Mainz
>> Registergericht
>> Amtsgericht Mainz
>> HRB 62 50
>> Aufsichtsratsvorsitzender
>> Dr. Wolfgang Trommer
>> Vorstand
>> Hanspeter Gau
>> Hermann Kiefer
>> Nils Manegold
>> Heinz-Jörg Zimmermann
>>
>>
>
>
>
> BGS Beratungsgesellschaft
> Software Systemplanung AG
>
>
>
>
> Niederlassung Rhein/Main
> Robert-Koch-Straße 41
> 55129 Mainz
> Fon: +49 (0) 6131 / 914-0
> Fax: +49 (0) 6131 / 914-400
> www.bgs-ag.de
> Geschäftssitz Mainz
> Registergericht
> Amtsgericht Mainz
> HRB 62 50
>
> Aufsichtsratsvorsitzender
> Dr. Wolfgang Trommer
> Vorstand
> Hanspeter Gau
> Hermann Kiefer
> Nils Manegold
> Heinz-Jörg Zimmermann
>
>


Mime
View raw message