Package com.liferay.portal.model

Examples of com.liferay.portal.model.Company


    */
    public static boolean doLogin(String userName, String password) throws NoSuchUserException {
        try {
          User user = null;
          boolean match = false;
          Company comp = com.dotmarketing.cms.factories.PublicCompanyFactory.getDefaultCompany();

          if (comp.getAuthType().equals(Company.AUTH_TYPE_EA)) {
         if(userName.equalsIgnoreCase(APILocator.getUserAPI().getSystemUser().getEmailAddress())){
           SecurityLogger.logInfo(LoginFactory.class,"An invalid attempt to login as " + userName + " has been made  - you cannot login as the system user");

           return false;
         }
       } else {
         if(userName.equalsIgnoreCase(APILocator.getUserAPI().getSystemUser().getUserId())){
           SecurityLogger.logInfo(LoginFactory.class,"An invalid attempt to login as " + userName + " has been made  - you cannot login as the system user");

           return false;
         }
       }

          if ((PRE_AUTHENTICATOR != null) &&
            (0 < PRE_AUTHENTICATOR.length()) &&
            PRE_AUTHENTICATOR.equals(Config.getStringProperty("LDAP_FRONTEND_AUTH_IMPLEMENTATION"))) {
            Class ldap_auth_impl_class = Class.forName(Config.getStringProperty("LDAP_FRONTEND_AUTH_IMPLEMENTATION"));
            Authenticator ldap_auth_impl = (Authenticator) ldap_auth_impl_class.newInstance();
            int auth = 0;

          if (comp.getAuthType().equals(Company.AUTH_TYPE_EA)) {
            auth = ldap_auth_impl.authenticateByEmailAddress(comp.getCompanyId(), userName, password);
         } else {
           auth = ldap_auth_impl.authenticateByUserId(comp.getCompanyId(), userName, password);
         }

          if (comp.getAuthType().equals(Company.AUTH_TYPE_EA)) {
                 user = APILocator.getUserAPI().loadByUserByEmail(userName, APILocator.getUserAPI().getSystemUser(), false);
               } else {
                 user = APILocator.getUserAPI().loadUserById(userName, APILocator.getUserAPI().getSystemUser(), false);
               }

          try{
            boolean SYNC_PASSWORD = BaseAuthenticator.SYNC_PASSWORD;
            if(!SYNC_PASSWORD){
              String roleName = LDAPImpl.LDAP_USER_ROLE;
              if(com.dotmarketing.business.APILocator.getRoleAPI().doesUserHaveRole(user, roleName)){
                user.setPassword(DotCustomLoginPostAction.FAKE_PASSWORD);
                APILocator.getUserAPI().save(user,APILocator.getUserAPI().getSystemUser(),false);
              }
            }
          }catch (Exception e) {
            Logger.debug(LoginFactory.class, "syncPassword not set or unable to load user", e);
          }

          match = auth == Authenticator.SUCCESS;
          } else {
               if (comp.getAuthType().equals(Company.AUTH_TYPE_EA)) {
                 user = APILocator.getUserAPI().loadByUserByEmail(userName, APILocator.getUserAPI().getSystemUser(), false);
               } else {
                 user = APILocator.getUserAPI().loadUserById(userName, APILocator.getUserAPI().getSystemUser(), false);
               }

View Full Code Here


        if(userMod!=null){
          webAsset.setModUser(userMod.getUserId());
        }

        try {
          Company comp = PublicCompanyFactory.getDefaultCompany();
          String message = LanguageUtil.get(comp.getCompanyId(), user.getLocale(), "message." + webAsset.getType() + ".edit.locked");
          message += " (" + userMod.getEmailAddress() + ")";
          SessionMessages.add(httpReq, "custommessage", message);
        } catch (Exception e) {
          SessionMessages.add(httpReq, "message", "message." + webAsset.getType() + ".edit.locked");
        }
View Full Code Here

      emails = emails.substring(0,emails.lastIndexOf(";"));
    }

    String emailTemplate = commentsOptions.get("emailTemplate");

    Company liferay = PublicCompanyFactory.getDefaultCompany();
    String from = liferay.getEmailAddress();
    String to  =  commentsOptions.get("email");
    String subject = Config.getStringProperty("commentSubject");
    subject = subject.replaceAll("\\$\\{commentQuestion}", commentQuestion);
    String URL = "http://" + request.getServerName() + referrer;
View Full Code Here

    Date today = new Date();

    if (user.isNew() || (!user.isNew() && user.getLastLoginDate() == null)) {

      // ### CREATE USER ###
      Company company = PublicCompanyFactory.getDefaultCompany();
      user.setEmailAddress(form.getEmail().trim().toLowerCase());
      user.setFirstName(form.getFirstName() == null ? "" : form.getFirstName());
      user.setMiddleName(form.getMiddleName() == null ? "" : form.getMiddleName());
      user.setLastName(form.getLastName() == null ? "" : form.getLastName());
      user.setNickName("");
      user.setCompanyId(company.getCompanyId());
      user.setPasswordEncrypted(true);
      user.setGreeting("Welcome, " + user.getFullName() + "!");

      // Set defaults values
      if (user.isNew()) {
        //if it's a new user we set random password
        String pass = PublicEncryptionFactory.getRandomPassword();
        user.setPassword(PublicEncryptionFactory.digestString(pass));
        user.setLanguageId(defaultUser.getLanguageId());
        user.setTimeZoneId(defaultUser.getTimeZoneId());
        user.setSkinId(defaultUser.getSkinId());
        user.setDottedSkins(defaultUser.isDottedSkins());
        user.setRoundedSkins(defaultUser.isRoundedSkins());
        user.setResolution(defaultUser.getResolution());
        user.setRefreshRate(defaultUser.getRefreshRate());
        user.setLayoutIds("");
        user.setActive(true);
        user.setCreateDate(today);
      }
      APILocator.getUserAPI().save(user,APILocator.getUserAPI().getSystemUser(),false);
      // ### END CREATE USER ###

      // ### CREATE USER_PROXY ###
      UserProxy userProxy = com.dotmarketing.business.APILocator.getUserProxyAPI().getUserProxy(user.getUserId(),APILocator.getUserAPI().getSystemUser(), false);
      userProxy.setPrefix("");
      userProxy.setTitle(form.getTitle());
      userProxy.setOrganization(form.getOrganization());
      userProxy.setUserId(user.getUserId());
      com.dotmarketing.business.APILocator.getUserProxyAPI().saveUserProxy(userProxy,APILocator.getUserAPI().getSystemUser(), false);
      // ### END CRETE USER_PROXY ###

      // saving user inode on web form
      form.setUserInode(userProxy.getInode());
      if(UtilMethods.isSet(form.getFormType())){
      HibernateUtil.saveOrUpdate(form);
      }

      ///// WE CAN DO THIS! BUT WE NEED TO ADD CATEGORIES TO WEBFORM AND ALSO CHANGE THE PROCESSES THAT
      //// CREATE THE EXCEL DOWNLOAD FROM WEB FORMS. I DIDN'T ADD IT SO I COMMENTED THIS CODE FOR NOW
      //get the old categories, wipe them out
      /*
      List<Category> categories = InodeFactory.getParentsOfClass(userProxy, Category.class);
      for (int i = 0; i < categories.size(); i++) {
        categories.get(i).deleteChild(userProxy);
      }
       */
      // Save the new categories
      /*String[] arr = form.getCategories();
      if (arr != null) {
        for (int i = 0; i < arr.length; i++) {
          Category node = (Category) InodeFactory.getInode(arr[i], Category.class);
          node.addChild(userProxy);
        }
      }*/

      // ### CREATE ADDRESS ###
      try {
        List<Address> addresses = PublicAddressFactory.getAddressesByUserId(user.getUserId());
        Address address = (addresses.size() > 0 ? addresses.get(0) : PublicAddressFactory.getInstance());
        address.setStreet1(form.getAddress1() == null ? "" : form.getAddress1());
        address.setStreet2(form.getAddress2() == null ? "" : form.getAddress2());
        address.setCity(form.getCity() == null ? "" : form.getCity());
        address.setState(form.getState() == null ? "" : form.getState());
        address.setZip(form.getZip() == null ? "" : form.getZip());
        String phone = form.getPhone();
        address.setPhone(phone == null ? "" : phone);
        address.setUserId(user.getUserId());
        address.setCompanyId(company.getCompanyId());
        PublicAddressFactory.save(address);
      } catch (Exception ex) {
        Logger.error(this,ex.getMessage(),ex);
      }

View Full Code Here

      finalMessageStr = finalMessageStr.replaceAll("(?i)(<|(&lt;))/varZip(>|(&gt;))", "");
      finalMessageStr = finalMessageStr.replaceAll("(?i)(<|(&lt;))varZip(\")?( )*/*( )*(>|(&gt;))", (address.getZip()!=null) ? address.getZip() : "");

      //gets default company to get locale
      Company comp = PublicCompanyFactory.getDefaultCompany();

      try {

        int varCounter = 1;

        for (;varCounter < 26;varCounter++) {
          String var = LanguageUtil.get(comp.getCompanyId(), comp.getLocale(), "user.profile.var" + varCounter);
          if (var!=null) var = var.replaceAll(" ","_");

          String value = "";
          try {
            value = BeanUtils.getSimpleProperty(userproxy, "var" + varCounter);
View Full Code Here

      context.put("permission", new Boolean(permission));

      // Check if the user is a CMS Administrator
      boolean adminUser = false;
      try {
        Company company = null;
        company = com.dotmarketing.cms.factories.PublicCompanyFactory.getDefaultCompany();

        String adminRoleKey = "";
        try {
          Role adminRole = APILocator.getRoleAPI().loadRoleByKey(Config.getStringProperty("CMS_ADMINISTRATOR_ROLE"));
View Full Code Here

  public User authorizePrincipal(String username, String passwdthrows DotSecurityException, NoSuchUserException, DotDataException {
    User _user;

    boolean useEmailAsLogin = true;
    Company comp = com.dotmarketing.cms.factories.PublicCompanyFactory.getDefaultCompany();
    if (comp.getAuthType().equals(Company.AUTH_TYPE_ID)) {
      useEmailAsLogin = false;
    }
    try {
      if (PRE_AUTHENTICATOR != null && !PRE_AUTHENTICATOR.equals("")) {
        Authenticator authenticator;
        authenticator = (Authenticator) new com.dotcms.repackage.bsh.Interpreter().eval("new " + PRE_AUTHENTICATOR + "()");
        if (useEmailAsLogin) {
          authenticator.authenticateByEmailAddress(comp.getCompanyId(), username, passwd);
        } else {
          authenticator.authenticateByUserId(comp.getCompanyId(), username, passwd);
        }
      }
    }catch (AuthException ae) {
      Logger.debug(this, "Username : " + username + " failed to login", ae);
      throw new DotSecurityException(ae.getMessage(),ae);
    }catch (Exception e) {
      Logger.error(this, e.getMessage(), e);
      throw new DotSecurityException(e.getMessage(),e);
    }
    UserAPI userAPI=APILocator.getUserAPI();
    if (comp.getAuthType().equals(Company.AUTH_TYPE_ID)) {
      _user = userAPI.loadUserById(username,userAPI.getSystemUser(),false);
    } else {
      _user = userAPI.loadByUserByEmail(username, userAPI.getSystemUser(), false);
    }
    if (PublicEncryptionFactory.digestString(passwd).equals(_user.getPassword())) {
View Full Code Here

  }

  public static String prettyDateSince(Date date, Locale locale) {

    if (locale == null) {
      Company company = PublicCompanyFactory.getDefaultCompany();
      locale = company.getLocale();
    }
    String sinceMessage = null;
    SimpleDateFormat sdf = new SimpleDateFormat("h:mm aa, MMMM d?, yyyy", locale);
    String modDate = sdf.format(date);
    modDate = modDate.replaceAll("\\?", "th");
View Full Code Here

    return prettyDateSince(date, null);
  }

  public static String prettyDateSinceWithDate(Date date, Locale locale) {
    if (locale == null) {
      Company company = PublicCompanyFactory.getDefaultCompany();
      locale = company.getLocale();
    }
    SimpleDateFormat sdf = new SimpleDateFormat("h:mm aa, MMMM d?, yyyy", locale);
    String modDate = sdf.format(date);
    modDate = modDate.replaceAll("\\?", "th");
View Full Code Here

      boolean passwordReset, String firstName, String middleName,
      String lastName, String nickName, boolean male, Date birthday,
      String emailAddress, Locale locale)
    throws PortalException, SystemException {

    Company company = CompanyUtil.findByPrimaryKey(companyId);

    if (!company.isStrangers() && !hasAdministrator(companyId)) {
      throw new PrincipalException();
    }

    return UserLocalManagerUtil.addUser(
      companyId, autoUserId, userId, autoPassword, password1, password2,
View Full Code Here

TOP

Related Classes of com.liferay.portal.model.Company

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.