public void importFromLDAP(long companyId) throws Exception {
    if (!LDAPSettingsUtil.isImportEnabled(companyId)) {
      return;
    }

    long defaultUserId = UserLocalServiceUtil.getDefaultUserId(companyId);

    if (LockLocalServiceUtil.hasLock(
        defaultUserId, PortalLDAPImporterUtil.class.getName(), companyId)) {

      if (_log.isDebugEnabled()) {
        _log.debug(
            "Skipping LDAP import for company "
                + companyId
                + "because another LDAP import is in process");
      }

      return;
    }

    LockLocalServiceUtil.lock(
        defaultUserId,
        PortalLDAPImporterUtil.class.getName(),
        companyId,
        PortalLDAPImporterImpl.class.getName(),
        false,
        PropsValues.LDAP_IMPORT_LOCK_EXPIRATION_TIME);

    long threadLocalCompanyId = CompanyThreadLocal.getCompanyId();

    try {
      if (threadLocalCompanyId == CompanyConstants.SYSTEM) {
        CompanyThreadLocal.setCompanyId(companyId);
      }

      long[] ldapServerIds =
          StringUtil.split(PrefsPropsUtil.getString(companyId, "ldap.server.ids"), 0L);

      for (long ldapServerId : ldapServerIds) {
        importFromLDAP(ldapServerId, companyId);
      }

      for (int ldapServerId = 0; ; ldapServerId++) {
        String postfix = LDAPSettingsUtil.getPropertyPostfix(ldapServerId);

        String providerUrl =
            PrefsPropsUtil.getString(companyId, PropsKeys.LDAP_BASE_PROVIDER_URL + postfix);

        if (Validator.isNull(providerUrl)) {
          break;
        }

        importFromLDAP(ldapServerId, companyId);
      }
    } finally {
      LockLocalServiceUtil.unlock(PortalLDAPImporterUtil.class.getName(), companyId);

      CompanyThreadLocal.setCompanyId(threadLocalCompanyId);
    }
  }
  protected void verifyLDAPProperties() throws Exception {
    long[] companyIds = PortalInstances.getCompanyIdsBySQL();

    for (long companyId : companyIds) {
      UnicodeProperties properties = new UnicodeProperties();

      long[] ldapServerIds =
          StringUtil.split(PrefsPropsUtil.getString(companyId, "ldap.server.ids"), 0L);

      for (long ldapServerId : ldapServerIds) {
        String postfix = LDAPSettingsUtil.getPropertyPostfix(ldapServerId);

        for (String key : _LDAP_KEYS) {
          String value = PrefsPropsUtil.getString(companyId, key + postfix, null);

          if (value == null) {
            properties.put(key + postfix, StringPool.BLANK);
          }
        }
      }

      if (!properties.isEmpty()) {
        CompanyLocalServiceUtil.updatePreferences(companyId, properties);
      }
    }
  }
  protected Attribute getUsers(
      long ldapServerId,
      long companyId,
      LdapContext ldapContext,
      Attributes attributes,
      UserGroup userGroup,
      Properties groupMappings)
      throws Exception {

    Attribute attribute = attributes.get(groupMappings.getProperty("user"));

    if (attribute == null) {
      return null;
    }

    String postfix = LDAPSettingsUtil.getPropertyPostfix(ldapServerId);

    String baseDN = PrefsPropsUtil.getString(companyId, PropsKeys.LDAP_BASE_DN + postfix);

    StringBundler sb = new StringBundler(7);

    sb.append("(&");
    sb.append(
        PrefsPropsUtil.getString(companyId, PropsKeys.LDAP_IMPORT_GROUP_SEARCH_FILTER + postfix));
    sb.append("(");
    sb.append(groupMappings.getProperty("groupName"));
    sb.append("=");
    sb.append(escapeValue(userGroup.getName()));
    sb.append("))");

    return PortalLDAPUtil.getMultivaluedAttribute(
        companyId, ldapContext, baseDN, sb.toString(), attribute);
  }
  public LayoutTemplateAutoDeployer() {
    try {
      baseDir =
          PrefsPropsUtil.getString(
              PropsKeys.AUTO_DEPLOY_DEPLOY_DIR, PropsValues.AUTO_DEPLOY_DEPLOY_DIR);
      destDir = DeployUtil.getAutoDeployDestDir();
      appServerType = ServerDetector.getServerId();
      unpackWar =
          PrefsPropsUtil.getBoolean(
              PropsKeys.AUTO_DEPLOY_UNPACK_WAR, PropsValues.AUTO_DEPLOY_UNPACK_WAR);
      filePattern = StringPool.BLANK;
      jbossPrefix =
          PrefsPropsUtil.getString(
              PropsKeys.AUTO_DEPLOY_JBOSS_PREFIX, PropsValues.AUTO_DEPLOY_JBOSS_PREFIX);
      unpackWar =
          PrefsPropsUtil.getBoolean(
              PropsKeys.AUTO_DEPLOY_UNPACK_WAR, PropsValues.AUTO_DEPLOY_UNPACK_WAR);

      List<String> jars = new ArrayList<String>();

      addRequiredJar(jars, "util-java.jar");

      this.jars = jars;

      checkArguments();
    } catch (Exception e) {
      _log.error(e);
    }
  }
