Здравствуйте,столкнулся с проблемой аутентификации при работе с EJB в GlassFish. Имеются два инстанса сервера, на втором ("удаленном") имеется компонент:
| Код | @Remote public interface RemoteInterface { void addValues(String value, String type); } @Singleton public class RemoteBean implements RemoteInterface { @Override @RolesAllowed("testrole") public void addValues(String value, String type) { System.out.println("Add: " + value + "," + type); } }
|
Который настроен следующим образом:
| Код | CollapsedWrap disabledLine numbers off <glassfish-ejb-jar> <security-role-mapping> <role-name>testrole</role-name> <principal-name>testuser</principal-name> </security-role-mapping> <enterprise-beans> <name>testejb</name> <ejb> <ejb-name>RemoteBean</ejb-name> <ior-security-config> <as-context> <auth-method>USERNAME_PASSWORD</auth-method> <realm>file</realm> <required>true</required> </as-context> </ior-security-config> </ejb> </enterprise-beans> </glassfish-ejb-jar>
|
На первом сервере имеет другой компонет, который хочет работать с "удаленным" компонентом
| Код | test_prop.put("java.naming.factory.state", "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl"); test_prop.put("org.omg.CORBA.ORBInitialHost", "localhost"); test_prop.put("org.omg.CORBA.ORBInitialPort", "3701"); test_prop.put("java.naming.security.principal", "testuser"); test_prop.put("java.naming.security.credentials", "testpass"); InitialContext ic = new InitialContext(test_prop); RemoteInterface remote = (RemoteInterface) ic.lookup(RemoteInterface.class.getName()); remote.addValues("test", "test2");
|
Данный код генерирует ошибку:
| Код | SEVERE: iiop.runas_error SEVERE: iiop.secmechanism_exception com.sun.enterprise.iiop.security.SecurityMechanismException: Cannot propagate username/password required by target when using run as identity
|
Единственное решение, найденное в гугле - это использовать ProgrammaticLogin.login перед каждым использованием в новом контексте.
Есть ли средство заставить принимать java.naming.security.principal и java.naming.security.credentials через параметры контекста?
|