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.util.CollectionUtil;
11 import gov.nist.secauto.metaschema.core.util.ObjectUtils;
12 import gov.nist.secauto.oscal.lib.OscalBindingContext;
13 import gov.nist.secauto.oscal.tools.cli.core.commands.oscal.AbstractDeprecatedOscalValidationSubcommand;
14
15 import org.json.JSONObject;
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 public 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 List<Source> 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 CollectionUtil.unmodifiableList(retval);
39 }
40
41 @Override
42 protected JSONObject getOscalJsonSchema() throws IOException {
43 try (InputStream is = ObjectUtils.requireNonNull(
44 OscalBindingContext.class.getResourceAsStream("/schema/json/oscal-poam_schema.json"))) {
45 return JsonUtil.toJsonObject(is);
46 }
47 }
48 }