Skip to content

Commit

Permalink
Integrated changes based on metaschema-java 1.0.0 refactoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
david-waltermire committed Aug 28, 2023
1 parent 17cb210 commit d612448
Show file tree
Hide file tree
Showing 17 changed files with 154 additions and 133 deletions.
13 changes: 4 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>gov.nist.secauto</groupId>
<artifactId>oss-parent</artifactId>
<version>26</version>
<version>27-SNAPSHOT</version>
</parent>
<groupId>gov.nist.secauto.oscal.tools.oscal-cli</groupId>
<artifactId>cli-core</artifactId>
Expand Down Expand Up @@ -78,8 +78,8 @@
</mailingLists>
<properties>
<!-- metaschema dependencies -->
<dependency.metaschema-framework.version>0.12.0</dependency.metaschema-framework.version>
<dependency.liboscal-java.version>3.0.0</dependency.liboscal-java.version>
<dependency.metaschema-framework.version>1.0.0-SNAPSHOT</dependency.metaschema-framework.version>
<dependency.liboscal-java.version>3.0.1-SNAPSHOT</dependency.liboscal-java.version>

<!-- site configuration -->
<site.url>https://pages.nist.gov/metaschema-java/</site.url>
Expand Down Expand Up @@ -228,12 +228,7 @@
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

package gov.nist.secauto.oscal.tools.cli.core;

import gov.nist.secauto.metaschema.model.common.util.IVersionInfo;
import gov.nist.secauto.metaschema.core.util.IVersionInfo;

