You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@geronimo.apache.org by yellowb <ye...@hotmail.fr> on 2010/12/02 17:26:56 UTC

javax.ejb.EJBAccessException - Unauthorized Access by Principal Denied

Hi,

I'm trying to use authenticated remote ejb but it always fails with the
exception javax.ejb.EJBAccessException - Unauthorized Access by Principal
Denied

I've been browsing the web alot but I didn't found a solution.

i'm using Geronimo 2.1.7

here is the bean :

@Stateless
@DeclareRoles({"admin"})
@RolesAllowed({"admin"})
public class UserBean implements UserBeanRemote, UserBeanLocal {

    public UserBean() {
    }
   
    public String getName() {
    return "plout" ;
    }

}


Here is the client :

public class User {
        private String name="";

           public String getName() {
                   return name ;
           }

           public void setName(String name) {
              String n = "";
                        try {
                                Properties prop = new Properties();
                                prop.put("java.naming.factory.initial",
"org.apache.openejb.client.RemoteInitialContextFactory");
                                prop.put("java.naming.provider.url",
"ejbd://localhost:4201");
                                Context ctx= new InitialContext(prop);
                               
prop.setProperty("openejb.authentication.realmName", "geronimo-admin");
                               
prop.setProperty("java.naming.security.principal", "system");
                               
prop.setProperty("java.naming.security.credentials", "manager");
                                UserBeanRemote
u1=(UserBeanRemote)ctx.lookup("UserBeanRemote");
                                n = u1.getName();
                        } catch (NamingException ne) {
                                System.out.println(ne.toString());
                        }
                        this.name = n ;
           }
}

Here is the openejb-jar.xml :

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<ejb:openejb-jar
        xmlns:app="http://geronimo.apache.org/xml/ns/j2ee/application-2.0"
       
xmlns:client="http://geronimo.apache.org/xml/ns/j2ee/application-client-2.0"
        xmlns:conn="http://geronimo.apache.org/xml/ns/j2ee/connector-1.2"
        xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.2"
        xmlns:ejb="http://openejb.apache.org/xml/ns/openejb-jar-2.2"
        xmlns:log="http://geronimo.apache.org/xml/ns/loginconfig-2.0"
        xmlns:name="http://geronimo.apache.org/xml/ns/naming-1.2"
        xmlns:pers="http://java.sun.com/xml/ns/persistence"
        xmlns:pkgen="http://openejb.apache.org/xml/ns/pkgen-2.1"
        xmlns:sec="http://geronimo.apache.org/xml/ns/security-2.0"
        xmlns:web="http://geronimo.apache.org/xml/ns/j2ee/web-2.0.1">
    <dep:environment>
        <dep:moduleId>
            <dep:groupId>default</dep:groupId>
            <dep:artifactId>pkb-ejb</dep:artifactId>
            <dep:version>1.0</dep:version>
            <dep:type>car</dep:type>
       </dep:moduleId>
    </dep:environment>
        <sec:security>
                <sec:role-mappings>
                        <sec:role role-name="admin">
                                <sec:principal
class="org.apache.geronimo.security.realm.providers.GeronimoGroupPrincipal"
name="admin"/>
                        </sec:role>
    </sec:role-mappings>
        </sec:security>
</ejb:openejb-jar>


Do you know where the problem come from or where I can find a good
documentation ?


Thanks


-- 
View this message in context: http://apache-geronimo.328035.n3.nabble.com/javax-ejb-EJBAccessException-Unauthorized-Access-by-Principal-Denied-tp2006827p2006827.html
Sent from the Users mailing list archive at Nabble.com.

Re: javax.ejb.EJBAccessException - Unauthorized Access by Principal Denied

Posted by "viola.lu" <vi...@gmail.com>.
You can refer to geronimo sample DataCDInfo
https://svn.apache.org/repos/asf/geronimo/samples/branches/2.1/samples/DataCDInfo/DataCDInfo-JTA-ejb/src/main/java/org/apache/geronimo/samples/datacdinfo/core/DataCDInfoAdmin.java
which also used the ejb security. 
Good Luck!
-- 
View this message in context: http://apache-geronimo.328035.n3.nabble.com/javax-ejb-EJBAccessException-Unauthorized-Access-by-Principal-Denied-tp2006827p2009511.html
Sent from the Users mailing list archive at Nabble.com.