4

I want to use a JAAS-Authentication in a JAVA application via WildFly (8.2.0).

I have tried several methods and configurations....but I still get errors at the login (LoginContext).

I have started to configure the standalone.xml (WildFly):

  • created a new security realm „TPRealm“ with the JAAS-authentication:

    <security-realm name="TPRealm">
         <authentication>
             <jaas name="TPLogin"/>
         </authentication>
    </security-realm>
    
  • set the realm as default?:

    <subsystem xmlns="urn:jboss:domain:remoting:2.0">
         <endpoint worker="default"/>
            <http-connector name="http-remoting-connector" connector-ref="default" security-realm="TPRealm"/>
    </subsystem>
    
  • at Last, I have created a security domain „TPLogin“ with the login module:

    <security-domain name="TPLogin" cache-type="default">
        <authentication>
            <login-module code="Database" flag="required">
                <module-option name="dsJndiName" value="java:jboss/datasources/TourPlanningDS"/>
                <module-option name="principalsQuery" value="select passwordHash from TaUser where login=?"/>
            </login-module>
        </authentication>
    <security-domain>
    

In Java:

String username = "Admin";
String password = "admin";

PasswordClientCallbackHandler handler = new PasswordClientCallbackHandler(username, "TPRealm", password.toCharArray());

try {
      LoginContext loginContext = new LoginContext("TPRealm", handler);
      loginContext.login();
} catch (LoginException e) {
      System.out.println("Login failed");
      return;
}

At "new LoginContext(...)", I get following error

javax.security.auth.login.LoginException: No LoginModules configured for TPRealm

Moreoften I read, that a config-file is needed (jaas.config):

TPRealm {
      org.jboss.security.auth.spi.TPLogin required;  // I dont know, what exactly have to stay here
}

I added this file to the System.Properties.

System.setProperty("java.security.auth.login.config", jaasConfig)  //jaasConfig = path to file

With this, I can compile "new LoginContext(...)" but compiling failes at the next line at loginContext.login():

javax.security.auth.login.LoginException: unable to find LoginModule class: org.jboss.security.auth.spi.TPLogin

I also watched the log of wildfly expecting anything to be logged while running the code, but nothing was logged.

In the Java Application I have added also these properties:

Properties ejbProps = new Properties();
ejbProps.put("endpoint.name", "client-endpoint");
ejbProps.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false");
ejbProps.put("remote.connections", "default");
ejbProps.put("remote.connection.default.host", "localhost");
ejbProps.put("remote.connection.default.port", "8080");                                                  
ejbProps.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false");

EJBClientConfiguration cc = new PropertiesBasedEJBClientConfiguration(ejbProps);
ContextSelector<EJBClientContext> selector = new ConfigBasedEJBClientContextSelector(cc);
EJBClientContext.setSelector(selector);

Do I need to set further properties? Should I take notice on something else?

I would be really pleased, if anyone could help me.

Sevan
  • 669
  • 1
  • 5
  • 18
Ace
  • 65
  • 6

0 Answers0