code:     public Principal authenticate(String username, String credentials) {
  
          // No user or no credentials
          // Can't possibly authenticate, don't bother the database then
          if (username == null || credentials == null) {
              if (log.isDebugEnabled())
                  log.debug(sm.getString("memoryRealm.authenticateFailure", username));
              return null;
          }
  
          GenericPrincipal principal = principals.get(username);
  
          if(principal == null || principal.getPassword() == null) {
              // User was not found in the database of the password was null
  
              if (log.isDebugEnabled())
                  log.debug(sm.getString("memoryRealm.authenticateFailure", username));
              return null;
          }
  
          boolean validated = getCredentialHandler().matches(credentials, principal.getPassword());
  
          if (validated) {
              if (log.isDebugEnabled())
                  log.debug(sm.getString("memoryRealm.authenticateSuccess", username));
              return principal;
          } else {
              if (log.isDebugEnabled())
                  log.debug(sm.getString("memoryRealm.authenticateFailure", username));
              return null;
          }
      }
  
  
      // -------------------------------------------------------- Package Methods
  
  
      /**
       * Add a new user to the in-memory database.
       *
       * @param username User's username
       * @param password User's password (clear text)
       * @param roles Comma-delimited set of roles associated with this user
       */
  