3 Replies Latest reply on Sep 19, 2005 10:00 AM by spadafora

    Remote Swing client not working

    spadafora

      Hello,
      I did successifully run the "JAAS how to" examples, I also changed the login-config.xml to authenticate and authorizate users against my application datasource.
      The problem i have is when i run the same code from a remote Swing application, following is the code i use:

      login-config.xml

      <application-policy name="myapp">
       <authentication>
       <login-module code="org.jboss.security.auth.spi.DatabaseServerLoginModule"
       flag="required">
       <module-option name="dsJndiName">java:/sqlserver</module-option>
       <module-option name="principalsQuery">select Password from USERS where USERNAME=?</module-option>
       <module-option name="rolesQuery">select Role, RoleGroup from USER_ROLES where USERNAME=?</module-option>
       </login-module>
       </authentication>
       </application-policy>
      



      Swing code:
      ...
      env.put(Context.INITIAL_CONTEXT_FACTORY, resources.getProperty("context.factory","") );
      env.put(Context.PROVIDER_URL, resources.getProperty("provider.url","") );
      env.put(Context.SECURITY_PRINCIPAL, username );
      env.put(Context.SECURITY_CREDENTIALS, password );
      initial = new InitialContext(env);
      Object objref = initial.lookup(USER_SETTING);
      authSuccess = true;
      ....
      



      jboss.xml
      <jboss>
       <security-domain>java:/jaas/myapp</security-domain>
       <session>
       <ejb-name>UserSettingManager</ejb-name>
       <jndi-name>UserSettingManager</jndi-name>
       </session>
      </jboss>
      



      when I run my application without JAAS it works fine, as i need to gain or deny access to specific business methods I have to plug JAAS, when i do it I get on the server side principal=null...

      why does that happens?
      I tested on other App Server and it works.
      Please help.

      thank you.

        • 1. Re: Remote Swing client not working
          spadafora

          anybody could help please?
          thank you.

          • 2. Re: Remote Swing client not working
            darranl

             

            "spadafora" wrote:
            Hello,
            I did successifully run the "JAAS how to" examples, I also changed the login-config.xml to authenticate and authorizate users against my application datasource.


            The JAAS how to examples used the ClientLoginModule on the client side to send the username and password from the client to the server, you are trying to pass the username and password into the InitalContext constructor.

            Have a look at: -

            http://docs.jboss.org/jbossas/jboss4guide/r3/html/ch3.chapter.htm

            Section 3.2.1.3 for the LoginInitialContextFactory that allows you to specify the username and password the way you are.

            • 3. Re: Remote Swing client not working
              spadafora

              it works!! thank you so much!

              i did read the section you suggested and it works... actually i had to change my ejb-jar.xml ... but something small... and set in my auth.conf ClientLoginModule as required.

              Now i need to do the same job (authentication and authorization) over HTTPS or http, would be great to do the login call over https and then use http for subsequent calls.
              Could you please help me?


              thank you in advance for your time.

              Ciao