3 Replies Latest reply on Dec 1, 2006 6:09 AM by marilenc

    Autentication through Java client for JAAS failing

    nazare

      Hi,

      I'm new to JBoss/JAAS. Working on a project to retrieve JMX information from JBoss in secure environment.

      The client program written with code

      props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.security.jndi.LoginInitialContextFactory");
      props.put(Context.PROVIDER_URL, "jnp://localhost:1099");
      props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
      props.put(Context.SECURITY_PRINCIPAL, name);
      props.put(Context.SECURITY_CREDENTIALS, password);

      is failing with "java.lang.SecurityException: Unable to locate a login configuration" errors.

      The JBoss command line utility twiddle.bat works fine with the authentication information retrieving the data from JBoss.

      Can somebody help in this regard to get this working as making the client connect with security is very essential.

      Thanks,
      Krishna

        • 1. Re: Autentication through Java client for JAAS failing
          j2ee_junkie

          Krishna,

          You forgot to set the security protocol property. See http://wiki.jboss.org/wiki/Wiki.jsp?page=LoginInitialContextFactory for details

          cgriffith

          • 2. Re: Autentication through Java client for JAAS failing
            nazare

            Hi Griffith,

            Thanks for pointing to the SECURITY_PROTOCOL parameter.

            I have a default installation of JBoss with authentication for jmx-console enabled. The username/password used is also default. (admin/admin)

            The value i provided for this parameter is "org.jboss.security.auth.spi.UsersRolesLoginModule". Tell me whether this is ok.

            Got my sample code working with creating a file auth.conf with following contents.

            other {
            
             // jBoss LoginModule
             org.jboss.security.ClientLoginModule required
             ;
            
             // Put your login modules that need jBoss here
            };


            And added addtional startup parameter for the JVM.
            -Djava.security.auth.login.config=file:<Path>/auth.conf


            With this the module started working fine.

            I have several following questions.
            1. In the JVM we'll be connecting to several different JBoss AS instances simultaneously. Is it possible to connect to different JBoss instances simultaneously with this single auth.conf. What changes are necessary in the client program and configuration file auth.conf

            2. What's the significance of SECURITY_PROTOCOL parameter. And how we can get a value/configure on the server. The value mentioned above is not affecting/effecting the sample code as it's connecting and returning values without the parameter being set.

            3. Point me to doc/url so that i can create some more users on JBoss server and test out the same.

            Thanks,
            Krishna


            • 3. Re: Autentication through Java client for JAAS failing
              marilenc

              Thank you this info, after searching a lot on this topic i have put together a complete working example using jmx remote invocation with secured console http://www.len.ro/work/articles/jboss/jmx-invocation-with-secured-console/