Package com.liferay.portal.model

Examples of com.liferay.portal.model.Company


  public KeyValuePair decryptUserId(
      String companyId, String userId, String password)
    throws PortalException, SystemException {

    Company company = CompanyUtil.findByPrimaryKey(companyId);

    try {
      userId = Encryptor.decrypt(company.getKeyObj(), userId);
    }
    catch (EncryptorException ee) {
      throw new SystemException(ee);
    }

    String liferayUserId = userId;

    try {
      PrincipalFinder principalFinder = (PrincipalFinder)InstancePool.get(
        PropsUtil.get(PropsUtil.PRINCIPAL_FINDER));

      liferayUserId = principalFinder.toLiferay(userId);
    }
    catch (Exception e) {
    }

    User user = UserUtil.findByPrimaryKey(liferayUserId);

    try {
      password = Encryptor.decrypt(company.getKeyObj(), password);
    }
    catch (EncryptorException ee) {
      throw new SystemException(ee);
    }
View Full Code Here


    catch (Exception e) {
    }

    User user = UserUtil.findByPrimaryKey(liferayUserId);

    Company company = CompanyUtil.findByPrimaryKey(user.getCompanyId());

    try {
      return Encryptor.encrypt(company.getKeyObj(), userId);
    }
    catch (EncryptorException ee) {
      throw new SystemException(ee);
    }
  }
