Skip to content

Commit 0683504

Browse files
suzannajiwanicopybara-github
authored andcommitted
Fix README code examples + Extension.kt error messages
Patched from #78, originally authored by @thomasbuilds PiperOrigin-RevId: 911352815
1 parent 8ebb290 commit 0683504

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ when verifying. For example, if you expect the challenge to be equal to
4040

4141
```kotlin
4242
// Create a ChallengeChecker
43-
val challengeChecker = ChallengeMatcher("challenge123")
43+
val challengeChecker = ChallengeMatcher(ByteString.copyFromUtf8("challenge123"))
4444

4545
// Verify an attestation certificate chain with the checker
4646
val result = verifier.verify(certificateChain, challengeChecker)
@@ -57,9 +57,14 @@ with an `InMemoryLruCache` like in this sample:
5757
```kotlin
5858
val cacheSize = 100
5959

60-
// Create a ChainedChallengeChecker with desired ChallengeCheckers
60+
// Create a ChainedChallengeChecker with desired ChallengeCheckers. The
61+
// coroutineScope is used to run each individual checker.
6162
val challengeChecker =
62-
ChainedChallengeChecker.of(ChallengeMatcher("expectedChallenge"), InMemoryLruCache(cacheSize))
63+
ChainedChallengeChecker.of(
64+
coroutineScope,
65+
ChallengeMatcher(ByteString.copyFromUtf8("expectedChallenge")),
66+
InMemoryLruCache(cacheSize),
67+
)
6368

6469
// Verify an attestation certificate chain with the checker
6570
val result = verifier.verify(certificateChain, challengeChecker)

src/main/kotlin/Extension.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,9 @@ data class PatchLevel(val yearMonth: YearMonth, val version: Int? = null) {
536536
partitionName: String = "",
537537
logFn: (String) -> Unit = { _ -> },
538538
): PatchLevel? {
539-
check(patchLevel is ASN1Integer) { "Must be an ASN1Integer, was ${this::class.simpleName}" }
539+
check(patchLevel is ASN1Integer) {
540+
"Must be an ASN1Integer, was ${patchLevel::class.simpleName}"
541+
}
540542
return from(patchLevel.value.toString(), partitionName, logFn)
541543
}
542544

@@ -768,7 +770,7 @@ private inline fun <reified T> ASN1Encodable.toSet(): Set<T> {
768770
return this.map {
769771
if (it !is T) {
770772
throw ExtensionParsingException(
771-
"Object must be a ${T::class.simpleName}, was ${this::class.simpleName}"
773+
"Object must be a ${T::class.simpleName}, was ${it::class.simpleName}"
772774
)
773775
}
774776
it

0 commit comments

Comments
 (0)