Package org.eclipse.orion.server.useradmin

Examples of org.eclipse.orion.server.useradmin.User


   * @throws UnsupportedUserStoreException
   */
  public static LoginResult performAuthentication(HttpServletRequest req, HttpServletResponse resp) throws IOException, UnsupportedUserStoreException {
    Logger logger = LoggerFactory.getLogger("org.eclipse.orion.server.login"); //$NON-NLS-1$
    String login = req.getParameter("login");//$NON-NLS-1$
    User user = getUserForCredentials(login, req.getParameter("password")); //$NON-NLS-1$

    if (user != null) {
      if (user.getBlocked()) {
        return LoginResult.BLOCKED;
      }
      String actualLogin = user.getUid();
      if (logger.isInfoEnabled())
        logger.info("Login success: " + actualLogin); //$NON-NLS-1$
      req.getSession().setAttribute("user", actualLogin); //$NON-NLS-1$

      IOrionUserProfileNode userProfileNode = getUserProfileService().getUserProfileNode(actualLogin, IOrionUserProfileConstants.GENERAL_PROFILE_PART);
View Full Code Here


      return null;
    }
   
    // check for "admin" user first
    if (login.equals("admin")) { //$NON-NLS-1$
      User user = userAdmin.getUser(UserConstants.KEY_LOGIN, login);
      if (user != null && user.hasCredential(UserConstants.KEY_PASSWORD, password)) {
        return user;
      }
    }
   
    try {
      JSONObject userJson = getUserObject(login);
      if (userJson != null) {
        String dn = userJson.get("userDN").toString();
        String displayname = userJson.get(USER_DISPLAYNAME).toString();
        String email = userJson.get(USER_EMAIL).toString();
        logger.info("authenticate dn, email, displayname" + " "+dn+ " "+email+ " "+displayname);
        //String json = userHash.get("jsonAttrib").toString();
        authenticate(dn, password);

        User user = userAdmin.getUser(UserConstants.KEY_LOGIN, login);
        if (user == null) {
          user = createOrionUser(login, email, displayname);
        }
        return user;
      }
View Full Code Here

  private static User createOrionUser(String login, String email, String name) {
    if (name == null) {
      name = login;
    }

    User newUser = new User(login, name, null)// don't save password
    newUser.setEmail(email);

    newUser = userAdmin.createUser(newUser);

    try {
      AuthorizationService.addUserRight(newUser.getUid(), newUser.getLocation());
    } catch (CoreException e) {
      LogHelper.log(e);
    }

    return newUser;
View Full Code Here

  public static JSONObject getUserJson(String uid, String contextPath) throws JSONException {
    JSONObject obj = new JSONObject();
    obj.put("login", uid); //$NON-NLS-1$

    try {
      User user = userAdmin.getUser(UserConstants.KEY_UID, uid);
      if (user == null) {
        return null;
      }
      // try to add the login timestamp to the user info
      IOrionUserProfileNode generalUserProfile = LdapAuthenticationService.getUserProfileService().getUserProfileNode(uid, IOrionUserProfileConstants.GENERAL_PROFILE_PART);
      obj.put(UserConstants.KEY_UID, uid);
      obj.put(UserConstants.KEY_LOGIN, user.getLogin());
      obj.put("Location", contextPath + user.getLocation());
      obj.put("Name", user.getName());
      if (generalUserProfile.get(IOrionUserProfileConstants.LAST_LOGIN_TIMESTAMP, null) != null) {
        Long lastLogin = Long.parseLong(generalUserProfile.get(IOrionUserProfileConstants.LAST_LOGIN_TIMESTAMP, ""));

        obj.put(IOrionUserProfileConstants.LAST_LOGIN_TIMESTAMP, lastLogin);
      }
View Full Code Here

    }
    return null;
  }

  public IPerson getPersonByEmail(String email) {
    User user = getOrionUserByEmail(email);
    if (user != null) {
      try {
        return addPerson(user.getUid(), null, email);
      } catch (UserException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
View Full Code Here

    public String getEmail() {
      if (this.email != null)
        return this.email;

      User user = getOrionUser(this.getUserID());
      if (user != null) {
        this.email = user.getEmail();
      } else {
        theLogger.logp(
          Level.SEVERE,
          OrionPersonManager.class.getName(),
          "getEmail",
View Full Code Here

      return name;
    }

    public String getDisplayName() {
      String displayName = "";
      User user = getOrionUser(this.getUserID());
      if (user != null) {
        displayName = user.getName();
      } else {
        theLogger.logp(
          Level.SEVERE,
          OrionPersonManager.class.getName(),
          "getDisplayName",
View Full Code Here

      return false;
    }

    String email = request.getParameter(UserConstants.KEY_EMAIL);
    IOrionCredentialsService userAdmin = getUserAdmin();
    User user = userAdmin.getUser(UserConstants.KEY_EMAIL, email);
    if (user == null) {
      // users registered before M10 will have an email for "login" and no value for "email"
      user = userAdmin.getUser(UserConstants.KEY_LOGIN, email);
      if (user != null) {
        user = fixOldUser(userAdmin, user);
      }

      if (user == null) {  // also checks for failure from `fixOldUser()`
        theLogger.finest("User object not found for " + email +
            ". Perhaps that user isn't registered yet.");
        return false;
      }
    }

    // modify request to add correct `login` parameter
    RequestWrapper modifiedRequest = new RequestWrapper(request);
    modifiedRequest.setParameter(UserConstants.KEY_LOGIN, user.getLogin());

    // continue with filter chain
    chain.doFilter(modifiedRequest, response);
    return true;
  }
View Full Code Here

      if (login != null && login.length() > 0) {
        return;
      }

      IOrionCredentialsService userAdmin = getUserAdmin();
      User user = userAdmin.getUser(UserConstants.KEY_EMAIL, email);
      if (user != null) {
        // a user exists with this email; let Orion handle the rest
        return;
      }
View Full Code Here

TOP

Related Classes of org.eclipse.orion.server.useradmin.User

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.