public class OscalCliVersion implements IVersionInfo {

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/gov/nist/secauto/oscal/tools/cli/core/CLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@

import gov.nist.secauto.metaschema.cli.processor.CLIProcessor;
import gov.nist.secauto.metaschema.cli.processor.ExitStatus;
import gov.nist.secauto.metaschema.model.MetaschemaVersion;
import gov.nist.secauto.metaschema.model.common.util.IVersionInfo;
import gov.nist.secauto.metaschema.model.common.util.MetaschemaJavaVersion;
import gov.nist.secauto.metaschema.model.common.util.ObjectUtils;
import gov.nist.secauto.metaschema.core.MetaschemaJavaVersion;
import gov.nist.secauto.metaschema.core.model.MetaschemaVersion;
import gov.nist.secauto.metaschema.core.util.IVersionInfo;
import gov.nist.secauto.metaschema.core.util.ObjectUtils;
import gov.nist.secauto.oscal.lib.LibOscalVersion;
import gov.nist.secauto.oscal.lib.OscalVersion;
import gov.nist.secauto.oscal.tools.cli.core.commands.assessmentplan.AssessmentPlanCommand;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import gov.nist.secauto.metaschema.cli.processor.command.DefaultExtraArgument;
import gov.nist.secauto.metaschema.cli.processor.command.ExtraArgument;
import gov.nist.secauto.metaschema.cli.processor.command.ICommandExecutor;
import gov.nist.secauto.metaschema.model.common.util.ObjectUtils;
import gov.nist.secauto.metaschema.core.util.ObjectUtils;

import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Option;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,17 @@

package gov.nist.secauto.oscal.tools.cli.core.commands.assessmentplan;

import gov.nist.secauto.metaschema.binding.io.xml.XmlUtil;
import gov.nist.secauto.metaschema.model.common.util.CollectionUtil;
import gov.nist.secauto.metaschema.model.common.util.ObjectUtils;
import gov.nist.secauto.metaschema.model.common.validation.JsonSchemaContentValidator;
import gov.nist.secauto.metaschema.core.model.util.JsonUtil;
import gov.nist.secauto.metaschema.core.model.util.XmlUtil;
import gov.nist.secauto.metaschema.core.util.CollectionUtil;
import gov.nist.secauto.metaschema.core.util.ObjectUtils;
import gov.nist.secauto.oscal.lib.OscalBindingContext;
import gov.nist.secauto.oscal.tools.cli.core.commands.oscal.AbstractOscalValidationSubcommand;

import org.json.JSONObject;

import java.io.IOException;
import java.io.InputStream;
import java.util.LinkedList;
import java.util.List;

Expand All @@ -52,16 +53,16 @@ public String getDescription() {
protected List<Source> getOscalXmlSchemas() throws IOException {
List<Source> retval = new LinkedList<>();
retval.add(
ObjectUtils.requireNonNull(
XmlUtil.getStreamSource(
OscalBindingContext.class.getResource("/schema/xml/oscal_assessment-plan_schema.xsd"))));
XmlUtil.getStreamSource(ObjectUtils.requireNonNull(
OscalBindingContext.class.getResource("/schema/xml/oscal_assessment-plan_schema.xsd"))));
return CollectionUtil.unmodifiableList(retval);
}

@Override
protected JSONObject getOscalJsonSchema() {
return JsonSchemaContentValidator.toJsonObject(
ObjectUtils.requireNonNull(
OscalBindingContext.class.getResourceAsStream("/schema/json/oscal_assessment-plan_schema.json")));
protected JSONObject getOscalJsonSchema() throws IOException {
try (InputStream is = ObjectUtils.requireNonNull(
OscalBindingContext.class.getResourceAsStream("/schema/json/oscal_assessment-plan_schema.json"))) {
return JsonUtil.toJsonObject(is);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,17 @@

package gov.nist.secauto.oscal.tools.cli.core.commands.assessmentresults;

import gov.nist.secauto.metaschema.binding.io.xml.XmlUtil;
import gov.nist.secauto.metaschema.model.common.util.CollectionUtil;
import gov.nist.secauto.metaschema.model.common.util.ObjectUtils;
import gov.nist.secauto.metaschema.model.common.validation.JsonSchemaContentValidator;
import gov.nist.secauto.metaschema.core.model.util.JsonUtil;
import gov.nist.secauto.metaschema.core.model.util.XmlUtil;
import gov.nist.secauto.metaschema.core.util.CollectionUtil;
import gov.nist.secauto.metaschema.core.util.ObjectUtils;
import gov.nist.secauto.oscal.lib.OscalBindingContext;
import gov.nist.secauto.oscal.tools.cli.core.commands.oscal.AbstractOscalValidationSubcommand;

import org.json.JSONObject;

import java.io.IOException;
import java.io.InputStream;
import java.util.LinkedList;
import java.util.List;

Expand All @@ -52,16 +53,16 @@ public String getDescription() {
protected List<Source> getOscalXmlSchemas() throws IOException {
List<Source> retval = new LinkedList<>();
retval.add(
ObjectUtils.requireNonNull(
XmlUtil.getStreamSource(
OscalBindingContext.class.getResource("/schema/xml/oscal_assessment-results_schema.xsd"))));
XmlUtil.getStreamSource(ObjectUtils.requireNonNull(
OscalBindingContext.class.getResource("/schema/xml/oscal_assessment-results_schema.xsd"))));
return CollectionUtil.unmodifiableList(retval);
}

@Override
protected JSONObject getOscalJsonSchema() {
return JsonSchemaContentValidator.toJsonObject(
ObjectUtils.requireNonNull(
OscalBindingContext.class.getResourceAsStream("/schema/json/oscal_assessment-results_schema.json")));
protected JSONObject getOscalJsonSchema() throws IOException {
try (InputStream is = ObjectUtils.requireNonNull(
OscalBindingContext.class.getResourceAsStream("/schema/json/oscal_assessment-results_schema.json"))) {
return JsonUtil.toJsonObject(is);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,17 @@

package gov.nist.secauto.oscal.tools.cli.core.commands.catalog;

import gov.nist.secauto.metaschema.binding.io.xml.XmlUtil;
import gov.nist.secauto.metaschema.model.common.util.CollectionUtil;
import gov.nist.secauto.metaschema.model.common.util.ObjectUtils;
import gov.nist.secauto.metaschema.model.common.validation.JsonSchemaContentValidator;
import gov.nist.secauto.metaschema.core.model.util.JsonUtil;
import gov.nist.secauto.metaschema.core.model.util.XmlUtil;
import gov.nist.secauto.metaschema.core.util.CollectionUtil;
import gov.nist.secauto.metaschema.core.util.ObjectUtils;
import gov.nist.secauto.oscal.lib.OscalBindingContext;
import gov.nist.secauto.oscal.tools.cli.core.commands.oscal.AbstractOscalValidationSubcommand;

import org.json.JSONObject;

import java.io.IOException;
import java.io.InputStream;
import java.util.LinkedList;
import java.util.List;

Expand All @@ -52,15 +53,16 @@ public String getDescription() {
protected List<Source> getOscalXmlSchemas() throws IOException {
List<Source> retval = new LinkedList<>();
retval.add(
ObjectUtils.requireNonNull(
XmlUtil.getStreamSource(OscalBindingContext.class.getResource("/schema/xml/oscal_catalog_schema.xsd"))));
XmlUtil.getStreamSource(ObjectUtils.requireNonNull(
OscalBindingContext.class.getResource("/schema/xml/oscal_catalog_schema.xsd"))));
return CollectionUtil.unmodifiableList(retval);
}

@Override
protected JSONObject getOscalJsonSchema() {
return JsonSchemaContentValidator.toJsonObject(
ObjectUtils.requireNonNull(
OscalBindingContext.class.getResourceAsStream("/schema/json/oscal_catalog_schema.json")));
protected JSONObject getOscalJsonSchema() throws IOException {
try (InputStream is = ObjectUtils.requireNonNull(
OscalBindingContext.class.getResourceAsStream("/schema/json/oscal_catalog_schema.json"))) {
return JsonUtil.toJsonObject(is);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,17 @@

package gov.nist.secauto.oscal.tools.cli.core.commands.componentdefinition;

import gov.nist.secauto.metaschema.binding.io.xml.XmlUtil;
import gov.nist.secauto.metaschema.model.common.util.CollectionUtil;
import gov.nist.secauto.metaschema.model.common.util.ObjectUtils;
import gov.nist.secauto.metaschema.model.common.validation.JsonSchemaContentValidator;
import gov.nist.secauto.metaschema.core.model.util.JsonUtil;
import gov.nist.secauto.metaschema.core.model.util.XmlUtil;
import gov.nist.secauto.metaschema.core.util.CollectionUtil;
import gov.nist.secauto.metaschema.core.util.ObjectUtils;
import gov.nist.secauto.oscal.lib.OscalBindingContext;
import gov.nist.secauto.oscal.tools.cli.core.commands.oscal.AbstractOscalValidationSubcommand;

import org.json.JSONObject;

import java.io.IOException;
import java.io.InputStream;
import java.util.LinkedList;
import java.util.List;

Expand All @@ -52,15 +53,16 @@ public String getDescription() {
protected List<Source> getOscalXmlSchemas() throws IOException {
List<Source> retval = new LinkedList<>();
retval.add(
ObjectUtils.requireNonNull(
XmlUtil.getStreamSource(OscalBindingContext.class.getResource("/schema/xml/oscal_component_schema.xsd"))));
XmlUtil.getStreamSource(ObjectUtils.requireNonNull(
OscalBindingContext.class.getResource("/schema/xml/oscal_component_schema.xsd"))));
return CollectionUtil.unmodifiableList(retval);
}

@Override
protected JSONObject getOscalJsonSchema() {
return JsonSchemaContentValidator.toJsonObject(
ObjectUtils.requireNonNull(
OscalBindingContext.class.getResourceAsStream("/schema/json/oscal_component_schema.json")));
protected JSONObject getOscalJsonSchema() throws IOException {
try (InputStream is = ObjectUtils.requireNonNull(
OscalBindingContext.class.getResourceAsStream("/schema/json/oscal_component_schema.json"))) {
return JsonUtil.toJsonObject(is);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
import com.google.auto.service.AutoService;

import gov.nist.secauto.metaschema.cli.commands.GenerateSchemaCommand;
import gov.nist.secauto.metaschema.cli.commands.ValidateContentWithMetaschemaCommand;
import gov.nist.secauto.metaschema.cli.commands.ValidateMetaschemaCommand;
import gov.nist.secauto.metaschema.cli.commands.ValidateContentUsingModuleCommand;
import gov.nist.secauto.metaschema.cli.commands.ValidateModuleCommand;
import gov.nist.secauto.metaschema.cli.processor.command.AbstractParentCommand;
import gov.nist.secauto.metaschema.cli.processor.command.ICommand;

Expand All @@ -42,8 +42,8 @@ public class MetaschemaCommand
public MetaschemaCommand() {
super(true);
addCommandHandler(new GenerateSchemaCommand());
addCommandHandler(new ValidateMetaschemaCommand());
addCommandHandler(new ValidateContentWithMetaschemaCommand());
addCommandHandler(new ValidateModuleCommand());
addCommandHandler(new ValidateContentUsingModuleCommand());
}

@Override
Expand All @@ -53,6 +53,6 @@ public String getName() {

@Override
public String getDescription() {
return "Perform an operation on a Metaschema";
return "Perform an operation on a Module";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@

package gov.nist.secauto.oscal.tools.cli.core.commands.oscal;

import gov.nist.secauto.metaschema.binding.IBindingContext;
import gov.nist.secauto.metaschema.cli.commands.AbstractConvertSubcommand;
import gov.nist.secauto.metaschema.cli.processor.CLIProcessor.CallingContext;
import gov.nist.secauto.metaschema.cli.processor.command.ICommandExecutor;
import gov.nist.secauto.metaschema.databind.IBindingContext;
import gov.nist.secauto.oscal.lib.OscalBindingContext;

import org.apache.commons.cli.CommandLine;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@

package gov.nist.secauto.oscal.tools.cli.core.commands.oscal;

import gov.nist.secauto.metaschema.binding.IBindingContext;
import gov.nist.secauto.metaschema.cli.commands.AbstractValidateContentCommand;
import gov.nist.secauto.metaschema.cli.processor.CLIProcessor.CallingContext;
import gov.nist.secauto.metaschema.cli.processor.command.ICommandExecutor;
import gov.nist.secauto.metaschema.model.common.constraint.IConstraintSet;
import gov.nist.secauto.metaschema.core.model.constraint.IConstraintSet;
import gov.nist.secauto.metaschema.databind.IBindingContext;
import gov.nist.secauto.oscal.lib.OscalBindingContext;

import org.apache.commons.cli.CommandLine;
Expand All @@ -51,7 +51,7 @@ public abstract class AbstractOscalValidationSubcommand
protected abstract List<Source> getOscalXmlSchemas() throws IOException;

@NonNull
protected abstract JSONObject getOscalJsonSchema();
protected abstract JSONObject getOscalJsonSchema() throws IOException;

@Override
public ICommandExecutor newExecutor(CallingContext callingContext, CommandLine commandLine) {
Expand Down Expand Up @@ -80,7 +80,7 @@ public List<Source> getXmlSchemas() throws IOException {

@Override
@NonNull
public JSONObject getJsonSchema() {
public JSONObject getJsonSchema() throws IOException {
return getOscalJsonSchema();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,17 @@

package gov.nist.secauto.oscal.tools.cli.core.commands.poam;

import gov.nist.secauto.metaschema.binding.io.xml.XmlUtil;
import gov.nist.secauto.metaschema.model.common.util.CollectionUtil;
import gov.nist.secauto.metaschema.model.common.util.ObjectUtils;
import gov.nist.secauto.metaschema.model.common.validation.JsonSchemaContentValidator;
import gov.nist.secauto.metaschema.core.model.util.JsonUtil;
import gov.nist.secauto.metaschema.core.model.util.XmlUtil;
import gov.nist.secauto.metaschema.core.util.CollectionUtil;
import gov.nist.secauto.metaschema.core.util.ObjectUtils;
import gov.nist.secauto.oscal.lib.OscalBindingContext;
import gov.nist.secauto.oscal.tools.cli.core.commands.oscal.AbstractOscalValidationSubcommand;

import org.json.JSONObject;

import java.io.IOException;
import java.io.InputStream;
import java.util.LinkedList;
import java.util.List;

Expand All @@ -52,17 +53,17 @@ public String getDescription() {
@Override
protected List<Source> getOscalXmlSchemas() throws IOException {
List<Source> retval = new LinkedList<>();
retval
.add(
ObjectUtils.requireNonNull(
XmlUtil.getStreamSource(OscalBindingContext.class.getResource("/schema/xml/oscal_poam_schema.xsd"))));
retval.add(
XmlUtil.getStreamSource(ObjectUtils.requireNonNull(
OscalBindingContext.class.getResource("/schema/xml/oscal_poam_schema.xsd"))));
return CollectionUtil.unmodifiableList(retval);
}

@Override
protected JSONObject getOscalJsonSchema() {
return JsonSchemaContentValidator.toJsonObject(
ObjectUtils.requireNonNull(
OscalBindingContext.class.getResourceAsStream("/schema/json/oscal_poam_schema.json")));
protected JSONObject getOscalJsonSchema() throws IOException {
try (InputStream is = ObjectUtils.requireNonNull(
OscalBindingContext.class.getResourceAsStream("/schema/json/oscal_poam_schema.json"))) {
return JsonUtil.toJsonObject(is);
}
}
}
Loading

0 comments on commit d612448

Please sign in to comment.