Click here to Skip to main content
15,891,745 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello community,

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

I have tried serveral 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:
XML
 <security-realm name="TPRealm">

     <authentication>

              <jaas name="TPLogin"/>

     </authentication>

</security-realm>


- set the realm as default?:
XML
<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:
XML
<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:

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
Java
javax.security.auth.login.LoginException: No LoginModules configured for TPRealm



Moreoften i read, that a config-file is needed (jaas.config):
Java
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.
Java
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():

Java
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:
Java
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
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900