-
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Alex Alzate <aalzate@sonatype.com>
- Loading branch information
Showing
26 changed files
with
469 additions
and
1,538 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
52 changes: 52 additions & 0 deletions
52
src/main/java/org/cyclonedx/generators/AbstractBomGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package org.cyclonedx.generators; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.module.SimpleModule; | ||
import org.cyclonedx.CycloneDxSchema; | ||
import org.cyclonedx.Version; | ||
import org.cyclonedx.model.Bom; | ||
import org.cyclonedx.util.serializer.InputTypeSerializer; | ||
import org.cyclonedx.util.serializer.LifecycleSerializer; | ||
import org.cyclonedx.util.serializer.MetadataSerializer; | ||
import org.cyclonedx.util.serializer.OutputTypeSerializer; | ||
|
||
public abstract class AbstractBomGenerator extends CycloneDxSchema | ||
{ | ||
protected ObjectMapper mapper; | ||
|
||
protected final Version version; | ||
|
||
protected final Bom bom; | ||
|
||
public AbstractBomGenerator(final Version version, final Bom bom) { | ||
this.mapper = new ObjectMapper(); | ||
this.version = version; | ||
this.bom = bom; | ||
} | ||
|
||
/** | ||
* Returns the version of the CycloneDX schema used by this instance | ||
* @return a CycloneDxSchemaVersion enum | ||
*/ | ||
public Version getSchemaVersion() { | ||
return version; | ||
} | ||
|
||
protected void setupObjectMapper(boolean isXml) { | ||
SimpleModule lifecycleModule = new SimpleModule(); | ||
lifecycleModule.addSerializer(new LifecycleSerializer(isXml)); | ||
mapper.registerModule(lifecycleModule); | ||
|
||
SimpleModule metadataModule = new SimpleModule(); | ||
metadataModule.addSerializer(new MetadataSerializer(isXml, getSchemaVersion())); | ||
mapper.registerModule(metadataModule); | ||
|
||
SimpleModule inputTypeModule = new SimpleModule(); | ||
inputTypeModule.addSerializer(new InputTypeSerializer(isXml)); | ||
mapper.registerModule(inputTypeModule); | ||
|
||
SimpleModule outputTypeModule = new SimpleModule(); | ||
outputTypeModule.addSerializer(new OutputTypeSerializer(isXml)); | ||
mapper.registerModule(outputTypeModule); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/org/cyclonedx/generators/BomGeneratorFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* This file is part of CycloneDX Core (Java). | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* Copyright (c) OWASP Foundation. All Rights Reserved. | ||
*/ | ||
package org.cyclonedx.generators; | ||
|
||
import org.cyclonedx.Version; | ||
import org.cyclonedx.generators.xml.BomXmlGenerator; | ||
import org.cyclonedx.model.Bom; | ||
import org.cyclonedx.generators.json.BomJsonGenerator; | ||
|
||
public class BomGeneratorFactory { | ||
|
||
public static BomXmlGenerator createXml(Version version, Bom bom) { | ||
return new BomXmlGenerator(bom, version); | ||
} | ||
|
||
public static BomJsonGenerator createJson(Version version, Bom bom) { | ||
return new BomJsonGenerator(bom, version); | ||
} | ||
} |
134 changes: 0 additions & 134 deletions
134
src/main/java/org/cyclonedx/generators/json/AbstractBomJsonGenerator.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.