Package com.liferay.portal.model

Examples of com.liferay.portal.model.User


        }
    }

  public static UserData getLiferayUserByEmailNoException(String email, Long companyId) {
        try {
            User user = UserLocalServiceUtil.getUserByEmailAddress(companyId, email);
            return convertLiferayUser(user);
        }
        catch (Exception e) {
            return null;
        }
View Full Code Here


        }
    }

    public static UserData getLiferayUser(String login, Long companyId) {
        try {
            User user = UserLocalServiceUtil.getUserByScreenName(companyId, login);
            return convertLiferayUser(user);
        }
        catch (Exception e) {
            throw new LiferayBridgeException(e);
        }
View Full Code Here

        try {
            long[] companyIds = PortalUtil.getCompanyIds();
            for (int i = 0; i < companyIds.length; ++i) {
                long ci = companyIds[i];
                try {
                    User u = UserLocalServiceUtil.getUserByScreenName(ci, login);
                    if (u != null) {
                        return convertLiferayUser(u);
                    }
                }
                catch (NoSuchUserException e) {
View Full Code Here

        }
    }

    public static UserData getLiferayUserByEmail(String email, Long companyId) {
        try {
            User user = UserLocalServiceUtil.getUserByEmailAddress(companyId, email);
            return convertLiferayUser(user);
        }
        catch (Exception e) {
            throw new LiferayBridgeException(e);
        }
View Full Code Here

public class PortalBridge {

    public static UserData getLiferayUser(PortletRequest request) {
        try {
            User user = PortalUtil.getUser(request);
            return LiferayBridge.convertLiferayUser(user);
        }
        catch (Exception e) {
            throw new LiferayBridge.LiferayBridgeException(e);
        }
View Full Code Here

        }
    }

    public static Collection<String> getLiferayUserRoles(PortletRequest request) {
        try {
            User user = PortalUtil.getUser(request);
            if (user == null) {
                return null;
            }
            return new Mapcar<Role, String>(user.getRoles()) {
                @Override
                public String lambda(Role x) {
                    return x.getName();
                }
            }.go();
View Full Code Here

    HttpSession session = req.getSession();
   
    /* Check if session is already authorized. If not, proceed with authorization */
    if (session.getAttribute(getSessionAuthorizationName()) == null)
    {
      User liferayUser = getLiferayUser(req);
     
      /* No liferay user bound with current session, fail */
      if(liferayUser == null)
      {
        out.write("No Liferay user is bound to current sesssion, abort");
        return false;
      }
     
      /* There is user bound with current session, but it has not got all required roles */
      if(!hasHelpChangeRole(liferayUser))
      {
        out.write("User "+liferayUser.getScreenName()+" does not have all roles: "+getAuthorizedRoles());
        return false;
      }
     
      session.setAttribute(getSessionAuthorizationName(), liferayUser.getScreenName());

    }

    out.close();
    return true;
View Full Code Here

  }

  /** Get Liferay user by given servlet request */
  protected User getLiferayUser(HttpServletRequest req) throws ServletException
  {
      User userByScreenName = null;
     
      /* Try to authorized user by given servlet request.
       * We have to use cookies, otherwise authentication
       * won't work on WebSphere
       */
     
      String userId = null;
      String password = null;
      String companyId = null;
     
      for (Cookie c : req.getCookies())
      {
        if ("COMPANY_ID".equals(c.getName())) {
          companyId = c.getValue();
        } else if ("ID".equals(c.getName())) {
          userId = hexStringToStringByAscii(c.getValue());
        } else if ("PASSWORD".equals(c.getName())) {
          password = hexStringToStringByAscii(c.getValue());
        }
      }
     
      if (userId != null && password != null && companyId != null) {
        try {
         
          KeyValuePair kvp = UserLocalServiceUtil.decryptUserId(Long.parseLong(companyId), userId, password);

          userByScreenName = UserLocalServiceUtil.getUserById(Long.valueOf(kvp.getKey()));
        } catch (NumberFormatException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        } catch (PortalException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        } catch (SystemException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }
     
      if(userByScreenName == null)
      {
        logger.warning("Failed to authorize user");
        return null;
      }
      logger.info("Successfully authorized user: " + userByScreenName.getScreenName());
     
      return userByScreenName;
  }
View Full Code Here

            return;
        }

        try {
            //check for user session
            User userByScreenName = null;
            //try to authorize user using Liferay API
            long basicAuthUserId = PortalUtil.getBasicAuthUserId(req);
            if (basicAuthUserId != 0)
                userByScreenName  = UserLocalServiceUtil.getUserById(basicAuthUserId);
            if (userByScreenName != null) {
                String username = userByScreenName.getScreenName();
                logger.info("Successfully authorized user: " + username);
                List<Role> roles = userByScreenName.getRoles();
                boolean found = false;
                for (Role role : roles) {
                    if (!role.isTeam() && ROLE_NAMES.contains(role.getName().toUpperCase())) {
                        found = true;
                        logger.info("Matched role " + role.getName() + " for user " + username);
View Full Code Here

        Role role = RoleServiceUtil.getRole(PortalUtil.getDefaultCompanyId(), liferayRoleName);
        if (role == null) return new HashSet<UserData>();
        long[] roleUserIds = UserServiceUtil.getRoleUserIds(role.getRoleId());
        HashSet<UserData> users = new HashSet<UserData>();
        for (long roleUserId : roleUserIds) {
          User userById = UserServiceUtil.getUserById(roleUserId);
          UserData ud = new UserData();
          ud.setLogin(userById.getLogin());
          ud.setDescription(userById.getFullName());
          ud.setBpmLogin(userById.getScreenName());
          users.add(ud);
        }
        return users;
      }
      finally {
View Full Code Here

TOP

Related Classes of com.liferay.portal.model.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.