[jboss-dev-forums] [JBoss AS 7 Development] - Re: JBoss 7.2.0 nightly build custom login module

Daniel Jipa do-not-reply at jboss.com
Wed May 16 04:57:13 EDT 2012


Daniel Jipa [https://community.jboss.org/people/danjee] created the discussion

"Re: JBoss 7.2.0 nightly build custom login module"

To view the discussion, visit: https://community.jboss.org/message/735854#735854

--------------------------------------------------------------
Here is a simple example of an app that work on a 7.1.2 ( I think from April) works and on 7.2.0 it gives me the 


ERROR: JBREM000200: Remote connection failed: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed
Exception in thread "main" javax.naming.NamingException: Failed to create remoting connection [Root exception is java.lang.RuntimeException: javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed]




The login module looks like this:


package com.asf.jboss7.security;
 
 
import java.security.acl.Group;
 
 
import javax.security.auth.login.LoginException;
 
 
import org.jboss.security.SimpleGroup;
import org.jboss.security.SimplePrincipal;
import org.jboss.security.auth.spi.UsernamePasswordLoginModule;
 
 
public class TestLoginModule extends UsernamePasswordLoginModule {
 
 
          // initial state
          @Override
          protected String getUsersPassword() throws LoginException {
                    return "1";
          }
 
 
          /*
           * (non-Javadoc)
           * 
           * @see
           * org.jboss.security.auth.spi.UsernamePasswordLoginModule#validatePassword
           * (java.lang.String, java.lang.String)
           */
          @Override
          protected boolean validatePassword(String inputPassword,
                              String expectedPassword) {
                    System.out.println("--> username: " + super.getUsername());
                    new Throwable("trace login module calls").printStackTrace();
 
 
                    return super.validatePassword(inputPassword, expectedPassword);
          }
 
 
          @Override
          protected Group[] getRoleSets() {
                    Group[] groups = { new SimpleGroup("Roles"), new SimpleGroup("*") };
                    SimplePrincipal role = new SimplePrincipal("ASF_Users");
                    groups[0].addMember(role);
                    return groups;
          }
 
 
}
 



The client is this:


package com.asf.jndi.jboss7;
 
 
import java.rmi.RemoteException;
import java.util.Hashtable;
 
 
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
 
 
import com.asf.jboss7.RemoteCalculator;
import com.asf.kollecto.common.exception.AppException;
 
 
public class JndiTest {
          public static void main(String[] args) throws NamingException,
                              AppException, RemoteException {
                    final Hashtable<String, Object> jndiProperties = new Hashtable<String, Object>();
 
 
                    jndiProperties.put(Context.URL_PKG_PREFIXES,
                                        "org.jboss.ejb.client.naming");
                    jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY,
                                        "org.jboss.naming.remote.client.InitialContextFactory");
                    jndiProperties.put(Context.PROVIDER_URL,
                                        "remote://vs420.intranet.asf.ro:4447");
                    jndiProperties.put(Context.SECURITY_PRINCIPAL, "support");
                    jndiProperties.put(Context.SECURITY_CREDENTIALS, "1");
                    jndiProperties.put("jboss.naming.client.ejb.context", true);
                    jndiProperties
                                        .put("jboss.naming.client.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT",
                                                            "false");
 
 
                    final Context context = new InitialContext(jndiProperties);
                    final String appName = "myear";
                    final String moduleName = "myejb3";
                    final String distinctName = "";
                    final String beanName = "CalculatorBean";
                    final String viewClassName = RemoteCalculator.class.getName();
                    String lookup = "ejb:" + appName + "/" + moduleName + "/"
                                        + distinctName + "/" + beanName + "!" + viewClassName;
                    System.out.println("lookup name: " + lookup);
                    RemoteCalculator facade = (RemoteCalculator) context.lookup(lookup);
                    System.out.println(facade);
                    for (int i = 0; i < 3; i++) {
                              System.out.println("test: " + facade.add(i, 8));
                    }
 
 
          }
}
 
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/735854#735854]

Start a new discussion in JBoss AS 7 Development at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2225]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-dev-forums/attachments/20120516/6b29e56d/attachment.html 


More information about the jboss-dev-forums mailing list