Esempio n. 1
0
  public boolean authenticate() {
    log.debug("testing: " + isTesting());

    try {
      username = credentials.getUsername();
      String password = credentials.getPassword();

      if (StringUtils.isEmpty(username)) {
        messages.error("login", "User name must be specified.");
        return false;
      }

      if (username.equals("admin")) {
        identity.addRole("admin");
      }

      principal = userService.getUserByName(username);
      if (principal != null && principal.getPassword().equals(password)) {
        log.debug("authenticated: " + username);
        raiseUserAuthenticatedEvent();
        return true;
      }

      messages.error("login", "Invalid user name or password.");
      log.debug("not-authenticated");
      return false;

    } catch (Throwable e) {
      messages.error("login", e.getMessage());
      log.error("not-authenticated: " + e);
      return false;
    }
  }
Esempio n. 2
0
 @Begin(join = true)
 public void newRegistration() {
   setTitle("New Registration");
   Messages messages = BeanContext.get("messages");
   messages.info("Registration", "Enter information for new Registration.");
   registration = new Registration();
   // registration.setUserId(value);
   registrationManager.initialize(registration);
   initialize(registration);
 }