Ciao ragazzi,
sto tentando di proteggere un EJB in questo modo:

@Stateless
public class MySessionBean implements MySessionBeanRemote, MySessionBeanLocal {

@Resource SessionContext context;

public MySessionBean() {
// TODO Auto-generated constructor stub
}

@RolesAllowed("MAGNUS")
public long getTime() throws SecurityException{
return System.currentTimeMillis();
}
}

Ma utilizzando un client del tipo:

context = new InitialContext(properties);
MySessionBeanRemote bean = (MySessionBeanRemote)context.
lookup("MySessionBean/remote");
long time=bean.getTime();
System.out.println("MySessionBean.getTime() dice: " + new Date(time));

Non ho nessuna difficoltà ad utilizzare il metodo senza autenticazione.

Come fare per richiedere l'autenticazione all'accesso del bean?

Ciao!