Good all the time of day! I encountered the error "No LoginModules configured for default" while trying to call the @Remote EJB method with checking the user's role. Authorization does not occur. Already the third day the problem is not solved.

JDBCRealm configured with the name "jdbc-realm" is configured on the Glassfish server (5.0.1), authentication is performed correctly through the browser. Errors in the emphasis can not see!

Method:

@Override public String sayHellowSecurity(String name) { if (!ctx.isCallerInRole("ADMIN")){ return "FU, you doesnot have permissions!"; }else{ return "Hello, SECURITY "+name+"!"; } } 

I call this:

 public static void main(String[] args) { try { Properties props = new Properties(); props.setProperty("java.naming.factory.initial", "com.sun.enterprise.naming.SerialInitContextFactory"); props.setProperty("java.naming.factory.url.pkgs", "com.sun.enterprise.naming"); props.setProperty("java.naming.factory.state", "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl" ); props.setProperty("org.omg.CORBA.ORBInitialHost", "127.0.0.1"); props.setProperty("org.omg.CORBA.ORBInitialPort", "3700"); ProgrammaticLogin pm = new ProgrammaticLogin(); pm.login("admin@mail.ru", "Aa123456".toCharArray(), "jdbc-realm", false); InitialContext ctx = new InitialContext(props); UserEJBRemote userejb = (UserEJBRemote) ctx.lookup("userejb"); System.out.println("RESULT: " + userejb.sayHellowSecurity("world!")); pm.logout(); //mySessionBean.persist(user); } catch (javax.naming.NamingException ne) { ne.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } } 

And I get the error:

 авг 18, 2018 4:08:00 AM com.sun.enterprise.security.ee.auth.login.ProgrammaticLogin login SEVERE: SEC9050: Programmatic login failed com.sun.enterprise.security.auth.login.common.LoginException: javax.security.auth.login.LoginException: No LoginModules configured for default at com.sun.enterprise.security.auth.login.LoginContextDriver$9.run(LoginContextDriver.java:891) at com.sun.enterprise.security.common.AppservAccessController.doPrivileged(AppservAccessController.java:61) at com.sun.enterprise.security.auth.login.LoginContextDriver.doClientLogin(LoginContextDriver.java:882) at com.sun.enterprise.security.ee.auth.login.ProgrammaticLogin$1.run(ProgrammaticLogin.java:183) at com.sun.enterprise.security.ee.auth.login.ProgrammaticLogin$1.run(ProgrammaticLogin.java:168) at java.security.AccessController.doPrivileged(Native Method) at com.sun.enterprise.security.ee.auth.login.ProgrammaticLogin.login(ProgrammaticLogin.java:168) at ru.deviantdev.noapplication.Main2.main(Main2.java:32) Caused by: javax.security.auth.login.LoginException: No LoginModules configured for default at javax.security.auth.login.LoginContext.init(LoginContext.java:264) at javax.security.auth.login.LoginContext.<init>(LoginContext.java:381) at javax.security.auth.login.LoginContext.<init>(LoginContext.java:458) at com.sun.enterprise.security.auth.login.LoginContextDriver$9.run(LoginContextDriver.java:885) ... 7 more RESULT: FU, you doesnot have permissions! Process finished with exit code 0 
  • docs.oracle.com/cd/B14099_19/web.1012/b15505/… : JAAS Support for EJBs If you need it, it’s not supported. Ejb However, if you call the EJB from a servlet within the OC4J instance, then JAAS is supported. The question is how to log in to an EJB called outside the container? - deviantdev

0