[jboss-user] [EJB 3.0] - EJB 3.0 and Authorization

slavago do-not-reply at jboss.com
Thu Aug 24 10:50:04 EDT 2006


Hi.
I have ejb 3.0 bean:

package org;

import javax.annotation.security.DenyAll;
import javax.annotation.security.RolesAllowed;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;




@Stateless
public class ProcessPaymentBean implements ProcessPaymentRemote{
	public ProcessPaymentBean () {
		int a= 1;
	}
	
	@PersistenceContext(name = "Context")
	private EntityManager em;
	
	
/*	private void setEm(EntityManager em) {
		this.em = em;
	}
*/	 
	@DenyAll
	public int test1(int a) {
		int res = 0;
		if (em == null) {
			return 0;
		}
		Provider prov = new Provider();
		prov.setProviderName("zohar");
		prov.setCredentials("password");
		
		try {
			em.persist(prov);
		}
		catch (Exception e) {
			res = 2;
		}
		res = 1;
		return res;
	}
}

and client that wants to access this bean:

public class MyTest {
	  public static void main(String[] args){	
		  EntityManager em = null;
		  try{
			  Context jndiContext = getInitialContext();			
			  ProcessPaymentRemote ref = (ProcessPaymentRemote)jndiContext.lookup(("ProcessPaymentBean/remote"));
			  int res = ref.test1(1);
			  
			  int a =1;
		  }
		  catch (Throwable e) {
			e.printStackTrace();
		}
		  
	  }
	  
	  public static Context getInitialContext() throws NamingException{
		  Properties p = new Properties();		  		
		  p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
		  p.put(Context.URL_PKG_PREFIXES, "org.jboss.naming;org.jnp.interfaces");
		  p.put(Context.PROVIDER_URL, "jnp://localhost:1099");		   		  
		  return new InitialContext( p );
  
	  }
	  
}

And, when i'm execuyting my client, there is no access execption is thrown. everything is executed like no @denyall defined.

What i do wrong and what i need to configure, may be i missing something.

Or may be i can download some Jboss 4.0.4 (Ejb 3.0) authorization example ?


Thank You.

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

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



More information about the jboss-user mailing list