4 Replies Latest reply on Sep 11, 2003 5:27 AM by pgmjsd

    change password without reloggin

    cathylee

      I am using JBOSS 3.2.1, I want to give users ability to change password on the fly.
      I use roles.properties and users.properties to keep track of user information, I am sure JBOSS has some classes can be used to do that.

      Thanks in advance for your help.

        • 1. Re: change password without reloggin
          cathylee

          I have this problem with JBoss 3.2.1.
          I use roles.properties and users.properties, the following code executed without error, but the old password is still in force afterward.
          Also I want to copy the two properties files to my destination dir, and update them every time password is changed, so that I can copy these up-to-date password files back when application upgrade(everytime a newer version is deployed). Have any idea how to do that?

          Thanks!


          SecurityAssociation.setCredential(newPSW);
          java.util.ArrayList servers = MBeanServerFactory.findMBeanServer(null);
          if (servers.size() != 1)
          System.err.println("No server found");
          MBeanServer server = (MBeanServer) servers.get(0);

          try {
          String jaasMgrName = "jboss.security:service=JaasSecurityManager";
          ObjectName jaasMgr = new ObjectName(jaasMgrName);
          Object[] params = {"myDomainName", new org.jboss.security.SimplePrincipal("myUserName")};
          String[] signature = {"java.lang.String","java.security.Principal"};
          server.invoke(jaasMgr, "flushAuthenticationCache", params, signature);
          } catch (Exception e) {
          System.err.println("flushSecurityDomain Except: " + e);
          }

          • 2. Re: change password without reloggin
            pgmjsd

            cathylee,

            It might be better to use a database to store the usernames an passwords if the passwords are going to be changed. Try the DatabaseServerLoginModule instead. Or, if you don't mind LDAP, use the LDAP login module.

            • 3. Re: change password without reloggin
              cathylee

              If I use database I have to have a JDBC accessible database running, and config it talk to JBoss, right?

              • 4. Re: change password without reloggin
                pgmjsd

                > If I use database I have to have a JDBC accessible
                > database running, and config it talk to JBoss, right?

                Yes. You will need to have a DataSource defined. The 'DefaultDS' DataSource can be used, you need to create the tables and add some rows, of course.