View Full Code Here

      return 0;
    }

    // Send email notification

    Company company = CompanyUtil.findByPrimaryKey(companyId);

    String adminName = company.getAdminName();

    String subject = registrationEmail.getSubject();
    String body = registrationEmail.getBody();

    List users = UserUtil.findByC_P(companyId, "password");

    for (int i = 0; i < users.size(); i++) {
      User user = (User)users.get(i);

      user.setPassword(PwdToolkitUtil.generate());

      UserUtil.update(user);

      subject = StringUtil.replace(
        subject,
        new String[] {"[$ADMIN_EMAIL_ADDRESS$]", "[$ADMIN_NAME$]",
                "[$COMPANY_MX$]", "[$COMPANY_NAME$]",
                "[$PORTAL_URL$]",
                "[$USER_EMAIL_ADDRESS$]", "[$USER_NAME$]",
                "[$USER_PASSWORD$]"},
        new String[] {company.getEmailAddress(), adminName,
                company.getMx(), company.getName(),
                company.getPortalURL(),
                user.getEmailAddress(), user.getFullName(),
                user.getPassword()});

      body = StringUtil.replace(
        body,
        new String[] {"[$ADMIN_EMAIL_ADDRESS$]", "[$ADMIN_NAME$]",
                "[$COMPANY_MX$]", "[$COMPANY_NAME$]",
                "[$PORTAL_URL$]",
                "[$USER_EMAIL_ADDRESS$]", "[$USER_NAME$]",
                "[$USER_PASSWORD$]"},
        new String[] {company.getEmailAddress(), adminName,
                company.getMx(), company.getName(),
                company.getPortalURL(),
                user.getEmailAddress(), user.getFullName(),
                user.getPassword()});

      try {
        MailManagerUtil.sendEmail(new MailMessage(
          new InternetAddress(company.getEmailAddress(), adminName),
          new InternetAddress(
            user.getEmailAddress(), user.getFullName()),
          subject, body));
      }
      catch (IOException ioe) {
View Full Code Here

   
    UserUtil.update(user);

    // Send new password

    Company company = CompanyUtil.findByPrimaryKey(companyId);

    String url=(company.getPortalURL().contains("://") ? "" : "https://") +
            company.getPortalURL() + "/c/portal_public/login?my_account_cmd=ereset&my_user_id="+user.getUserId()+
            "&token="+token+"&switchLocale="+locale.getLanguage()+"_"+locale.getCountry();
   
    String body = LanguageUtil.format(locale, "reset-password-email-body", url, false);
   
    try {
      Mailer m = new Mailer();
      m.setToEmail(emailAddress);
      m.setToName(user.getFullName());
      m.setSubject(LanguageUtil.get(locale, "reset-password-email-subject"));
      m.setHTMLBody(body.toString());
      m.setFromName(company.getName());
      m.setFromEmail(company.getEmailAddress());
      m.sendMessage();
    }
    catch (Exception ioe) {
      throw new SystemException(ioe);
    }
View Full Code Here

    String userId = login;

    int authResult = Authenticator.FAILURE;

    Company company = PortalUtil.getCompany(req);

        //Search for the system user
        User systemUser = APILocator.getUserAPI().getSystemUser();

        if ( company.getAuthType().equals( Company.AUTH_TYPE_EA ) ) {

            //Verify that the System User is not been use to log in inside the system
            if ( systemUser.getEmailAddress().equalsIgnoreCase( login ) ) {
                SecurityLogger.logInfo(this.getClass(),"An invalid attempt to login as a System User has been made  - you cannot login as the System User");
                throw new AuthException( "Unable to login as System User - you cannot login as the System User." );
            }

            authResult = UserManagerUtil.authenticateByEmailAddress( company.getCompanyId(), login, password );
            userId = UserManagerUtil.getUserId( company.getCompanyId(), login );

        } else {

            //Verify that the System User is not been use to log in inside the system
            if ( systemUser.getUserId().equalsIgnoreCase( login ) ) {
                SecurityLogger.logInfo(this.getClass(),"An invalid attempt to login as a System User has been made  - you cannot login as the System User");
                throw new AuthException( "Unable to login as System User - you cannot login as the System User." );
            }

            authResult = UserManagerUtil.authenticateByUserId( company.getCompanyId(), login, password );
        }

    try {
      PrincipalFinder principalFinder =
        (PrincipalFinder)InstancePool.get(
View Full Code Here

  private void _sendPassword(HttpServletRequest req) throws Exception {
    String emailAddress = ParamUtil.getString(
      req, "my_account_email_address");
    String userId = emailAddress;

    Company company = PortalUtil.getCompany(req);

    if (company.getAuthType().equals(Company.AUTH_TYPE_ID)) {     
      User user = UserLocalManagerUtil.getUserById(userId);
      emailAddress = user.getEmailAddress();
    }
   
    Locale locale = (Locale)req.getSession().getAttribute(Globals.LOCALE_KEY);
View Full Code Here

    validate(
      companyId, autoUserId, userId, autoPassword, password1, password2,
      firstName, lastName, emailAddress);

    Company company = CompanyUtil.findByPrimaryKey(companyId);

    if (autoUserId) {
      userId =
        companyId + "." +
        Long.toString(CounterManagerUtil.increment(
          User.class.getName() + "." + companyId));
    }

    User user = UserUtil.create(userId);

    if (autoPassword) {
      password1 = PwdToolkitUtil.generate();
    }

    int passwordsLifespan = GetterUtil.getInteger(
      PropsUtil.get(PropsUtil.PASSWORDS_LIFESPAN));

    Date expirationDate = null;
    if (passwordsLifespan > 0) {
      expirationDate = new Date(
        System.currentTimeMillis() + Time.DAY * passwordsLifespan);
    }

    user.setCompanyId(companyId);
    user.setCreateDate(new Date());
    user.setPassword(Encryptor.digest(password1));
    user.setPasswordEncrypted(true);
    user.setPasswordExpirationDate(expirationDate);
    user.setPasswordReset(passwordReset);
    user.setFirstName(firstName);
    user.setMiddleName(middleName);
    user.setLastName(lastName);
    user.setNickName(nickName);
    user.setMale(male);
    user.setBirthday(birthday);
    user.setEmailAddress(emailAddress);

    //removed because we don't need this and on import the system was throwing a null pointer for users with @dotcms.org
//    if (user.hasCompanyMx()) {
//      MailManagerUtil.addUser(
//        userId, password1, firstName, middleName, lastName,
//        emailAddress);
//    }

    User defaultUser = getDefaultUser(companyId);

    String greeting = null;
    try {
      greeting =
        LanguageUtil.get(companyId, locale, "welcome") +
        ", " + user.getFullName() + "!";
    }
    catch (LanguageException le) {
      greeting = "Welcome, " + user.getFullName() + "!";
    }

    user.setLanguageId(locale.toString());
    user.setTimeZoneId(defaultUser.getTimeZoneId());
    user.setSkinId(defaultUser.getSkinId());
    user.setDottedSkins(defaultUser.isDottedSkins());
    user.setRoundedSkins(defaultUser.isRoundedSkins());
    user.setGreeting(greeting);
    user.setResolution(defaultUser.getResolution());
    user.setRefreshRate(defaultUser.getRefreshRate());
    user.setLayoutIds("");
    user.setActive(true);

    UserUtil.update(user);

    UserConfig userConfig =
      AdminConfigManagerUtil.getUserConfig(companyId);

    // Add user groups

//    List groups = new ArrayList();
//
//    String groupNames[] = userConfig.getGroupNames();
//
//    for (int i = 0; groupNames != null && i < groupNames.length; i++) {
//      try {
//        groups.add(GroupUtil.findByC_N(companyId, groupNames[i]));
//      }
//      catch (NoSuchGroupException nsge) {
//      }
//    }
//
//    UserUtil.setGroups(userId, groups);

    // Add user roles

//    List roles = new ArrayList();
//
//    String roleNames[] = userConfig.getRoleNames();
//
//    for (int i = 0; roleNames != null && i < roleNames.length; i++) {
//      try {
//        Role role =
//          RoleLocalManagerUtil.getRoleByName(companyId, roleNames[i]);
//
//        roles.add(role);
//      }
//      catch (NoSuchRoleException nsre) {
//      }
//    }
//
//    UserUtil.setRoles(userId, roles);

    // Send email notification

    EmailConfig registrationEmail = userConfig.getRegistrationEmail();

    if (registrationEmail != null && registrationEmail.isSend()) {
      String adminName = company.getAdminName();

      String subject = registrationEmail.getSubject();
      subject = StringUtil.replace(
        subject,
        new String[] {"[$ADMIN_EMAIL_ADDRESS$]", "[$ADMIN_NAME$]",
                "[$COMPANY_MX$]", "[$COMPANY_NAME$]",
                "[$PORTAL_URL$]",
                "[$USER_EMAIL_ADDRESS$]", "[$USER_ID$]",
                "[$USER_NAME$]", "[$USER_PASSWORD$]"},
        new String[] {company.getEmailAddress(), adminName,
                company.getMx(), company.getName(),
                company.getPortalURL(),
                user.getEmailAddress(), user.getUserId(),
                user.getFullName(), password1});

      String body = registrationEmail.getBody();
      body = StringUtil.replace(
        body,
        new String[] {"[$ADMIN_EMAIL_ADDRESS$]", "[$ADMIN_NAME$]",
                "[$COMPANY_MX$]", "[$COMPANY_NAME$]",
                "[$PORTAL_URL$]",
                "[$USER_EMAIL_ADDRESS$]", "[$USER_ID$]",
                "[$USER_NAME$]", "[$USER_PASSWORD$]"},
        new String[] {company.getEmailAddress(), adminName,
                company.getMx(), company.getName(),
                company.getPortalURL(),
                user.getEmailAddress(), user.getUserId(),
                user.getFullName(), password1});

      try {
        InternetAddress from =
          new InternetAddress(company.getEmailAddress(), adminName);

        InternetAddress[] to = new InternetAddress[] {
          new InternetAddress(
            user.getEmailAddress(), user.getFullName())
        };

        InternetAddress[] cc = null;

        InternetAddress[] bcc = new InternetAddress[] {
          new InternetAddress(company.getEmailAddress(), adminName)
        };

        MailManagerUtil.sendEmail(new MailMessage(
          from, to, cc, bcc, subject, body));
      }
View Full Code Here

//        Config.initializeConfig();
//        com.dotmarketing.util.Config.setMyApp(config.getServletContext());



        Company company = PublicCompanyFactory.getDefaultCompany();
        TimeZone companyTimeZone = company.getTimeZone();
        TimeZone.setDefault(companyTimeZone);
        Logger.info(this, "InitServlet: Setting Default Timezone: " + companyTimeZone.getDisplayName());

        String _dbType = DbConnectionFactory.getDBType();
        String _dailect = "";
View Full Code Here

   * default company and default logo.
   *
   */
  public static void createDefaultCompany() {
    try {
      Company c = getDefaultCompany();
      c.setPortalURL("localhost");
      c
          .setKey("rO0ABXNyABRqYXZhLnNlY3VyaXR5LktleVJlcL35T7OImqVDAgAETAAJYWxnb3JpdGhtdAASTGphdmEvbGFuZy9TdHJpbmc7WwAHZW5jb2RlZHQAAltCTAAGZm9ybWF0cQB+AAFMAAR0eXBldAAbTGphdmEvc2VjdXJpdHkvS2V5UmVwJFR5cGU7eHB0AANERVN1cgACW0Ks8xf4BghU4AIAAHhwAAAACBksSlj3ReywdAADUkFXfnIAGWphdmEuc2VjdXJpdHkuS2V5UmVwJFR5cGUAAAAAAAAAABIAAHhyAA5qYXZhLmxhbmcuRW51bQAAAAAAAAAAEgAAeHB0AAZTRUNSRVQ=");
      c.setHomeURL("localhost");
      c.setMx("dotcms.com");
      c.setName("dotcms.com");
      c.setShortName("dotcms.com");
      c.setType("biz");
      c.setSize("100");
      c.setState("FL");
      c.setStreet("3059 Grand Ave.");
      c.setCity("Miami");
      c.setZip("33133");
      c.setPhone("3058581422");
      c.setEmailAddress("support@dotcms.com");
      c.setAuthType("emailAddress");
      c.setStrangers(false);
      c.setAutoLogin(true);
      c.setModified(true);

      CompanyUtil.update(c);

      /* Set the DM logo */
      File f = new File(FileUtil.getRealPath("/html/images/shim.gif"));
View Full Code Here

        return encryptString(getRandomPassword());
    }
   
    public static String encryptString(String x){
        try{
            Company c = PublicCompanyFactory.getDefaultCompany();
            Logger.debug(PublicEncryptionFactory.class, "c:"+c);
            Key k = c.getKeyObj();
            return Encryptor.encrypt(k, x);
           
        }
        catch(EncryptorException e){
            throw new DotRuntimeException("Encryption Failed");
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.