Glassfish v3 EJB + JAAS

1 resposta
C

Pessoal,

tenho um projeto web autenticando com jaas usando loginmodule e um projeto EJB.

tudo rodando local ele funciona getContext().getCallerPrincipal().getName() retorna o login.

rodando o ejb em outra máquina o getContext().getCallerPrincipal().getName() retorna branco

o que poderia ser?

1 Resposta

C

Adicionei as propriedades que encontrei no site do glassfish
https://glassfish.dev.java.net/javaee5/security/faq.html e agora está dando o seguinte erro

Failed to load com.sun.enterprise.naming.SerialInitContextFactory using CommonClassLoader

Sem as propriedades ele realiza o lookup porém getContext().getCallerPrincipal().getName() retorna branco

ps.
estou usando Custom login module
com.sun.appserv.security.AppservPasswordLoginModule

public static <T> T lookup(Class<T> ejbInterface) {
		if (ejbInterface == null) {
			throw new IllegalArgumentException("No EJBInterface specified");
		}

		try {
		       Properties properties = new Properties();
		        properties.setProperty("java.naming.factory.initial", "com.sun.enterprise.naming.SerialInitContextFactory");
 
		        properties.setProperty("java.naming.factory.url.pkgs", "com.sun.enterprise.naming");

		        properties.setProperty("java.naming.factory.state",
				"com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");

		        properties.setProperty("org.omg.CORBA.ORBInitialHost", host);
		        properties.setProperty("org.omg.CORBA.ORBInitialPort", port);
			Object bean = context.lookup(getJndi(ejbInterface));
			return ejbInterface.cast(PortableRemoteObject.narrow(bean, ejbInterface));
		} catch (NamingException e) {
			throw new IllegalStateException("Cannot connect to bean: " + ejbInterface.getName() + " Reason: " + e,
					e.getCause());
		} finally {
			try {
				context.close();
				properties = null;
			} catch (NamingException ex) {
				throw new IllegalStateException("Cannot close InitialContext. Reason: " + ex, ex.getCause());
			}
		}

	}
Criado 16 de agosto de 2010
Ultima resposta 16 de ago. de 2010
Respostas 1
Participantes 1