1 Reply Latest reply on Feb 15, 2007 5:58 PM by Thomas Heute

    Erro when try to login

    works works Newbie

      I do what you talk for me, but when i login this message was showed:

      java.io.IOException: No properties file: users.properties or defaults: defaultUs
      ers.properties found
      at org.jboss.security.auth.spi.Util.loadProperties(Util.java:313)
      at org.jboss.security.auth.spi.UsersRolesLoginModule.loadUsers(UsersRole
      sLoginModule.java:186)
      at org.jboss.security.auth.spi.UsersRolesLoginModule.createUsers(UsersRo
      lesLoginModule.java:200)
      at org.jboss.security.auth.spi.UsersRolesLoginModule.initialize(UsersRol
      esLoginModule.java:127)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
      java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at javax.security.auth.login.LoginContext.invoke(LoginContext.java:756)
      at javax.security.auth.login.LoginContext.access$000(LoginContext.java:1
      86)
      at javax.security.auth.login.LoginContext$4.run(LoginContext.java:683)
      at java.security.AccessController.doPrivileged(Native Method)
      at javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:6
      80)
      at javax.security.auth.login.LoginContext.login(LoginContext.java:579)
      at org.jboss.security.plugins.JaasSecurityManager.defaultLogin(JaasSecur
      ityManager.java:601)
      at org.jboss.security.plugins.JaasSecurityManager.authenticate(JaasSecur
      ityManager.java:535)
      at org.jboss.security.plugins.JaasSecurityManager.isValid(JaasSecurityMa
      nager.java:344)
      at org.jboss.web.tomcat.security.JBossSecurityMgrRealm.authenticate(JBos
      sSecurityMgrRealm.java:491)
      at org.apache.catalina.authenticator.BasicAuthenticator.authenticate(Bas
      icAuthenticator.java:180)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authentica
      torBase.java:490)
      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValv
      e.java:74)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
      ava:126)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
      ava:105)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
      ve.java:107)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
      a:148)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
      :869)
      at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.p
      rocessConnection(Http11BaseProtocol.java:664)
      at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpo
      int.java:527)
      at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWor
      kerThread.java:112)
      at java.lang.Thread.run(Thread.java:595)
      19:34:12,511 ERROR [DBAuthentication] Failed to load users/passwords/role f
      iles
      java.io.IOException: No properties file: users.properties or defaults: defaultUs
      ers.properties found
      at org.jboss.security.auth.spi.Util.loadProperties(Util.java:313)
      at org.jboss.security.auth.spi.UsersRolesLoginModule.loadUsers(UsersRole
      sLoginModule.java:186)
      at org.jboss.security.auth.spi.UsersRolesLoginModule.createUsers(UsersRo
      lesLoginModule.java:200)
      at org.jboss.security.auth.spi.UsersRolesLoginModule.initialize(UsersRol
      esLoginModule.java:127)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
      java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
      sorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at javax.security.auth.login.LoginContext.invoke(LoginContext.java:756)
      at javax.security.auth.login.LoginContext.access$000(LoginContext.java:1
      86)
      at javax.security.auth.login.LoginContext$4.run(LoginContext.java:683)
      at java.security.AccessController.doPrivileged(Native Method)
      at javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:6
      80)
      at javax.security.auth.login.LoginContext.login(LoginContext.java:579)
      at org.jboss.security.plugins.JaasSecurityManager.defaultLogin(JaasSecur
      ityManager.java:601)
      at org.jboss.security.plugins.JaasSecurityManager.authenticate(JaasSecur
      ityManager.java:535)
      at org.jboss.security.plugins.JaasSecurityManager.isValid(JaasSecurityMa
      nager.java:344)
      at org.jboss.web.tomcat.security.JBossSecurityMgrRealm.authenticate(JBos
      sSecurityMgrRealm.java:491)
      at org.apache.catalina.authenticator.BasicAuthenticator.authenticate(Bas
      icAuthenticator.java:180)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authentica
      torBase.java:490)
      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValv
      e.java:74)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
      ava:126)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
      ava:105)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
      ve.java:107)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
      a:148)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
      :869)
      at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.p
      rocessConnection(Http11BaseProtocol.java:664)
      at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpo
      int.java:527)
      at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWor
      kerThread.java:112)
      at java.lang.Thread.run(Thread.java:595)
      19:34:18,714 ERROR [DBAuthentication] Failed to load users/passwords/role f
      iles
      java.io.IOException: No properties file: users.properties or defaults: defaultUs
      ers.properties found

      ----------------------------------------------------------------------------------
      This is my class

      package com.digithobrasil.ogma.authentication;


      public class DBAuthentication extends UsersLoginModule {
      /**
      * Nome do usuário
      */
      private String user;

      public Log LOG;

      /**
      * Construtor padrão
      *
      * @throws IOException
      *
      */
      public DBAuthentication() throws IOException {
      DBUtil.initializeDataSource();
      LOG = LogFactory.getLog(this.getClass());
      }

      /**
      * @see org.jboss.security.auth.spi.UsernamePasswordLoginModule#getUsernameAndPassword()
      */
      protected String[] getUsernameAndPassword() throws LoginException {
      // O método getUsernameAndPassword(), retorna um vetor com o nome do
      // usuario e a sua senha
      // da seguinte maneira [0]-nome do usuario [1]-senha
      String[] userAndPassword = super.getUsernameAndPassword();
      this.user = userAndPassword[0];
      return userAndPassword;
      }

      /**
      *
      * @see org.jboss.security.auth.spi.UsernamePasswordLoginModule#validatePassword(java.lang.String,
      * java.lang.String)
      */
      public boolean validatePassword(String arg0, String arg1) {
      // arg0 é a senha do usuário
      // arg1 é uma senha esperada
      boolean result = false;
      try {
      result = dbValidatePassword(this.user, arg0);
      } catch (Exception e) {
      e.printStackTrace();
      }

      return result;
      }

      /**
      * Valida o password
      *
      * @return boolean
      * @throws Exception
      */
      private boolean dbValidatePassword(String login, String password)
      throws Exception {

      boolean result = false;

      LOG.info("Ogma:ValidatePassword");
      LOG
      .info("Ogma:ValidatePassword login: " + login + " senha:"
      + password);

      String md5Password = DBUtil.buildMd5(password);

      List<Map<String, Object>> list = DBUtil.executeQuery(
      DBQueries.userRoleQuery, login, md5Password);

      if (list != null) {
      result = true;
      }

      LOG.info("Ogma:ValidatePassword authorized:" + result);

      return result;
      }

      /**
      * @return the user
      */
      public String getUser() {
      return user;
      }

      /**
      * @param user
      * the user to set
      */
      public void setUser(String user) {
      this.user = user;
      }

      }

      THANKS A LOT