Ejemplo n.º 1
0
  public PasswordPolicy getPasswordPolicy() throws PortalException, SystemException {

    if (_passwordPolicy == null) {
      _passwordPolicy = PasswordPolicyLocalServiceUtil.getPasswordPolicyByUserId(getUserId());
    }

    return _passwordPolicy;
  }
Ejemplo n.º 2
0
  protected void validate(
      long companyId,
      boolean autoPassword,
      String password1,
      String password2,
      boolean autoScreenName,
      String screenName,
      String emailAddress,
      String firstName,
      String lastName,
      long organizationId,
      long locationId)
      throws PortalException, SystemException {

    if (!autoScreenName) {
      validateScreenName(companyId, screenName);
    }

    if (!autoPassword) {
      PasswordPolicy passwordPolicy =
          PasswordPolicyLocalServiceUtil.getDefaultPasswordPolicy(companyId);

      PwdToolkitUtil.validate(companyId, 0, password1, password2, passwordPolicy);
    }

    if (!Validator.isEmailAddress(emailAddress)) {
      throw new UserEmailAddressException();
    } else {
      // As per caGrid requirements portal can have duplicate email address for a particular company
      // Id.
      /*try {
      	User user = UserUtil.findByC_EA(companyId, emailAddress);

      	if (user != null) {
      		throw new DuplicateUserEmailAddressException();
      	}
      } catch (NoSuchUserException nsue) {
      }*/

      String[] reservedEmailAddresses =
          PrefsPropsUtil.getStringArray(companyId, PropsUtil.ADMIN_RESERVED_EMAIL_ADDRESSES);

      for (int i = 0; i < reservedEmailAddresses.length; i++) {
        if (emailAddress.equalsIgnoreCase(reservedEmailAddresses[i])) {
          throw new ReservedUserEmailAddressException();
        }
      }
    }

    if (Validator.isNull(firstName)) {
      throw new ContactFirstNameException();
    } else if (Validator.isNull(lastName)) {
      throw new ContactLastNameException();
    }
  }
  @Override
  protected void doImportStagedModel(
      PortletDataContext portletDataContext, PasswordPolicy passwordPolicy) throws Exception {

    long userId = portletDataContext.getUserId(passwordPolicy.getUserUuid());

    ServiceContext serviceContext =
        portletDataContext.createServiceContext(
            passwordPolicy, PasswordPolicyPortletDataHandler.NAMESPACE);

    PasswordPolicy existingPasswordPolicy =
        PasswordPolicyLocalServiceUtil.fetchPasswordPolicyByUuidAndCompanyId(
            passwordPolicy.getUuid(), portletDataContext.getCompanyId());

    if (existingPasswordPolicy == null) {
      existingPasswordPolicy =
          PasswordPolicyLocalServiceUtil.fetchPasswordPolicy(
              portletDataContext.getCompanyId(), passwordPolicy.getName());
    }

    PasswordPolicy importedPasswordPolicy = null;

    if (existingPasswordPolicy == null) {
      serviceContext.setUuid(passwordPolicy.getUuid());

      importedPasswordPolicy =
          PasswordPolicyLocalServiceUtil.addPasswordPolicy(
              userId,
              passwordPolicy.isDefaultPolicy(),
              passwordPolicy.getName(),
              passwordPolicy.getDescription(),
              passwordPolicy.getChangeable(),
              passwordPolicy.isChangeRequired(),
              passwordPolicy.getMinAge(),
              passwordPolicy.getCheckSyntax(),
              passwordPolicy.isAllowDictionaryWords(),
              passwordPolicy.getMinAlphanumeric(),
              passwordPolicy.getMinLength(),
              passwordPolicy.getMinLowerCase(),
              passwordPolicy.getMinNumbers(),
              passwordPolicy.getMinSymbols(),
              passwordPolicy.getMinUpperCase(),
              passwordPolicy.getRegex(),
              passwordPolicy.isHistory(),
              passwordPolicy.getHistoryCount(),
              passwordPolicy.isExpireable(),
              passwordPolicy.getMaxAge(),
              passwordPolicy.getWarningTime(),
              passwordPolicy.getGraceLimit(),
              passwordPolicy.isLockout(),
              passwordPolicy.getMaxFailure(),
              passwordPolicy.getLockoutDuration(),
              passwordPolicy.getResetFailureCount(),
              passwordPolicy.getResetTicketMaxAge(),
              serviceContext);
    } else {
      importedPasswordPolicy =
          PasswordPolicyLocalServiceUtil.updatePasswordPolicy(
              existingPasswordPolicy.getPasswordPolicyId(),
              passwordPolicy.getName(),
              passwordPolicy.getDescription(),
              passwordPolicy.isChangeable(),
              passwordPolicy.isChangeRequired(),
              passwordPolicy.getMinAge(),
              passwordPolicy.isCheckSyntax(),
              passwordPolicy.isAllowDictionaryWords(),
              passwordPolicy.getMinAlphanumeric(),
              passwordPolicy.getMinLength(),
              passwordPolicy.getMinLowerCase(),
              passwordPolicy.getMinNumbers(),
              passwordPolicy.getMinSymbols(),
              passwordPolicy.getMinUpperCase(),
              passwordPolicy.getRegex(),
              passwordPolicy.isHistory(),
              passwordPolicy.getHistoryCount(),
              passwordPolicy.isExpireable(),
              passwordPolicy.getMaxAge(),
              passwordPolicy.getWarningTime(),
              passwordPolicy.getGraceLimit(),
              passwordPolicy.isLockout(),
              passwordPolicy.getMaxFailure(),
              passwordPolicy.getLockoutDuration(),
              passwordPolicy.getResetFailureCount(),
              passwordPolicy.getResetTicketMaxAge(),
              serviceContext);
    }

    portletDataContext.importClassedModel(
        passwordPolicy, importedPasswordPolicy, PasswordPolicyPortletDataHandler.NAMESPACE);
  }