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: Using OpenEJB Security for JAAS LoginModule
Date Fri, 06 Jun 2008 21:05:07 GMT
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
>
>


Mime
View raw message