Skip to content

Commit

Permalink
Merge pull request #112 from nsacyber/maven-conf
Browse files Browse the repository at this point in the history
Configure deployment to maven central
  • Loading branch information
iadgovuser29 authored Jul 27, 2023
2 parents b6d86a1 + 7570ac4 commit a008020
Show file tree
Hide file tree
Showing 23 changed files with 368 additions and 136 deletions.
100 changes: 87 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ allprojects {
}

tasks.withType(Test) {
useTestNG() {
}
afterSuite { desc, result ->
if (desc.parent == null) {
logger.lifecycle("${result.successfulTestCount}/${result.testCount} tests passed")
Expand All @@ -22,15 +20,15 @@ allprojects {
// here to ensure that all projects are using the same versions of common
// dependencies:
ext.libs = [
bouncycastle: ['org.bouncycastle:bcpkix-jdk15on:1.55', // Bouncy Castle license
'org.bouncycastle:bcprov-ext-jdk15on:1.55'],
jackson: ['com.fasterxml.jackson.core:jackson-core:2.9.4', // Apache 2.0
'com.fasterxml.jackson.core:jackson-annotations:2.9.4',
'com.fasterxml.jackson.core:jackson-databind:2.9.4'],
jcommander: 'com.beust:jcommander:1.72', // cli and required by testng, Apache 2.0
powermock: ['org.powermock:powermock-module-testng:1.6.5', // Apache 2.0
'org.powermock:powermock-api-mockito:1.6.5'],
testng: 'org.testng:testng:6.13.1', // Apache 2.0
bouncycastle: ['org.bouncycastle:bcpkix-jdk15on:1.67', // Bouncy Castle license
'org.bouncycastle:bcprov-ext-jdk15on:1.67'],
jackson: ['com.fasterxml.jackson.core:jackson-core:2.15.2', // Apache 2.0
'com.fasterxml.jackson.core:jackson-annotations:2.15.2',
'com.fasterxml.jackson.core:jackson-databind:2.15.2'],
jcommander: 'com.beust:jcommander:1.72', // Apache 2.0
junit: 'junit:junit:4.13.2', // EPL 1.0
powermock: ['org.powermock:powermock-module-junit4:1.6.5', // Apache 2.0
'org.powermock:powermock-api-mockito:1.6.5']
]
}

Expand All @@ -55,6 +53,8 @@ apply plugin: 'eclipse'
apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'nebula.ospackage'
apply plugin: 'maven'
apply plugin: 'signing'

ext.refsDir = new File(projectDir, 'refs')

Expand All @@ -65,10 +65,84 @@ dependencies {
implementation libs.jackson
implementation libs.jcommander

testImplementation libs.testng
testImplementation libs.junit
testImplementation libs.powermock
}

// Maven packaging and signing
group = 'io.github.nsacyber.paccor'
version = '1.1.4r11'
project.gradle.taskGraph.whenReady { graph ->
project.tasks.findAll().forEach { task ->
if (task.name.contains("signArchives") || task.name.contains("uploadArchives")) {
// If this is set to true, the signing and maven
// properties in gradle.properties must be set.
task.enabled = false
}
}
}
task javadocJar(type: Jar) {
classifier = 'javadoc'
from javadoc
}

task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}

artifacts {
archives javadocJar, sourcesJar
}

signing {
sign configurations.archives
}

uploadArchives {
repositories {
mavenDeployer {
pom.project {
name 'paccor'
packaging 'jar'
// optionally artifactId can be defined here
description 'The Platform Attribute Certificate Creator can gather component details, create, sign, and validate the TCG-defined Platform Credential. #nsacyber'
url 'https://github.com/nsacyber/paccor'

scm {
connection 'scm:git:git://github.com:nsacyber/paccor.git'
developerConnection 'scm:git:git://github.com:nsacyber/paccor.git'
url 'https://github.com/nsacyber/paccor'
}
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
developers {
developer {
id 'iadgovuser29'
name 'iadgovuser29'
email '33426478+iadgovuser29@users.noreply.github.com'
organization 'NSA Cybersecurity Directorate'
organizationUrl 'https://github.com/nsacyber'
}
}
}
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

repository(url: "https://${sonatypeDomain}/service/local/staging/deploy/maven2/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
snapshotRepository(url: "https://${sonatypeDomain}/content/repositories/snapshots/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
}
}
}

// Application packaging into a zip file
def createScript(project, mainClass, name) {
project.tasks.create(name: name, type: CreateStartScripts) {
Expand Down Expand Up @@ -116,7 +190,7 @@ ospackage {
packageName='paccor'
os=LINUX
version='1.1.4'
release='8'
release='11'

into '/opt/paccor'
user 'root'
Expand Down
3 changes: 3 additions & 0 deletions scripts/get_ek.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@ fi

if [ -z "$TPM_VER_1_2" ] && [ -z "$TPM_VER_2_0" ]; then
tpmServerActive=$(ps -aux | grep "tpm_server" | grep -v "grep")
tpmAbrmdActive=$(ps -aux | grep "tpm2-abrmd" | grep -v "grep")
if [ -n "$tpmServerActive" ]; then
TPM_VER_2_0=1
elif [ -n "$tpmAbrmdActive" ]; then
TPM_VER_2_0=1
else
echo "Could not detect version of TPM. Please manually set in get_ek.sh"
exit 1
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/factory/AuthorityInfoAccessFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ private AuthorityInfoAccessFactory() {

/**
* Begin defining the authority info access extension.
* @return A new AuthorityInfoAccessFactory builder.
*/
public static final AuthorityInfoAccessFactory create() {
AuthorityInfoAccessFactory aiaf = new AuthorityInfoAccessFactory();
Expand All @@ -53,6 +54,7 @@ public static final AuthorityInfoAccessFactory create() {
/**
* Add a method and location element.
* @param element {@link AccessDescription}
* @return The AuthorityInfoAccessFactory object with a new element added.
*/
public final AuthorityInfoAccessFactory addElement(final AccessDescription element) {
elements.add(element);
Expand All @@ -63,6 +65,7 @@ public final AuthorityInfoAccessFactory addElement(final AccessDescription eleme
* Add an element using the enumerated methods.
* @param type {@link AuthorityInfoAccessFactory.MethodJson}
* @param location {@link GeneralName}
* @return The AuthorityInfoAccessFactory object with a new element added.
*/
public final AuthorityInfoAccessFactory addElement(final MethodJson type, final GeneralName location) {
elements.add(new AccessDescription(type.getOid(), location));
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/factory/CertificatePoliciesFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ private CertificatePoliciesFactory() {

/**
* Begin creating a new certificate policies object.
* @return A new AuthorityInfoAccessFactory builder.
*/
public static final CertificatePoliciesFactory create() {
CertificatePoliciesFactory cpf = new CertificatePoliciesFactory();
Expand All @@ -25,6 +26,7 @@ public static final CertificatePoliciesFactory create() {
/**
* Add another policy information object.
* @param pi {@link PolicyInformation}
* @return The CertificatePoliciesFactory object with new policy information added.
*/
public final CertificatePoliciesFactory addPolicyInformation(PolicyInformation pi) {
policies.add(pi);
Expand Down
13 changes: 12 additions & 1 deletion src/main/java/factory/CommonCriteriaMeasuresFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

/**
* Functions to help manage the creation of the common criteria measures object.
* @see https://www.commoncriteriaportal.org/cc/
* See <a href="https://www.commoncriteriaportal.org/cc/">https://www.commoncriteriaportal.org/cc/</a>
*/
public class CommonCriteriaMeasuresFactory {
/**
Expand Down Expand Up @@ -54,6 +54,7 @@ private CommonCriteriaMeasuresFactory() {

/**
* Begin creating a new common criteria measures object.
* @return A new CommonCriteriaMeasuresFactory builder.
*/
public static final CommonCriteriaMeasuresFactory create() {
return new CommonCriteriaMeasuresFactory();
Expand All @@ -62,6 +63,7 @@ public static final CommonCriteriaMeasuresFactory create() {
/**
* Set the version. Required field.
* @param version {@link DERIA5String}
* @return The CommonCriteriaMeasuresFactory object with the version set.
*/
public final CommonCriteriaMeasuresFactory version(final DERIA5String version) {
this.version = version;
Expand All @@ -71,6 +73,7 @@ public final CommonCriteriaMeasuresFactory version(final DERIA5String version) {
/**
* Set the assurance level. Required field.
* @param option {@link EvaluationAssuranceLevel}
* @return The CommonCriteriaMeasuresFactory object with the assurance level set.
*/
public final CommonCriteriaMeasuresFactory assuranceLevel(final EvaluationAssuranceLevel option) {
assuranceLevel = option;
Expand All @@ -80,6 +83,7 @@ public final CommonCriteriaMeasuresFactory assuranceLevel(final EvaluationAssura
/**
* Set the evaluation status. Required field.
* @param option {@link EvaluationStatus}
* @return The CommonCriteriaMeasuresFactory object with the evaluation status set.
*/
public final CommonCriteriaMeasuresFactory evaluationStatus(final EvaluationStatus option) {
evaluationStatus = option;
Expand All @@ -89,6 +93,7 @@ public final CommonCriteriaMeasuresFactory evaluationStatus(final EvaluationStat
/**
* Required field. Defaults to false.
* @param setting boolean
* @return The CommonCriteriaMeasuresFactory object with the plus bit set.
*/
public final CommonCriteriaMeasuresFactory plus(final ASN1Boolean setting) {
plus = setting;
Expand All @@ -98,6 +103,7 @@ public final CommonCriteriaMeasuresFactory plus(final ASN1Boolean setting) {
/**
* Set the strength of function. Optional field.
* @param option {@link StrengthOfFunction}
* @return The CommonCriteriaMeasuresFactory object with the strength of function set.
*/
public final CommonCriteriaMeasuresFactory strengthOfFunction(final StrengthOfFunction option) {
strengthOfFunction = option;
Expand All @@ -107,6 +113,7 @@ public final CommonCriteriaMeasuresFactory strengthOfFunction(final StrengthOfFu
/**
* Set the profile OID. Optional field.
* @param oid String
* @return The CommonCriteriaMeasuresFactory object with the profile OID set.
*/
public final CommonCriteriaMeasuresFactory profileOid(final String oid) {
profileOid = new ASN1ObjectIdentifier(oid);
Expand All @@ -117,6 +124,7 @@ public final CommonCriteriaMeasuresFactory profileOid(final String oid) {
* Set the profile URI. Optional field.
* @param uriRef {@link URIReference}
* @see URIReferenceFactory
* @return The CommonCriteriaMeasuresFactory object with the profile URI set.
*/
public final CommonCriteriaMeasuresFactory profileUri(final URIReference uriRef) {
profileUri = uriRef;
Expand All @@ -126,6 +134,7 @@ public final CommonCriteriaMeasuresFactory profileUri(final URIReference uriRef)
/**
* Set the target oid. Optional field.
* @param oid String
* @return The CommonCriteriaMeasuresFactory object with the target OID set.
*/
public final CommonCriteriaMeasuresFactory targetOid(final String oid) {
targetOid = new ASN1ObjectIdentifier(oid);
Expand All @@ -136,6 +145,7 @@ public final CommonCriteriaMeasuresFactory targetOid(final String oid) {
* Set the target URI. Optional field.
* @param uriRef {@link URIReference}
* @see URIReferenceFactory
* @return The CommonCriteriaMeasuresFactory object with the target URI set.
*/
public final CommonCriteriaMeasuresFactory targetUri(final URIReference uriRef) {
targetUri = uriRef;
Expand All @@ -155,6 +165,7 @@ public final CommonCriteriaMeasures build() {
/**
* Create a new common criteria measure object from a JSON node.
* @param refNode JsonNode
* @return A new CommonCriteriaMeasuresFactory with fields filled out from JSON.
*/
public static final CommonCriteriaMeasuresFactory fromJsonNode(final JsonNode refNode) {
CommonCriteriaMeasuresFactory ccmf = null;
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/factory/ComponentIdentifierFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ private ComponentIdentifierFactory() {

/**
* Begin defining the component identifier object.
* @return A new ComponentIdentifierFactory builder.
*/
public static final ComponentIdentifierFactory create() {
return new ComponentIdentifierFactory();
Expand All @@ -73,6 +74,7 @@ public static final ComponentIdentifierFactory create() {
/**
* Set the component manufacturer. Required field.
* @param manufacturer String
* @return The ComponentIdentifierFactory object with the component manufacturer set.
*/
public final ComponentIdentifierFactory componentManufacturer(final String manufacturer) {
componentManufacturer = new DERUTF8String(manufacturer);
Expand All @@ -82,6 +84,7 @@ public final ComponentIdentifierFactory componentManufacturer(final String manuf
/**
* Set the component model. Required field.
* @param model String
* @return The ComponentIdentifierFactory object with the component model set.
*/
public final ComponentIdentifierFactory componentModel(final String model) {
componentModel = new DERUTF8String(model);
Expand All @@ -91,6 +94,7 @@ public final ComponentIdentifierFactory componentModel(final String model) {
/**
* Set the component serial number. Optional field.
* @param serial String
* @return The ComponentIdentifierFactory object with the component serial number set.
*/
public final ComponentIdentifierFactory componentSerial(final String serial) {
componentSerial = serial != null && !serial.trim().isEmpty() ? new DERUTF8String(serial) : null;
Expand All @@ -100,6 +104,7 @@ public final ComponentIdentifierFactory componentSerial(final String serial) {
/**
* Set the component revision field. Optional field.
* @param revision String
* @return The ComponentIdentifierFactory object with the component revision set.
*/
public final ComponentIdentifierFactory componentRevision(final String revision) {
componentRevision = revision != null && !revision.trim().isEmpty() ? new DERUTF8String(revision) : null;
Expand All @@ -109,6 +114,7 @@ public final ComponentIdentifierFactory componentRevision(final String revision)
/**
* Set the component manufacturer oid. Optional field.
* @param manufacturerId String
* @return The ComponentIdentifierFactory object with the component manufacturer ID set.
*/
public final ComponentIdentifierFactory componentManufacturerId(final String manufacturerId) {
componentManufacturerId = manufacturerId != null && !manufacturerId.trim().isEmpty() ? new ASN1ObjectIdentifier(manufacturerId) : null;
Expand All @@ -118,6 +124,7 @@ public final ComponentIdentifierFactory componentManufacturerId(final String man
/**
* Set the field replaceable flag. Optional field.
* @param fieldReplaceable boolean
* @return The ComponentIdentifierFactory object with the field replaceable bit set.
*/
public final ComponentIdentifierFactory fieldReplaceable(final boolean fieldReplaceable) {
this.fieldReplaceable = ASN1Boolean.getInstance(fieldReplaceable);
Expand All @@ -126,6 +133,7 @@ public final ComponentIdentifierFactory fieldReplaceable(final boolean fieldRepl

/**
* Since it is an optional field, the field replaceable flag could be unset.
* @return The ComponentIdentifierFactory object with the field replaceable bit unset.
*/
public final ComponentIdentifierFactory unsetFieldReplaceable() {
this.fieldReplaceable = null;
Expand All @@ -136,6 +144,7 @@ public final ComponentIdentifierFactory unsetFieldReplaceable() {
* Add a component address.
* @param type {@link ComponentIdentifierFactory.ComponentAddressType} type of address as defined by the profile.
* @param value String
* @return The ComponentIdentifierFactory object with a component address added.
*/
public final ComponentIdentifierFactory addComponentAddress(final ComponentAddressType type, final String value) {
String filtered = value.toUpperCase();
Expand Down
Loading

0 comments on commit a008020

Please # to comment.