Exemplo n.º 1
0
  /**
   * Set the status of SCAP detailed result file upload settings for the given organization.
   *
   * @param sessionKey User's session key.
   * @param orgId ID of organization to work with.
   * @param newSettings New settings of the SCAP detailed result file upload.
   * @return Returns 1 for successfull change.
   * @xmlrpc.doc Set the status of SCAP detailed result file upload settings for the given
   *     organization.
   * @xmlrpc.param #session_key()
   * @xmlrpc.param #param("int", "orgId")
   * @xmlrpc.param #struct("scap_upload_info") #prop_desc("boolean", "enabled", "Aggregation of
   *     detailed SCAP results is enabled.") #prop_desc("int", "size_limit", "Limit (in Bytes) for a
   *     single SCAP file upload.") #struct_end()
   * @xmlrpc.returntype #return_int_success()
   */
  public int setPolicyForScapFileUpload(
      String sessionKey, Integer orgId, Map<String, Object> newSettings) {
    Set<String> validKeys = new HashSet<String>();
    validKeys.add("enabled");
    validKeys.add("size_limit");
    validateMap(validKeys, newSettings);

    getSatAdmin(sessionKey);
    OrgConfig orgConfig = verifyOrgExists(orgId).getOrgConfig();
    if (newSettings.containsKey("enabled")) {
      Boolean enabled = (Boolean) newSettings.get("enabled");
      orgConfig.setScapfileUploadEnabled(enabled);
    }
    if (newSettings.containsKey("size_limit")) {
      Long sizeLimit = new Long(((Integer) newSettings.get("size_limit")).longValue());
      orgConfig.setScapFileSizelimit(sizeLimit);
    }
    return 1;
  }
Exemplo n.º 2
0
  /**
   * Set the status of SCAP result deletion settings for the given organization.
   *
   * @param sessionKey User's session key.
   * @param orgId ID of organization to work with.
   * @param newSettings New settings of the SCAP result deletion settings.
   * @return Returns 1 for successfull change.
   * @xmlrpc.doc Set the status of SCAP result deletion settins for the given organization.
   * @xmlrpc.param #session_key()
   * @xmlrpc.param #param("int", "orgId")
   * @xmlrpc.param #struct("scap_deletion_info") #prop_desc("boolean", "enabled", "Deletion of SCAP
   *     results is enabled") #prop_desc("int", "retention_period", "Period (in days) after which a
   *     scan can be deleted (if enabled).") #struct_end()
   * @xmlrpc.returntype #return_int_success()
   */
  public int setPolicyForScapResultDeletion(
      String sessionKey, Integer orgId, Map<String, Object> newSettings) {
    Set<String> validKeys = new HashSet<String>();
    validKeys.add("enabled");
    validKeys.add("retention_period");
    validateMap(validKeys, newSettings);

    getSatAdmin(sessionKey);
    OrgConfig orgConfig = verifyOrgExists(orgId).getOrgConfig();
    if (newSettings.containsKey("enabled")) {
      if ((Boolean) newSettings.get("enabled")) {
        orgConfig.setScapRetentionPeriodDays(new Long(90));
      } else {
        orgConfig.setScapRetentionPeriodDays(null);
      }
    }
    if (newSettings.containsKey("retention_period")) {
      Long retentionPeriod = new Long(((Integer) newSettings.get("retention_period")).longValue());
      if (orgConfig.getScapRetentionPeriodDays() != null) {
        orgConfig.setScapRetentionPeriodDays(retentionPeriod);
      }
    }
    return 1;
  }