[jboss-user] [EJB 3.0] - Re: RolesAllowed causes exception on client with JBoss5

draganj do-not-reply at jboss.com
Wed Jan 28 08:16:36 EST 2009


Hello,

Here it is.
Client

  | public class TestStatelessClient 
  | {
  | 	public static void main(String[] args) throws Exception
  | 	{
  | 		Properties p = new Properties();
  | 		//p.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
  | 		p.setProperty("java.naming.factory.initial", "org.jboss.security.jndi.JndiLoginInitialContextFactory");
  | 		p.setProperty("java.naming.provider.url","localhost:1099");
  | 		p.setProperty("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
  | 		p.setProperty(Context.SECURITY_PRINCIPAL, "kermit");
  | 	    p.setProperty(Context.SECURITY_CREDENTIALS, "thefrog");
  | 		InitialContext ctx = new InitialContext(p);
  | 		IHelloWorld hw = (IHelloWorld) ctx.lookup("HelloWorldBean/remote");
  | 
  | 		System.out.println("Got " + hw.helloWorld("Hello server"));
  | 	}
  | }
  | 

Server:

  | package test.ejb.stateless;
  | 
  | import javax.annotation.security.RolesAllowed;
  | import javax.ejb.Remote;
  | import javax.ejb.Stateless;
  | 
  | import org.jboss.ejb3.annotation.SecurityDomain;
  | 
  | 
  | @Stateless
  | @SecurityDomain("JBossWS")
  | @Remote(IHelloWorld.class)
  | public class HelloWorldBean implements IHelloWorld
  | {
  | 	@RolesAllowed({"friend"})
  | 	public String helloWorld(String in) 
  | 	{
  | 		System.out.println("Got " + in);
  | 		return "Hello Client";
  | 	}
  | }
  | 
jboss.xml:

  | ?xml version="1.0"?>
  | <jboss>
  |     <security-domain>JBossWS</security-domain>
  | </jboss>
  | 

I used JBossWS security domain.

Regards,
Dragan

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4205231#4205231

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4205231



More information about the jboss-user mailing list