예제 #1
0
  @Handle("/openIdLoginResult")
  public Object loginResult(
      HttpServletRequest request, ParmManipulator manip, String endpoint, Location location) {
    byte[] mac_key = (byte[]) request.getSession().getAttribute(ATTR_MAC);
    String alias = (String) request.getSession().getAttribute(ATTR_ALIAS);

    Authentication auth = manager.getAuthentication(request, mac_key, alias);
    checkNonce(request.getParameter("openid.response_nonce"));

    if (auth == null || StringUtils.isBlank(auth.getEmail())) {
      return new Show(failureShowPage);
    }

    User user = authenticationService.getUserByProfileName(auth.getEmail());
    if (user == null) {
      user =
          todoService.createNewUser(
              auth.getEmail(),
              auth.getFullname(),
              auth.getEmail(),
              (String) request.getSession().getAttribute(ATTR_ENDPOINT));
    }
    ((Location) location.get(Constants.SESSION_LOCATION)).put(Constants.CURRENT_USER_OBJECT, user);

    // loading the object so it doesn't have a lazy init exception
    user.getGroupNames();

    return new Show(successShowPage);
  }
예제 #2
0
 protected User createUser(String profileName, String endpoint) {
   User user = authenticationService.createUser(profileName, profileName, null);
   authenticationService.setAuthenticationSystem(profileName, endpoint);
   return user;
 }