Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changes in dates for api 24 compatibility #68

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions decoder/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ android {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
dev {
}
qa {
}
}

compileOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ data class GreenCertificateData(
val issuingCountry: String?,
val hcertJson: String,
val greenCertificate: GreenCertificate,
val issuedAt: ZonedDateTime,
val expirationTime: ZonedDateTime
val issuedAt: Date,
val expirationTime: Date
) {

fun getNormalizedIssuingCountry(): String =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import dgca.verifier.app.decoder.model.GreenCertificate
import dgca.verifier.app.decoder.model.VerificationResult
import java.time.Instant
import java.time.ZoneOffset
import java.util.*

/**
* Decodes input as a CBOR structure
Expand All @@ -48,11 +49,11 @@ class DefaultCborService(private val greenCertificateMapper: GreenCertificateMap

val issuingCountry: String? = map[CwtHeaderKeys.ISSUING_COUNTRY.asCBOR()]?.AsString()

val issuedAt = Instant.ofEpochSecond(map[CwtHeaderKeys.ISSUED_AT.asCBOR()].AsInt64())
verificationResult.isIssuedTimeCorrect = issuedAt.isBefore(Instant.now())
val issuedAt = Date(map[CwtHeaderKeys.ISSUED_AT.asCBOR()].AsInt64()*1000)
verificationResult.isIssuedTimeCorrect = issuedAt.before(Date())

val expirationTime = Instant.ofEpochSecond(map[CwtHeaderKeys.EXPIRATION.asCBOR()].AsInt64())
verificationResult.isNotExpired = expirationTime.isAfter(Instant.now())
val expirationTime = Date(map[CwtHeaderKeys.EXPIRATION.asCBOR()].AsInt64()*1000)
verificationResult.isNotExpired = expirationTime.after(Date())

val hcert = map[CwtHeaderKeys.HCERT.asCBOR()]

Expand All @@ -64,8 +65,8 @@ class DefaultCborService(private val greenCertificateMapper: GreenCertificateMap
issuingCountry,
cborObject.ToJSONString(),
greenCertificate,
issuedAt.atZone(ZoneOffset.UTC),
expirationTime.atZone(ZoneOffset.UTC)
issuedAt,
expirationTime
)
} catch (e: Throwable) {
null
Expand Down