Beispiel #5
0
  protected TicketValidator getTicketValidator(long companyId) throws Exception {

    TicketValidator ticketValidator = _ticketValidators.get(companyId);

    if (ticketValidator != null) {
      return ticketValidator;
    }

    String serverName =
        PrefsPropsUtil.getString(companyId, PropsKeys.CAS_SERVER_NAME, PropsValues.CAS_SERVER_NAME);
    String serverUrl =
        PrefsPropsUtil.getString(companyId, PropsKeys.CAS_SERVER_URL, PropsValues.CAS_SERVER_URL);
    String loginUrl =
        PrefsPropsUtil.getString(companyId, PropsKeys.CAS_LOGIN_URL, PropsValues.CAS_LOGIN_URL);

    Cas20ProxyTicketValidator cas20ProxyTicketValidator = new Cas20ProxyTicketValidator(serverUrl);

    Map<String, String> parameters = new HashMap<String, String>();

    parameters.put("serverName", serverName);
    parameters.put("casServerUrlPrefix", serverUrl);
    parameters.put("casServerLoginUrl", loginUrl);
    parameters.put("redirectAfterValidation", "false");

    cas20ProxyTicketValidator.setCustomParameters(parameters);

    _ticketValidators.put(companyId, cas20ProxyTicketValidator);

    return cas20ProxyTicketValidator;
  }
  protected void validate(
      Map<Locale, String> nameMap,
      String xsl,
      boolean smallImage,
      String smallImageURL,
      File smallImageFile,
      byte[] smallImageBytes)
      throws PortalException, SystemException {

    if (nameMap.isEmpty()) {
      throw new TemplateNameException();
    } else if (Validator.isNull(xsl)) {
      throw new TemplateXslException();
    }

    String[] imageExtensions =
        PrefsPropsUtil.getStringArray(PropsKeys.JOURNAL_IMAGE_EXTENSIONS, StringPool.COMMA);

    if (smallImage
        && Validator.isNull(smallImageURL)
        && (smallImageFile != null)
        && (smallImageBytes != null)) {

      String smallImageName = smallImageFile.getName();

      if (smallImageName != null) {
        boolean validSmallImageExtension = false;

        for (int i = 0; i < imageExtensions.length; i++) {
          if (StringPool.STAR.equals(imageExtensions[i])
              || StringUtil.endsWith(smallImageName, imageExtensions[i])) {

            validSmallImageExtension = true;

            break;
          }
        }

        if (!validSmallImageExtension) {
          throw new TemplateSmallImageNameException(smallImageName);
        }
      }

      long smallImageMaxSize = PrefsPropsUtil.getLong(PropsKeys.JOURNAL_IMAGE_SMALL_MAX_SIZE);

      if ((smallImageMaxSize > 0)
          && ((smallImageBytes == null) || (smallImageBytes.length > smallImageMaxSize))) {

        throw new TemplateSmallImageSizeException();
      }
    }
  }
  protected int authenticate(
      long companyId, String emailAddress, String screenName, long userId, String password)
      throws Exception {

    if (!AuthSettingsUtil.isLDAPAuthEnabled(companyId)) {
      if (_log.isDebugEnabled()) {
        _log.debug("Authenticator is not enabled");
      }

      return SUCCESS;
    }

    if (_log.isDebugEnabled()) {
      _log.debug("Authenticator is enabled");
    }

    long[] ldapServerIds =
        StringUtil.split(PrefsPropsUtil.getString(companyId, "ldap.server.ids"), 0L);

    for (long ldapServerId : ldapServerIds) {
      int result =
          authenticate(companyId, ldapServerId, emailAddress, screenName, userId, password);

      if (result == SUCCESS) {
        return result;
      }
    }

    for (int ldapServerId = 0; ; ldapServerId++) {
      String postfix = LDAPSettingsUtil.getPropertyPostfix(ldapServerId);

      String providerUrl =
          PrefsPropsUtil.getString(companyId, PropsKeys.LDAP_BASE_PROVIDER_URL + postfix);

      if (Validator.isNull(providerUrl)) {
        break;
      }

      int result =
          authenticate(companyId, ldapServerId, emailAddress, screenName, userId, password);

      if (result == SUCCESS) {
        return result;
      }
    }

    return authenticateRequired(companyId, userId, emailAddress, screenName, true, FAILURE);
  }
 @Override
 public boolean isSendPasswordResetLink() throws SystemException {
   return PrefsPropsUtil.getBoolean(
       getCompanyId(),
       PropsKeys.COMPANY_SECURITY_SEND_PASSWORD_RESET_LINK,
       PropsValues.COMPANY_SECURITY_SEND_PASSWORD_RESET_LINK);
 }
 @Override
 public String getAuthType() throws SystemException {
   return PrefsPropsUtil.getString(
       getCompanyId(),
       PropsKeys.COMPANY_SECURITY_AUTH_TYPE,
       PropsValues.COMPANY_SECURITY_AUTH_TYPE);
 }
  protected int authenticateRequired(
      long companyId,
      long userId,
      String emailAddress,
      String screenName,
      boolean allowOmniadmin,
      int failureCode)
      throws Exception {

    // Make exceptions for omniadmins so that if they break the LDAP
    // configuration, they can still login to fix the problem

    if (allowOmniadmin
        && (authenticateOmniadmin(companyId, emailAddress, screenName, userId) == SUCCESS)) {

      return SUCCESS;
    }

    if (PrefsPropsUtil.getBoolean(companyId, PropsKeys.LDAP_AUTH_REQUIRED)) {

      return failureCode;
    } else {
      return SUCCESS;
    }
  }
  private void _setTemporaryValue(PortletPreferences portletPreferences, String key, String value)
      throws ReadOnlyException {

    _oldValues.put(key, PrefsPropsUtil.getString(key));

    portletPreferences.setValue(key, value);
  }
 @Override
 public boolean isStrangersWithMx() throws SystemException {
   return PrefsPropsUtil.getBoolean(
       getCompanyId(),
       PropsKeys.COMPANY_SECURITY_STRANGERS_WITH_MX,
       PropsValues.COMPANY_SECURITY_STRANGERS_WITH_MX);
 }
  @Override
  public boolean hasCompanyMx(String emailAddress) throws SystemException {
    emailAddress = StringUtil.toLowerCase(emailAddress.trim());

    int pos = emailAddress.indexOf(CharPool.AT);

    if (pos == -1) {
      return false;
    }

    String mx = emailAddress.substring(pos + 1);

    if (mx.equals(getMx())) {
      return true;
    }

    String[] mailHostNames =
        PrefsPropsUtil.getStringArray(
            getCompanyId(),
            PropsKeys.ADMIN_MAIL_HOST_NAMES,
            StringPool.NEW_LINE,
            PropsValues.ADMIN_MAIL_HOST_NAMES);

    for (int i = 0; i < mailHostNames.length; i++) {
      if (StringUtil.equalsIgnoreCase(mx, mailHostNames[i])) {
        return true;
      }
    }

    return false;
  }
  protected void deleteLDAPServer(ActionRequest actionRequest) throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    long ldapServerId = ParamUtil.getLong(actionRequest, "ldapServerId");

    // Remove preferences

    String postfix = LDAPSettingsUtil.getPropertyPostfix(ldapServerId);

    String[] keys = new String[_KEYS.length];

    for (int i = 0; i < _KEYS.length; i++) {
      keys[i] = _KEYS[i] + postfix;
    }

    CompanyServiceUtil.removePreferences(themeDisplay.getCompanyId(), keys);

    // Update preferences

    PortletPreferences preferences = PrefsPropsUtil.getPreferences(themeDisplay.getCompanyId());

    UnicodeProperties properties = new UnicodeProperties();

    String ldapServerIds = preferences.getValue("ldap.server.ids", StringPool.BLANK);

    ldapServerIds = StringUtil.remove(ldapServerIds, String.valueOf(ldapServerId));

    properties.put("ldap.server.ids", ldapServerIds);

    CompanyServiceUtil.updatePreferences(themeDisplay.getCompanyId(), properties);
  }
  protected String[] getAllowedFileExtensions(
      PortletConfig portletConfig, PortletRequest portletRequest, PortletResponse portletResponse)
      throws PortalException {

    String portletName = portletConfig.getPortletName();

    if (!portletName.equals(DLPortletKeys.MEDIA_GALLERY_DISPLAY)) {
      return PrefsPropsUtil.getStringArray(PropsKeys.DL_FILE_EXTENSIONS, StringPool.COMMA);
    } else {
      ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

      PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

      DLPortletInstanceSettings dlPortletInstanceSettings =
          DLPortletInstanceSettings.getInstance(themeDisplay.getLayout(), portletDisplay.getId());

      Set<String> extensions = new HashSet<>();

      String[] mimeTypes = dlPortletInstanceSettings.getMimeTypes();

      for (String mimeType : mimeTypes) {
        extensions.addAll(MimeTypesUtil.getExtensions(mimeType));
      }

      return extensions.toArray(new String[extensions.size()]);
    }
  }
 @Override
 public boolean isSiteLogo() throws SystemException {
   return PrefsPropsUtil.getBoolean(
       getCompanyId(),
       PropsKeys.COMPANY_SECURITY_SITE_LOGO,
       PropsValues.COMPANY_SECURITY_SITE_LOGO);
 }
 @Override
 public boolean isStrangersVerify() throws SystemException {
   return PrefsPropsUtil.getBoolean(
       getCompanyId(),
       PropsKeys.COMPANY_SECURITY_STRANGERS_VERIFY,
       PropsValues.COMPANY_SECURITY_STRANGERS_VERIFY);
 }
  public static String getDefaultRegularThemeId(long companyId) throws SystemException {

    String defaultRegularThemeId =
        PrefsPropsUtil.getString(companyId, PropsKeys.DEFAULT_REGULAR_THEME_ID);

    return PortalUtil.getJsSafePortletId(defaultRegularThemeId);
  }
 @Override
 public boolean isAutoLogin() throws SystemException {
   return PrefsPropsUtil.getBoolean(
       getCompanyId(),
       PropsKeys.COMPANY_SECURITY_AUTO_LOGIN,
       PropsValues.COMPANY_SECURITY_AUTO_LOGIN);
 }
  protected void doInit() throws Exception {
    if (_companyId > 0) {
      Company company = CompanyLocalServiceUtil.getCompany(_companyId);

      _domain = company.getMx();
      _userName = PrefsPropsUtil.getString(_companyId, PropsKeys.GOOGLE_APPS_USERNAME);
      _password = PrefsPropsUtil.getString(_companyId, PropsKeys.GOOGLE_APPS_PASSWORD);
    }

    Http.Options options = new Http.Options();

    options.addPart("accountType", "HOSTED");

    String emailAddress = _userName;

    if (!emailAddress.contains(StringPool.AT)) {
      emailAddress = _userName.concat(StringPool.AT).concat(_domain);
    }

    options.addPart("Email", emailAddress);

    options.addPart("Passwd", _password);
    options.addPart("service", "apps");
    options.setLocation("https://www.google.com/accounts/ClientLogin");
    options.setPost(true);

    String content = HttpUtil.URLtoString(options);

    Properties properties = PropertiesUtil.load(content);

    _error = properties.getProperty("Error");

    if (_error != null) {
      _log.info("Unable to initialize authentication token: " + _error);
    }

    _authenticationToken = properties.getProperty("Auth");

    if (_authenticationToken != null) {
      _log.info("Authentication token " + _authenticationToken);
    }

    _initTime = System.currentTimeMillis();
  }
  @Override
  public void close() throws Exception {
    PortletPreferences portletPreferences = PrefsPropsUtil.getPreferences(0, false);

    for (Map.Entry<String, String> entry : _oldValues.entrySet()) {
      portletPreferences.setValue(entry.getKey(), entry.getValue());
    }

    portletPreferences.store();
  }
  public User importLDAPUser(long companyId, String emailAddress, String screenName)
      throws Exception {

    long[] ldapServerIds =
        StringUtil.split(PrefsPropsUtil.getString(companyId, "ldap.server.ids"), 0L);

    for (long ldapServerId : ldapServerIds) {
      User user = importLDAPUser(ldapServerId, companyId, emailAddress, screenName);

      if (user != null) {
        return user;
      }
    }

    for (int ldapServerId = 0; ; ldapServerId++) {
      String postfix = LDAPSettingsUtil.getPropertyPostfix(ldapServerId);

      String providerUrl =
          PrefsPropsUtil.getString(companyId, PropsKeys.LDAP_BASE_PROVIDER_URL + postfix);

      if (Validator.isNull(providerUrl)) {
        break;
      }

      User user = importLDAPUser(ldapServerId, companyId, emailAddress, screenName);

      if (user != null) {
        return user;
      }
    }

    if (_log.isDebugEnabled()) {
      if (Validator.isNotNull(emailAddress)) {
        _log.debug(
            "User with the email address " + emailAddress + " was not found in any LDAP servers");
      } else {
        _log.debug(
            "User with the screen name " + screenName + " was not found in any LDAP servers");
      }
    }

    return null;
  }
