Skip to content

Commit

Permalink
- add more javadoc comments; (eu-digital-green-certificates#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
MykhailoNester authored May 26, 2021
1 parent 7b89659 commit 5e04b03
Show file tree
Hide file tree
Showing 15 changed files with 45 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5e04b03

Please sign in to comment.