コード例 #1
0
ファイル: LDAPUtility.java プロジェクト: ankushchhabra/repo
  public static boolean isUserLocked(Long value, Map<String, String> mapConnectorParams) {
    ALNTLogger.debug(LDAPUtility.class.getName(), "isUserLocked()", "entered for value : " + value);
    boolean accountLocked = false;
    int UF_ACCOUNTDISABLE = 0x0002;
    String encodePwd =
        LDAPUtility.getLdapColumnName(
            mapConnectorParams, CommonConstants.LDAP_PWD_ENCODING_COLUMN_NAME);
    boolean pwdEncodeEnabled = true;

    if (StringUtils.isNotNullOrNotEmpty(encodePwd) && encodePwd.equalsIgnoreCase("No")) {
      pwdEncodeEnabled = false;
    } else {

      pwdEncodeEnabled = true;
    }

    if (pwdEncodeEnabled) {

      if (value != null && ((value & UF_ACCOUNTDISABLE) == UF_ACCOUNTDISABLE)) {
        accountLocked = true;
      }
    } else {
      if (value != null && (value.intValue() == 1)) accountLocked = true;
      else accountLocked = false;
    }
    ALNTLogger.debug(
        LDAPUtility.class.getName(), "isUserLocked()", "accountLocked : " + accountLocked);
    return accountLocked;
  }
コード例 #2
0
  public String getConfigParamValue(String configParamName, boolean getConfigParamLabel)
      throws ALNTApplicationException, ALNTSystemException {
    String configParamValue = null;
    String configParamLabel = null;
    try {
      if (getConfigParamLabel) {
        ApplicationConfig applicationConfig = applicationConfigDAO.load(configParamName);
        if (null != applicationConfig) {
          configParamValue = applicationConfig.getConfigParamValue();
          configParamLabel = applicationConfig.getConfigParamLabel();
        }
      } else {
        configParamValue = CacheManager.getApplicationConfig(configParamName);
      }

    } catch (Exception ex) {
      ALNTLogger.error(
          this.getClass().getName(),
          "getConfigParamValue",
          "Error in loading Application config ::" + configParamName);
      handleException(ex);
    }
    if (getConfigParamLabel && StringUtils.isNotNullOrNotEmpty(configParamLabel))
      return configParamLabel + " : " + configParamValue;
    return configParamValue;
  }
コード例 #3
0
ファイル: LDAPUtility.java プロジェクト: ankushchhabra/repo
  public static String getLdapColumnName(Map<String, String> paramsMap, String columnName) {

    String ldapColumnName = null;
    if (paramsMap != null && !paramsMap.isEmpty()) {
      ldapColumnName = paramsMap.get(columnName);
    }

    if (StringUtils.isNullOrEmpty(ldapColumnName)) ldapColumnName = getADColumnName(columnName);

    return ldapColumnName;
  }
コード例 #4
0
 public String getShardOutboundFolder() throws ALNTApplicationException, ALNTSystemException {
   String sharedFolder = getConfigParamValue(CommonConstants.SHARED_FOLDER);
   if (StringUtils.isNullOrEmpty(sharedFolder)) return "";
   StringBuffer outbounFolder = new StringBuffer(sharedFolder);
   if (sharedFolder != null
       && !(sharedFolder.equals(""))
       && (sharedFolder.length() > 0)
       && (!sharedFolder.endsWith("\\"))) outbounFolder.append(CommonConstants.fileSeparator);
   outbounFolder.append(CommonConstants.OUTBOUND_FOLDER);
   return outbounFolder.toString();
 }
コード例 #5
0
 public String getBrowserPageTitle() throws ALNTApplicationException, ALNTSystemException {
   String title = null;
   try {
     title = getConfigParamValue(BROWSER_PAGE_TITLE);
     ALNTLogger.debug(
         this.getClass().getName(),
         "getBrowserPageTitle()",
         "Browser page title configured as : " + title);
   } catch (Exception ex) {
     ALNTLogger.error(this.getClass().getName(), "getBrowserPageTitle()", ex);
     handleException(ex);
   }
   return StringUtils.isEmpty(title) ? I18NUtil.getI18NValue("browser.title.default") : title;
 }
