tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From J.M. Villagrá <villa...@gmail.com>
Subject Re: Set up a custom LoginModule
Date Fri, 11 Jun 2010 10:55:57 GMT
I found the error...
login.config has to be in :

openejb.home/conf

not in:

openejb.home/config


Now i have another problem...  althought the login is succesfully i'm always
getting "guest" as the Principal:

@Stateless(name=SecurityService.BEANNAME)
public class TestBean implements Test {

@PersistenceContext(unitName = "Entities")
private EntityManager _em;

@Resource
private SessionContext session;

        @Override
public void test(){

        Principal p =  session.getCallerPrincipal();
        //p = "guest"

}

}

Any tip? Thanks


On Fri, Jun 11, 2010 at 11:39 AM, J.M. Villagrá <villagra@gmail.com> wrote:

> Hi All,
>   We're using openejb to do some tests of our ejbs, but now, i want to use
> our custom LoginModule and i dont know how to configure it in openEJB....
>
>   I've created the file openejb.home/config/login.config like this:
>
> TestName {
>    com.test.TestLoginModule required debug=true;
> };
>
> And, in the context initialization i have this properties:
>
> Properties props = new Properties();
> props.setProperty(Context.INITIAL_CONTEXT_FACTORY,
> "org.apache.openejb.client.LocalInitialContextFactory");
> props.put("openejb.authentication.realmName", "TestName");
> props.put("Entities", "new://Resource?type=DataSource");
> props.put("Entities.JdbcDriver", "org.postgresql.Driver");
> props.put("Entities.JdbcUrl", "jdbc:postgresql://localhost:5432/......");
> props.put("Entities.Password", "....");
> props.put("hibernate.dialect", "org.hibernate.dialect.PostgreSQLDialect");
>
> context = new InitialContext(props);
>
> Do i need any other configuration file??
> If i try to do a login i get an error:
>
> LoginContext lc = new LoginContext("¿TestName?");
> lc.login();
>
> javax.security.auth.login.LoginException: No se han configurado
> LoginModules para TestName
> at javax.security.auth.login.LoginContext.init(LoginContext.java:256)
>  at javax.security.auth.login.LoginContext.<init>(LoginContext.java:334)
> at
> com.ensenia.server.ejb.SchoolServiceBeanTests.userCrudOperations(SchoolServiceBeanTests.java:38)
>  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>  at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
>  at
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
> at
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
>  at
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
> at
> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
>  at
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
> at
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
>  at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
> at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
>  at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
> at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
>  at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
> at
> org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
>  at
> org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
> at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
>  at
> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
> at
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>  at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
>  at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
>
>
> Thank you very much.
>
> --
> Jose
>



-- 
Jose

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message