Package scap.check.content

Examples of scap.check.content.SourceContext


            showHelp(cmdLineProcessor.getOptions());
            System.exit(0);
        }

        XCCDFOptions xccdfOptions = commandLineResult.getXccdfOptions();
        SourceContext checklist = new FileSourceContent(commandLineResult.getChecklistFile(), xccdfOptions.isCleanupTempFiles());     
        Log4jConsoleConfiguration.configure(xccdfOptions.isVerboseOutput());
        logBuildProperties();

        if (xccdfOptions.isVerboseOutput()) {
            System.out.println();
            System.out.println("Using the following commandline parameters:");
//            System.out.println("  Result Directory: " + resultDirectory.getAbsolutePath());
            System.out.println("  XCCDF File: " + checklist.getSourceContent().getId());
            System.out.println("  Tailoring File: " + ((xccdfOptions.getTailoringInstance() != null) ? xccdfOptions.getTailoringInstance().getSourceContent().getLocalFile().getAbsoluteFile() : "none"));
            System.out.println("  Profile: " + xccdfOptions.getProfileId());
            System.out.print("  CPE Dictionary File(s):");
            List<SourceContext> dictionaries = xccdfOptions.getCpeDictionaries();
            if (dictionaries.isEmpty()) {
View Full Code Here


      } catch (ParseException e) {
        throw new ContentException(e);
      }
    }

    SourceContext context = getPlatform().getPlatformSpecification().getSourceContext();
    for (CheckFactRefType node : data.getCheckFactRefList()) {
      // Build the contentRef
      CheckContentRef contentRef = new CheckContentRef(node.getHref(), node.getIdRef());

      // Generate the check
View Full Code Here

    this.checkSystem = checkSystem;
  }

  public AssessmentFile resolve(Check check, CheckContentRef contentRef) {

    SourceContext context = check.getContext();
    SourceContextData contextData = sourceContextToSourceContextDataMap.get(context);
    if (contextData == null) {
      contextData = new SourceContextData(context);
      sourceContextToSourceContextDataMap.put(context, contextData);
    }

    String href = contentRef.getHref();
    SourceContext resolvedContext = contextData.resolveHref(href);

    AssessmentFile retval = null;
    if (resolvedContext != null) {
      if (sourceContextToAssessmentFileMap.containsKey(resolvedContext)) {
        retval = sourceContextToAssessmentFileMap.get(resolvedContext);
      } else {
        try {
          retval = checkSystem.newAssessmentFile(resolvedContext);
          sourceContextToAssessmentFileMap.put(resolvedContext, retval);
        } catch (IOException e) {
          log.error("Unable to create assessment file for content: "+resolvedContext.getId(), e);
          retval = null;
        } catch (XmlException e) {
          log.error("Unable to create assessment file for content: "+resolvedContext.getId(), e);
          retval = null;
        }
      }
    } // else do nothing
    return retval;
View Full Code Here

    public SourceContextData(SourceContext context) {
      this.context = context;
    }

    public SourceContext resolveHref(String href) {
      SourceContext retval;
      if (hrefToSourceContextMap.containsKey(href)) {
        retval = hrefToSourceContextMap.get(href);
        // if a previous resolution failed then the retval will be null
        if (retval == null) {
          String msg = new StringBuilder()
          .append("Unable to resolve href '")
          .append(href)
          .append("' in the context '")
          .append(context.getId())
          .append("'. See previous error.")
          .toString();
          log.error(msg);
        }
      } else {
        log.debug("Resolving check content for: "+href);
        try {
          retval = context.resolveRelative(href);
          if (retval == null) {
            // not resolvable
            log.error("The href '"+href+"' was not found in the content context: "+context.getId());
          }
        } catch (IOException e) {
          // some error occured resolving the file
          retval = null;
          String msg = new StringBuilder()
            .append("Unable to resolve href '")
            .append(href)
            .append("' in the context '")
            .append(context.getId())
            .append("'. Error: ")
            .append(e.getLocalizedMessage())
            .toString();
          log.error(msg, e);
        }
        hrefToSourceContextMap.put(href, retval);
      }
      log.debug("Using source: "+retval.getUri());
      return retval;
    }
View Full Code Here

TOP

Related Classes of scap.check.content.SourceContext

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.