Beispiel #23
0
  public static String getAutoDeployDestDir() throws Exception {
    String destDir =
        PrefsPropsUtil.getString(PropsKeys.AUTO_DEPLOY_DEST_DIR, PropsValues.AUTO_DEPLOY_DEST_DIR);

    if (Validator.isNull(destDir)) {
      destDir = getAutoDeployServerDestDir();
    }

    return destDir;
  }
  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();
    }
  }
  protected NtlmManager getNtlmManager(long companyId) throws SystemException {

    String domain =
        PrefsPropsUtil.getString(companyId, PropsKeys.NTLM_DOMAIN, PropsValues.NTLM_DOMAIN);
    String domainController =
        PrefsPropsUtil.getString(
            companyId, PropsKeys.NTLM_DOMAIN_CONTROLLER, PropsValues.NTLM_DOMAIN_CONTROLLER);
    String domainControllerName =
        PrefsPropsUtil.getString(
            companyId,
            PropsKeys.NTLM_DOMAIN_CONTROLLER_NAME,
            PropsValues.NTLM_DOMAIN_CONTROLLER_NAME);
    String serviceAccount =
        PrefsPropsUtil.getString(
            companyId, PropsKeys.NTLM_SERVICE_ACCOUNT, PropsValues.NTLM_SERVICE_ACCOUNT);
    String servicePassword =
        PrefsPropsUtil.getString(
            companyId, PropsKeys.NTLM_SERVICE_PASSWORD, PropsValues.NTLM_SERVICE_PASSWORD);

    NtlmManager ntlmManager = _ntlmManagers.get(companyId);

    if (ntlmManager == null) {
      ntlmManager =
          new NtlmManager(
              domain, domainController, domainControllerName, serviceAccount, servicePassword);

      _ntlmManagers.put(companyId, ntlmManager);
    } else {
      if (!Validator.equals(ntlmManager.getDomain(), domain)
          || !Validator.equals(ntlmManager.getDomainController(), domainController)
          || !Validator.equals(ntlmManager.getDomainControllerName(), domainControllerName)
          || !Validator.equals(ntlmManager.getServiceAccount(), serviceAccount)
          || !Validator.equals(ntlmManager.getServicePassword(), servicePassword)) {

        ntlmManager.setConfiguration(
            domain, domainController, domainControllerName, serviceAccount, servicePassword);
      }
    }

    return ntlmManager;
  }
  protected UnicodeProperties addLDAPServer(long companyId, UnicodeProperties properties)
      throws Exception {

    String defaultPostfix = LDAPSettingsUtil.getPropertyPostfix(0);

    String[] defaultKeys = new String[_KEYS.length];

    for (int i = 0; i < _KEYS.length; i++) {
      defaultKeys[i] = _KEYS[i] + defaultPostfix;
    }

    long ldapServerId = CounterLocalServiceUtil.increment();

    String postfix = LDAPSettingsUtil.getPropertyPostfix(ldapServerId);

    String[] keys = properties.keySet().toArray(new String[0]);

    for (String key : keys) {
      if (ArrayUtil.contains(defaultKeys, key)) {
        String value = properties.remove(key);

        if (key.equals(PropsKeys.LDAP_SECURITY_CREDENTIALS + defaultPostfix)
            && value.equals(Portal.TEMP_OBFUSCATION_VALUE)) {

          value = PrefsPropsUtil.getString(PropsKeys.LDAP_SECURITY_CREDENTIALS);
        }

        properties.setProperty(key.replace(defaultPostfix, postfix), value);
      }
    }

    PortletPreferences preferences = PrefsPropsUtil.getPreferences(companyId);

    String ldapServerIds = preferences.getValue("ldap.server.ids", StringPool.BLANK);

    ldapServerIds = StringUtil.add(ldapServerIds, String.valueOf(ldapServerId));

    properties.setProperty("ldap.server.ids", ldapServerIds);

    return properties;
  }
  public void importFromLDAP(long ldapServerId, long companyId) throws Exception {

    if (!LDAPSettingsUtil.isImportEnabled(companyId)) {
      return;
    }

    LdapContext ldapContext = PortalLDAPUtil.getContext(ldapServerId, companyId);

    if (ldapContext == null) {
      return;
    }

    try {
      Properties userMappings = LDAPSettingsUtil.getUserMappings(ldapServerId, companyId);
      Properties userExpandoMappings =
          LDAPSettingsUtil.getUserExpandoMappings(ldapServerId, companyId);
      Properties contactMappings = LDAPSettingsUtil.getContactMappings(ldapServerId, companyId);
      Properties contactExpandoMappings =
          LDAPSettingsUtil.getContactExpandoMappings(ldapServerId, companyId);
      Properties groupMappings = LDAPSettingsUtil.getGroupMappings(ldapServerId, companyId);

      String importMethod = PrefsPropsUtil.getString(companyId, PropsKeys.LDAP_IMPORT_METHOD);

      if (importMethod.equals(_IMPORT_BY_GROUP)) {
        importFromLDAPByGroup(
            ldapServerId,
            companyId,
            ldapContext,
            userMappings,
            userExpandoMappings,
            contactMappings,
            contactExpandoMappings,
            groupMappings);
      } else if (importMethod.equals(_IMPORT_BY_USER)) {
        importFromLDAPByUser(
            ldapServerId,
            companyId,
            ldapContext,
            userMappings,
            userExpandoMappings,
            contactMappings,
            contactExpandoMappings,
            groupMappings);
      }
    } catch (Exception e) {
      _log.error("Error importing LDAP users and groups", e);
    } finally {
      if (ldapContext != null) {
        ldapContext.close();
      }
    }
  }