コード例 #6
0
 public String fetchUser(HttpServletRequest request) {
   ALNTLogger.info(
       "ALNTEncodedURLValidator".getClass().getName(),
       "fetchUser",
       "fetching user using Encoded URL");
   String userId = "";
   String encodedUserId =
       request.getQueryString().contains(CommonConstants.CALLING_APP_LOGGEDIN_USER)
           ? request.getParameter(CommonConstants.CALLING_APP_LOGGEDIN_USER)
           : null;
   if (StringUtils.isNotNullOrNotEmpty(encodedUserId)) {
     try {
       userId = EncodeDecodeUtil.decodeBase64(encodedUserId);
     } catch (Exception e) {
       ALNTLogger.error("ALNTEncodedURLValidator".getClass().getName(), "fetchUser", e, true);
       userId = "";
     }
   }
   return userId;
 }
コード例 #7
0
ファイル: LDAPUtility.java プロジェクト: ankushchhabra/repo
  public static Long getUserAccessValue(
      String userId, LDAPConnectorService ldapConnection, Map<String, String> mapConnectorParams)
      throws ALNTApplicationException {
    ALNTLogger.debug(
        LDAPUtility.class.getName(), "getUserAccessValue()", "entered for userId : " + userId);
    Long userAccessValue = null;
    String encodePwd =
        LDAPUtility.getLdapColumnName(
            mapConnectorParams, CommonConstants.LDAP_PWD_ENCODING_COLUMN_NAME);
    String accountControlColumnName =
        LDAPUtility.getLdapColumnName(
            mapConnectorParams, CommonConstants.LDAP_ACCOUNT_CONTROL_COLUMN_NAME);

    boolean pwdEncodeEnabled = true;

    if (StringUtils.isNotNullOrNotEmpty(encodePwd) && encodePwd.equalsIgnoreCase("No")) {
      pwdEncodeEnabled = false;
    } else {

      pwdEncodeEnabled = true;
    }

    try {
      DirContext dirContext = ldapConnection.getDirContext();
      SearchControls ctls = new SearchControls();
      ctls.setSearchScope(SearchControls.SUBTREE_SCOPE);

      String searchObjClass = ldapConnection.getObjectClass();
      if (searchObjClass == null || searchObjClass.trim().length() == 0) {
        searchObjClass = "user";
      }

      ALNTLogger.debug(
          LDAPUtility.class.getName(),
          "getUserAccessValue()",
          "Search object class:  " + searchObjClass);

      String userIdColumnName = (String) mapConnectorParams.get("userIdColumnName");
      if (StringUtils.isNullOrEmpty(userIdColumnName)) {
        userIdColumnName = "sAMAccountName";
      }

      NamingEnumeration attrs =
          dirContext.search(
              ldapConnection.getCompleteBaseDns(),
              "(&(objectClass=" + searchObjClass + ")(" + userIdColumnName + "=" + userId + "))",
              ctls);

      while (attrs.hasMoreElements()) {
        SearchResult result = (SearchResult) attrs.next();
        Attributes userAttrs = result.getAttributes();
        if (userAttrs != null) {

          Attribute userAccess =
              userAttrs
                  //						.get(LDAPConstants.LDAP_ATTR_UserAccntControl);
                  .get(accountControlColumnName);

          if (!pwdEncodeEnabled) {
            if (userAccess == null) userAccessValue = Long.parseLong("0");
            else {

              String status = userAccess.get().toString();
              if (status.equalsIgnoreCase("true")) userAccessValue = Long.parseLong("1");
              else userAccessValue = Long.parseLong("0");
            }

          } else {

            if (userAccess != null && !"".equals(userAccess.get().toString())) {

              // accountLocked = isAccountDisable(Integer.parseInt(userAccess.get().toString()));

              userAccessValue = Long.parseLong(userAccess.get().toString());
            }
          }
        }
      }
    } catch (Exception e) {
      ALNTLogger.error(
          LDAPUtility.class.getName(), "getUserAccessValue(): Error finding user locked: ", e);
    }
    ALNTLogger.debug(
        LDAPUtility.class.getName(),
        "getUserAccessValue()",
        "returning userAccessValue : " + userAccessValue);
    return userAccessValue;
  }
