|
31 | 31 | link:https://developers.yubico.com/java-webauthn-server/JavaDoc/webauthn-server-attestation/2.0.0/com/yubico/fido/metadata/FidoMetadataDownloader.html[`FidoMetadataDownloader`]
|
32 | 32 | class will attempt to download a new BLOB only when its
|
33 | 33 | link:https://developers.yubico.com/java-webauthn-server/JavaDoc/webauthn-server-attestation/2.0.0/com/yubico/fido/metadata/FidoMetadataDownloader.html#loadCachedBlob()[`loadCachedBlob()`]
|
34 |
| -is executed, |
35 |
| -and then only if the cache is empty or if the cached BLOB is invalid or out of date. |
| 34 | +or |
| 35 | +link:https://developers.yubico.com/java-webauthn-server/JavaDoc/webauthn-server-attestation/2.1.0/com/yubico/fido/metadata/FidoMetadataDownloader.html#refreshBlob()[`refreshBlob()`] |
| 36 | +method is executed. |
| 37 | +As the names suggest, |
| 38 | +`loadCachedBlob()` downloads a new BLOB only if the cache is empty |
| 39 | +or the cached BLOB is invalid or out of date, |
| 40 | +while `refreshBlob()` always downloads a new BLOB and falls back |
| 41 | +to the cached BLOB only when the new BLOB is invalid in some way. |
36 | 42 | link:https://developers.yubico.com/java-webauthn-server/JavaDoc/webauthn-server-attestation/2.0.0/com/yubico/fido/metadata/FidoMetadataService.html[`FidoMetadataService`]
|
37 | 43 | will never re-download a new BLOB once instantiated.
|
38 | 44 | +
|
39 |
| -You should use some external scheduling mechanism to re-run `loadCachedBlob()` periodically |
| 45 | +You should use some external scheduling mechanism to re-run `loadCachedBlob()` |
| 46 | +and/or `refreshBlob()` periodically |
40 | 47 | and rebuild new `FidoMetadataService` instances with the updated metadata contents.
|
41 | 48 | You can do this with minimal disruption since the `FidoMetadataService` and `RelyingParty`
|
42 | 49 | classes keep no internal mutable state.
|
@@ -95,11 +102,14 @@ Unlike other classes in this module and the core library,
|
95 | 102 | link:https://developers.yubico.com/java-webauthn-server/JavaDoc/webauthn-server-attestation/2.0.0/com/yubico/fido/metadata/FidoMetadataDownloader.html[`FidoMetadataDownloader`]
|
96 | 103 | is NOT THREAD SAFE since its
|
97 | 104 | link:https://developers.yubico.com/java-webauthn-server/JavaDoc/webauthn-server-attestation/2.0.0/com/yubico/fido/metadata/FidoMetadataDownloader.html#loadCachedBlob()[`loadCachedBlob()`]
|
98 |
| -method reads and writes caches. |
| 105 | +and |
| 106 | +link:https://developers.yubico.com/java-webauthn-server/JavaDoc/webauthn-server-attestation/2.1.0/com/yubico/fido/metadata/FidoMetadataDownloader.html#refreshBlob()[`refreshBlob()`] |
| 107 | +methods read and write caches. |
99 | 108 | link:https://developers.yubico.com/java-webauthn-server/JavaDoc/webauthn-server-attestation/2.0.0/com/yubico/fido/metadata/FidoMetadataService.html[`FidoMetadataService`],
|
100 | 109 | on the other hand, is thread safe,
|
101 |
| -and `FidoMetadataDownloader` instances can be reused for subsequent `loadCachedBlob()` calls |
102 |
| -as long as only one `loadCachedBlob()` call executes at a time. |
| 110 | +and `FidoMetadataDownloader` instances can be reused |
| 111 | +for subsequent `loadCachedBlob()` and `refreshBlob()` calls |
| 112 | +as long as only one call executes at a time. |
103 | 113 | =====
|
104 | 114 | +
|
105 | 115 | [source,java]
|
@@ -323,15 +333,19 @@ The library implements these as closely as possible, but with some slight depart
|
323 | 333 |
|
324 | 334 | ** Step 3 states "The `nextUpdate` field of the Metadata BLOB specifies a date when the download SHOULD occur at latest".
|
325 | 335 | `FidoMetadataDownloader` does not automatically re-download the BLOB.
|
326 |
| - Instead, each time its |
| 336 | + Instead, each time the |
327 | 337 | link:https://developers.yubico.com/java-webauthn-server/JavaDoc/webauthn-server-attestation/2.0.0/com/yubico/fido/metadata/FidoMetadataDownloader.html#loadCachedBlob()[`loadCachedBlob()`]
|
328 | 338 | method is executed it checks whether a new BLOB should be downloaded.
|
| 339 | + The |
| 340 | + link:https://developers.yubico.com/java-webauthn-server/JavaDoc/webauthn-server-attestation/2.1.0/com/yubico/fido/metadata/FidoMetadataDownloader.html#refreshBlob()[`refreshBlob()`] |
| 341 | + method always attempts to download a new BLOB when executed, |
| 342 | + but also does not trigger re-downloads automatically. |
329 | 343 | +
|
330 |
| -If no BLOB exists in cache, or the cached BLOB is invalid, or if the current date is greater than or equal to `nextUpdate`, |
331 |
| -then a new BLOB is downloaded. |
332 |
| -If the new BLOB is valid, has a correct signature, and has a `no` field greater than the cached BLOB, |
| 344 | +Whenever a newly downloaded BLOB is valid, has a correct signature, |
| 345 | +and has a `no` field greater than the cached BLOB (if any), |
333 | 346 | then the new BLOB replaces the cached one;
|
334 |
| -otherwise, the new BLOB is discarded and the cached one is kept until the next execution of `.loadCachedBlob()`. |
| 347 | +otherwise, the new BLOB is discarded and the cached one is kept |
| 348 | +until the next execution of `.loadCachedBlob()` or `.refreshBlob()`. |
335 | 349 |
|
336 | 350 | * Metadata entries are not stored or cached individually, instead the BLOB is cached as a whole.
|
337 | 351 | In processing rules step 8, neither `FidoMetadataDownloader` nor
|
|
0 commit comments