1
2
3
4
5
6 package gov.nist.secauto.oscal.tools.cli.core.commands.poam;
7
8 import gov.nist.secauto.metaschema.core.model.util.JsonUtil;
9 import gov.nist.secauto.metaschema.core.model.util.XmlUtil;
10 import gov.nist.secauto.metaschema.core.model.validation.JsonSchemaContentValidator;
11 import gov.nist.secauto.metaschema.core.model.validation.XmlSchemaContentValidator;
12 import gov.nist.secauto.metaschema.core.util.CollectionUtil;
13 import gov.nist.secauto.metaschema.core.util.ObjectUtils;
14 import gov.nist.secauto.oscal.lib.OscalBindingContext;
15 import gov.nist.secauto.oscal.tools.cli.core.commands.AbstractDeprecatedOscalValidationSubcommand;
16
17 import java.io.IOException;
18 import java.io.InputStream;
19 import java.util.LinkedList;
20 import java.util.List;
21
22 import javax.xml.transform.Source;
23
24 class ValidateSubcommand
25 extends AbstractDeprecatedOscalValidationSubcommand {
26 @Override
27 public String getDescription() {
28 return "Check that the specified OSCAL instance is well-formed"
29 + " and valid to the Plan of Actions and Milestones model.";
30 }
31
32 @Override
33 protected XmlSchemaContentValidator getOscalXmlSchemas() throws IOException {
34 List<Source> retval = new LinkedList<>();
35 retval.add(
36 XmlUtil.getStreamSource(ObjectUtils.requireNonNull(
37 OscalBindingContext.class.getResource("/schema/xml/oscal-poam_schema.xsd"))));
38 return new XmlSchemaContentValidator(CollectionUtil.unmodifiableList(retval));
39 }
40
41 @Override
42 protected JsonSchemaContentValidator getOscalJsonSchema() throws IOException {
43 try (InputStream is = ObjectUtils.requireNonNull(
44 OscalBindingContext.class.getResourceAsStream("/schema/json/oscal-poam_schema.json"))) {
45 return new JsonSchemaContentValidator(JsonUtil.toJsonObject(is));
46 }
47 }
48 }