コード例 #8
0
  @SuppressWarnings("unchecked")
  public void jobToBeExecuted(JobExecutionContext context) {
    ALNTLogger.info(this.getClass().getName(), "jobToBeExecuted()", "Begin");
    try {
      ISchedulerConfigService schedulerConfigService =
          (ISchedulerConfigService) ServiceLocator.findService("schedulerConfigService");

      JobDetail jobDetails = context.getJobDetail();
      Long id = (Long) jobDetails.getJobDataMap().get("JOB_ID");
      String jobPgmName = (String) jobDetails.getJobDataMap().get("JOB_NAME");

      String triggerGroup = context.getTrigger().getGroup();
      boolean recoveringJob = false;
      JobStatus jobStatus = null;
      if (!StringUtils.isEmpty(triggerGroup) && triggerGroup.equals("RECOVERING_JOBS")) {
        recoveringJob = true;
        jobDetails.getJobDataMap().put(SchedulerUtil.RECOVERING_JOB, Boolean.TRUE);

        List<JobStatus> jobStatusList = null;
        try {
          jobStatusList =
              schedulerConfigService.loadJobStatus(
                  jobDetails.getJobDataMap().getLongValue("JOB_ID"));
          if (null != jobStatusList && jobStatusList.size() > 0) {
            jobStatus = jobStatusList.get(jobStatusList.size() - 1);
            jobDetails
                .getJobDataMap()
                .put(SchedulerUtil.RECOVERING_JOB_STATUS_ID, jobStatus.getId());
            jobStatus.setJobStatus(CommonConstants.JOB_STATUS_RUNNING);
          }
        } catch (Exception ex) {
          ALNTLogger.error(this.getClass().getName(), "jobToBeExecuted", ex);
        }
      }

      if (jobStatus == null) {
        jobStatus = new JobStatus();
        jobStatus.setJobId(id);
        Date nextFireTime = context.getNextFireTime();
        jobStatus.setNextFireTime(nextFireTime);
        jobStatus.setJobName(jobPgmName);
        jobStatus.setCreationDate(new Date());
        jobStatus.setJobStatus(CommonConstants.JOB_STATUS_RUNNING);
      }

      Job job = context.getJobInstance();
      if (job instanceof IJobsWithResult) {
        IJobsWithResult jobWithResult = (IJobsWithResult) job;
        JobResultWriter writer = new JobResultWriter();
        writer.setCreateDate(jobStatus.getCreationDate());
        writer.setJobId(id);
        writer.init();
        jobWithResult.setResultWriter(writer);
      }
      if (jobDetails.getJobDataMap().containsKey(SchedulerUtil.RETRYING_JOB)
          && jobDetails.getJobDataMap().containsKey(SchedulerUtil.FAILED_JOB_STATUS_ID)
          && jobDetails.getJobDataMap().containsKey(SchedulerUtil.RETRYING_JOB_STATUS_ID)) {
        if (jobDetails.getJobDataMap().getBoolean(SchedulerUtil.RETRYING_JOB)) {
          jobStatus.setOriginalFailedId(
              jobDetails.getJobDataMap().getLong(SchedulerUtil.FAILED_JOB_STATUS_ID));
          jobStatus.setRetryForId(
              jobDetails.getJobDataMap().getLong(SchedulerUtil.RETRYING_JOB_STATUS_ID));
        }
      }

      jobStatus = schedulerConfigService.saveJobStatus(jobStatus);

      jobDetails.getJobDataMap().put("JobStatus_ID", jobStatus.getId());
      if (recoveringJob) {

      } else if (jobStatus.getRetryForId() != null) {
        JobStatus retryingForJobStatus =
            schedulerConfigService.loadJobStatusByStatusId(jobStatus.getRetryForId());
        if (retryingForJobStatus != null) {
          // get the job status object that simply says retrying and append it with new job status
          // id
          retryingForJobStatus.setJobStatus(
              CommonConstants.JOB_STATUS_RETRIED + " - " + jobStatus.getId());
          schedulerConfigService.saveJobStatus(retryingForJobStatus);
        }
      }

      ALNTLogger.info(this.getClass().getName(), "jobToBeExecuted()", "End");
    } catch (ALNTSystemException e) {
      ALNTLogger.error(this.getClass().getName(), "jobToBeExecuted()", "Error ::" + e.getMessage());
    } catch (ALNTApplicationException e) {
      ALNTLogger.error(this.getClass().getName(), "jobToBeExecuted", "Error ::" + e.getMessage());
    }
  }