Beispiel #28
0
  public static String getAutoDeployServerDestDir() throws Exception {
    String destDir = null;

    String serverId = GetterUtil.getString(ServerDetector.getServerId());

    if (serverId.equals(ServerDetector.TOMCAT_ID)) {
      destDir =
          PrefsPropsUtil.getString(
              PropsKeys.AUTO_DEPLOY_TOMCAT_DEST_DIR, PropsValues.AUTO_DEPLOY_TOMCAT_DEST_DIR);
    } else {
      destDir = PrefsPropsUtil.getString("auto.deploy." + serverId + ".dest.dir");
    }

    if (Validator.isNull(destDir)) {
      destDir =
          PrefsPropsUtil.getString(
              PropsKeys.AUTO_DEPLOY_DEFAULT_DEST_DIR, PropsValues.AUTO_DEPLOY_DEFAULT_DEST_DIR);
    }

    destDir = StringUtil.replace(destDir, CharPool.BACK_SLASH, CharPool.SLASH);

    return destDir;
  }
  public PrefsPropsTemporarySwapper(String firstKey, Object firstValue, Object... keysAndValues)
      throws Exception {

    PortletPreferences portletPreferences = PrefsPropsUtil.getPreferences(0, false);

    _setTemporaryValue(portletPreferences, firstKey, String.valueOf(firstValue));

    for (int i = 0; i < keysAndValues.length; i += 2) {
      String key = String.valueOf(keysAndValues[i]);
      String value = String.valueOf(keysAndValues[i + 1]);

      _setTemporaryValue(portletPreferences, key, value);
    }

    portletPreferences.store();
  }
Beispiel #30
0
  @Override
  public boolean isFilterEnabled(HttpServletRequest request, HttpServletResponse response) {

    try {
      long companyId = PortalUtil.getCompanyId(request);

      if (PrefsPropsUtil.getBoolean(
          companyId, PropsKeys.CAS_AUTH_ENABLED, PropsValues.CAS_AUTH_ENABLED)) {

        return true;
      }
    } catch (Exception e) {
      _log.error(e, e);
    }

    return false;
  }