From 5e04b03a97cbf193838c40d790ff72378c811dce Mon Sep 17 00:00:00 2001 From: Mykhailo Nester Date: Wed, 26 May 2021 09:46:19 +0300 Subject: [PATCH] - add more javadoc comments; (#15) --- .../java/dgca/verifier/app/decoder/base45/Base45Service.kt | 3 +++ .../verifier/app/decoder/base45/DefaultBase45Service.kt | 3 +++ .../main/java/dgca/verifier/app/decoder/cbor/CborService.kt | 3 +++ .../dgca/verifier/app/decoder/cbor/DefaultCborService.kt | 3 +++ .../verifier/app/decoder/compression/CompressorService.kt | 3 +++ .../app/decoder/compression/DefaultCompressorService.kt | 5 ++++- .../main/java/dgca/verifier/app/decoder/cose/CoseService.kt | 3 +++ .../java/dgca/verifier/app/decoder/cose/CryptoService.kt | 3 +++ .../dgca/verifier/app/decoder/cose/DefaultCoseService.kt | 3 +++ .../verifier/app/decoder/cose/VerificationCryptoService.kt | 3 +++ .../java/dgca/verifier/app/decoder/cwt/CwtHeaderKeys.kt | 6 ------ .../dgca/verifier/app/decoder/model/GreenCertificate.kt | 3 +++ .../app/decoder/prefixvalidation/PrefixValidationService.kt | 3 +++ .../verifier/app/decoder/schema/DefaultSchemaValidator.kt | 5 +++++ .../dgca/verifier/app/decoder/schema/SchemaValidator.kt | 3 +++ 15 files changed, 45 insertions(+), 7 deletions(-) diff --git a/decoder/src/main/java/dgca/verifier/app/decoder/base45/Base45Service.kt b/decoder/src/main/java/dgca/verifier/app/decoder/base45/Base45Service.kt index 5755e2c..e42b7ab 100644 --- a/decoder/src/main/java/dgca/verifier/app/decoder/base45/Base45Service.kt +++ b/decoder/src/main/java/dgca/verifier/app/decoder/base45/Base45Service.kt @@ -24,6 +24,9 @@ package dgca.verifier.app.decoder.base45 import dgca.verifier.app.decoder.model.VerificationResult +/** + * Decodes input from Base45 + */ interface Base45Service { fun decode(input: String, verificationResult: VerificationResult): ByteArray diff --git a/decoder/src/main/java/dgca/verifier/app/decoder/base45/DefaultBase45Service.kt b/decoder/src/main/java/dgca/verifier/app/decoder/base45/DefaultBase45Service.kt index f46961f..4e00ab3 100644 --- a/decoder/src/main/java/dgca/verifier/app/decoder/base45/DefaultBase45Service.kt +++ b/decoder/src/main/java/dgca/verifier/app/decoder/base45/DefaultBase45Service.kt @@ -24,6 +24,9 @@ package dgca.verifier.app.decoder.base45 import dgca.verifier.app.decoder.model.VerificationResult +/** + * Decodes input from Base45 + */ @ExperimentalUnsignedTypes class DefaultBase45Service : Base45Service { diff --git a/decoder/src/main/java/dgca/verifier/app/decoder/cbor/CborService.kt b/decoder/src/main/java/dgca/verifier/app/decoder/cbor/CborService.kt index 9c02af8..1221936 100644 --- a/decoder/src/main/java/dgca/verifier/app/decoder/cbor/CborService.kt +++ b/decoder/src/main/java/dgca/verifier/app/decoder/cbor/CborService.kt @@ -25,6 +25,9 @@ package dgca.verifier.app.decoder.cbor import dgca.verifier.app.decoder.model.GreenCertificate import dgca.verifier.app.decoder.model.VerificationResult +/** + * Decodes input as a CBOR structure + */ interface CborService { fun decode(input: ByteArray, verificationResult: VerificationResult): GreenCertificate? diff --git a/decoder/src/main/java/dgca/verifier/app/decoder/cbor/DefaultCborService.kt b/decoder/src/main/java/dgca/verifier/app/decoder/cbor/DefaultCborService.kt index 7283889..5ab73da 100644 --- a/decoder/src/main/java/dgca/verifier/app/decoder/cbor/DefaultCborService.kt +++ b/decoder/src/main/java/dgca/verifier/app/decoder/cbor/DefaultCborService.kt @@ -29,6 +29,9 @@ import dgca.verifier.app.decoder.model.GreenCertificate import dgca.verifier.app.decoder.model.VerificationResult import java.time.Instant +/** + * Decodes input as a CBOR structure + */ class DefaultCborService : CborService { override fun decode(input: ByteArray, verificationResult: VerificationResult): GreenCertificate? { diff --git a/decoder/src/main/java/dgca/verifier/app/decoder/compression/CompressorService.kt b/decoder/src/main/java/dgca/verifier/app/decoder/compression/CompressorService.kt index 143249e..abf31ab 100644 --- a/decoder/src/main/java/dgca/verifier/app/decoder/compression/CompressorService.kt +++ b/decoder/src/main/java/dgca/verifier/app/decoder/compression/CompressorService.kt @@ -24,6 +24,9 @@ package dgca.verifier.app.decoder.compression import dgca.verifier.app.decoder.model.VerificationResult +/** + * Decompresses input + */ interface CompressorService { fun decode(input: ByteArray, verificationResult: VerificationResult): ByteArray diff --git a/decoder/src/main/java/dgca/verifier/app/decoder/compression/DefaultCompressorService.kt b/decoder/src/main/java/dgca/verifier/app/decoder/compression/DefaultCompressorService.kt index 255d45d..7d8777e 100644 --- a/decoder/src/main/java/dgca/verifier/app/decoder/compression/DefaultCompressorService.kt +++ b/decoder/src/main/java/dgca/verifier/app/decoder/compression/DefaultCompressorService.kt @@ -25,10 +25,13 @@ package dgca.verifier.app.decoder.compression import dgca.verifier.app.decoder.model.VerificationResult import java.util.zip.InflaterInputStream +/** + * Decompresses input with ZLIB + */ class DefaultCompressorService : CompressorService { /** - * *Optionally* decompresses input with ZLIB = inflating. + * Decompresses input with ZLIB = inflating. * * If the [input] does not start with ZLIB magic numbers (0x78), no decompression happens */ diff --git a/decoder/src/main/java/dgca/verifier/app/decoder/cose/CoseService.kt b/decoder/src/main/java/dgca/verifier/app/decoder/cose/CoseService.kt index 9c477db..21582a5 100644 --- a/decoder/src/main/java/dgca/verifier/app/decoder/cose/CoseService.kt +++ b/decoder/src/main/java/dgca/verifier/app/decoder/cose/CoseService.kt @@ -25,6 +25,9 @@ package dgca.verifier.app.decoder.cose import dgca.verifier.app.decoder.model.CoseData import dgca.verifier.app.decoder.model.VerificationResult +/** + * Decodes input according to COSE specification (RFC8152) + */ interface CoseService { fun decode(input: ByteArray, verificationResult: VerificationResult): CoseData? diff --git a/decoder/src/main/java/dgca/verifier/app/decoder/cose/CryptoService.kt b/decoder/src/main/java/dgca/verifier/app/decoder/cose/CryptoService.kt index 4f85bff..1627b04 100644 --- a/decoder/src/main/java/dgca/verifier/app/decoder/cose/CryptoService.kt +++ b/decoder/src/main/java/dgca/verifier/app/decoder/cose/CryptoService.kt @@ -25,6 +25,9 @@ package dgca.verifier.app.decoder.cose import dgca.verifier.app.decoder.model.VerificationResult import java.security.cert.Certificate +/** + * Verifies COSE signature + */ interface CryptoService { fun validate(cose: ByteArray, certificate: Certificate, verificationResult: VerificationResult) diff --git a/decoder/src/main/java/dgca/verifier/app/decoder/cose/DefaultCoseService.kt b/decoder/src/main/java/dgca/verifier/app/decoder/cose/DefaultCoseService.kt index becb937..522ce9d 100644 --- a/decoder/src/main/java/dgca/verifier/app/decoder/cose/DefaultCoseService.kt +++ b/decoder/src/main/java/dgca/verifier/app/decoder/cose/DefaultCoseService.kt @@ -27,6 +27,9 @@ import com.upokecenter.cbor.CBORObject import dgca.verifier.app.decoder.model.CoseData import dgca.verifier.app.decoder.model.VerificationResult +/** + * Decodes input according to COSE specification (RFC8152) + */ class DefaultCoseService : CoseService { override fun decode(input: ByteArray, verificationResult: VerificationResult): CoseData? { diff --git a/decoder/src/main/java/dgca/verifier/app/decoder/cose/VerificationCryptoService.kt b/decoder/src/main/java/dgca/verifier/app/decoder/cose/VerificationCryptoService.kt index 59e65e7..da7ef07 100644 --- a/decoder/src/main/java/dgca/verifier/app/decoder/cose/VerificationCryptoService.kt +++ b/decoder/src/main/java/dgca/verifier/app/decoder/cose/VerificationCryptoService.kt @@ -36,6 +36,9 @@ import java.security.Signature import java.security.cert.Certificate import java.security.spec.RSAPublicKeySpec +/** + * Verifies COSE signature + */ class VerificationCryptoService : CryptoService { init { diff --git a/decoder/src/main/java/dgca/verifier/app/decoder/cwt/CwtHeaderKeys.kt b/decoder/src/main/java/dgca/verifier/app/decoder/cwt/CwtHeaderKeys.kt index 625649c..f272772 100644 --- a/decoder/src/main/java/dgca/verifier/app/decoder/cwt/CwtHeaderKeys.kt +++ b/decoder/src/main/java/dgca/verifier/app/decoder/cwt/CwtHeaderKeys.kt @@ -36,13 +36,7 @@ sealed class CwtHeaderKeys(value: Int) { return value } - object ISSUER : CwtHeaderKeys(1) - object SUBJECT : CwtHeaderKeys(2) - object AUDIENCE : CwtHeaderKeys(3) object EXPIRATION : CwtHeaderKeys(4) - object NOT_BEFORE : CwtHeaderKeys(5) object ISSUED_AT : CwtHeaderKeys(6) - object CWT_ID : CwtHeaderKeys(7) - object HCERT : CwtHeaderKeys(-260) } \ No newline at end of file diff --git a/decoder/src/main/java/dgca/verifier/app/decoder/model/GreenCertificate.kt b/decoder/src/main/java/dgca/verifier/app/decoder/model/GreenCertificate.kt index e5806ab..ad9abed 100644 --- a/decoder/src/main/java/dgca/verifier/app/decoder/model/GreenCertificate.kt +++ b/decoder/src/main/java/dgca/verifier/app/decoder/model/GreenCertificate.kt @@ -25,6 +25,9 @@ package dgca.verifier.app.decoder.model import com.fasterxml.jackson.annotation.JsonProperty import java.io.Serializable +/** + * CBOR structure of the certificate + */ data class GreenCertificate( @JsonProperty("ver") diff --git a/decoder/src/main/java/dgca/verifier/app/decoder/prefixvalidation/PrefixValidationService.kt b/decoder/src/main/java/dgca/verifier/app/decoder/prefixvalidation/PrefixValidationService.kt index 6714424..529e562 100644 --- a/decoder/src/main/java/dgca/verifier/app/decoder/prefixvalidation/PrefixValidationService.kt +++ b/decoder/src/main/java/dgca/verifier/app/decoder/prefixvalidation/PrefixValidationService.kt @@ -24,6 +24,9 @@ package dgca.verifier.app.decoder.prefixvalidation import dgca.verifier.app.decoder.model.VerificationResult +/** + * Drops prefix from input + */ interface PrefixValidationService { fun decode(input: String, verificationResult: VerificationResult): String diff --git a/decoder/src/main/java/dgca/verifier/app/decoder/schema/DefaultSchemaValidator.kt b/decoder/src/main/java/dgca/verifier/app/decoder/schema/DefaultSchemaValidator.kt index b4bbb76..408310c 100644 --- a/decoder/src/main/java/dgca/verifier/app/decoder/schema/DefaultSchemaValidator.kt +++ b/decoder/src/main/java/dgca/verifier/app/decoder/schema/DefaultSchemaValidator.kt @@ -32,6 +32,11 @@ import dgca.verifier.app.decoder.JSON_SCHEMA_V1 import dgca.verifier.app.decoder.cwt.CwtHeaderKeys import dgca.verifier.app.decoder.model.VerificationResult +/** + * Verifies CBOR with predefined schema + * + * @see JSON_SCHEMA_V1 + */ class DefaultSchemaValidator : SchemaValidator { override fun validate(cbor: ByteArray, verificationResult: VerificationResult): Boolean { diff --git a/decoder/src/main/java/dgca/verifier/app/decoder/schema/SchemaValidator.kt b/decoder/src/main/java/dgca/verifier/app/decoder/schema/SchemaValidator.kt index 3ac07dd..e1e49ca 100644 --- a/decoder/src/main/java/dgca/verifier/app/decoder/schema/SchemaValidator.kt +++ b/decoder/src/main/java/dgca/verifier/app/decoder/schema/SchemaValidator.kt @@ -24,6 +24,9 @@ package dgca.verifier.app.decoder.schema import dgca.verifier.app.decoder.model.VerificationResult +/** + * Verifies CBOR schema + */ interface SchemaValidator { fun validate(cbor: ByteArray, verificationResult: VerificationResult): Boolean