Пример #1
0
  /** JAAS CallbackHandler method */
  public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
    JAASLoginRequestCallback requestCallback = (JAASLoginRequestCallback) callbacks[0];
    JAASLoginResponseCallback responseCallback = (JAASLoginResponseCallback) callbacks[1];

    // first parameter is username
    String username = requestCallback.getParams().get(0);
    // second parameter is password
    String password = requestCallback.getParams().get(1);

    Account account = accountBO.getAccount(username, password);

    // set callback object, will return by LoginService.login
    responseCallback.setCallbackObject(account);
    // set principal name
    responseCallback.setPrincipalName(username);
    // set role
    responseCallback.setRole(username);
  }
Пример #2
0
  @ActionMethod(
      name = "edit",
      successView = "index.vhtml",
      errorView = "EditAccount.vhtml",
      parameterClass = EditAccountParameterObject.class,
      httpMethod = ActionMethod.HttpMethod.POST)
  public void doPostEdit(ActionContext actionContext) throws Exception {
    EditAccountParameterObject invocation =
        (EditAccountParameterObject) actionContext.getParameterObject();

    SessionContext sessionContext = actionContext.getSessionContext();
    Account account = (Account) sessionContext.getAttribute(ACCOUNT_SESSION_KEY);

    Account newAccount = new Account();
    newAccount.setBannerName(account.getBannerName());
    newAccount.setUsername(account.getUsername());
    newAccount.setStatus(account.getStatus());

    newAccount.setPassword(invocation.getPassword());
    newAccount.setAddress1(invocation.getAddress1());
    newAccount.setAddress2(invocation.getAddress2());
    newAccount.setBannerOption(invocation.getBannerOption());
    newAccount.setCity(invocation.getCity());
    newAccount.setCountry(invocation.getCountry());
    newAccount.setEmail(invocation.getEmail());
    newAccount.setFavouriteCategoryId(invocation.getFavouriteCategoryId());
    newAccount.setFirstName(invocation.getFirstName());
    newAccount.setLanguagePreference(invocation.getLanguagePreference());
    newAccount.setLastName(invocation.getLastName());
    newAccount.setListOption(invocation.getListOption());
    newAccount.setPassword(invocation.getPassword());
    newAccount.setPhone(invocation.getPhone());
    newAccount.setState(invocation.getState());
    newAccount.setZip(invocation.getZip());

    try {
      accountBO.updateAccount(newAccount);
      sessionContext.setAttribute(ACCOUNT_SESSION_KEY, newAccount);
    } catch (Exception e) {
      // update failed
      throw e;
    }
  }
Пример #3
0
  @ActionMethod(
      name = "create",
      successView = "index.vhtml",
      errorView = "NewAccountForm.vhtml",
      parameterClass = NewAccountParameterObject.class,
      httpMethod = ActionMethod.HttpMethod.POST)
  public void doPostCreate(ActionContext actionContext) throws Exception {
    NewAccountParameterObject invocation =
        (NewAccountParameterObject) actionContext.getParameterObject();
    Account newAccount = EntityFactory.newEntityObject(Account.class);
    newAccount.setUsername(invocation.getUsername());
    newAccount.setStatus("OK");
    newAccount.setPassword(invocation.getPassword());
    newAccount.setAddress1(invocation.getAddress1());
    newAccount.setAddress2(invocation.getAddress2());
    newAccount.setBannerOption(invocation.getBannerOption());
    newAccount.setCity(invocation.getCity());
    newAccount.setCountry(invocation.getCountry());
    newAccount.setEmail(invocation.getEmail());
    newAccount.setFavouriteCategoryId(invocation.getFavouriteCategoryId());
    newAccount.setFirstName(invocation.getFirstName());
    newAccount.setLanguagePreference(invocation.getLanguagePreference());
    newAccount.setLastName(invocation.getLastName());
    newAccount.setListOption(invocation.getListOption());
    newAccount.setPassword(invocation.getPassword());
    newAccount.setPhone(invocation.getPhone());
    newAccount.setState(invocation.getState());
    newAccount.setZip(invocation.getZip());

    try {
      accountBO.insertAccount(newAccount);
    } catch (Exception e) {
      // update failed
      throw e;
    }
  }