Class ProtectionReport
What a store, a key or a vault actually provides, one Protection at a time.
Three answers rather than two. UNKNOWN is what a port returns when the platform will not
tell it -- a browser has no way to learn whether a CryptoKey ended up in a secure element,
and the honest report of that is not NO (which would understate an authenticator that does
use one) and certainly not YES. Callers that need a guarantee must treat UNKNOWN as "not
provided"; callers that are only describing the state to a user can say so.
A report describes what was observed, not what an API exists for. A port that finds
crypto.subtle present but cannot complete a round trip through it reports
Protection.ENCRYPTED_AT_REST as NO.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classAccumulates the answers for aProtectionReport. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionintanswer(Protection protection) static ProtectionReport.Builderbuilder()Starts building a report.firstUnmet(Protection[] required) The first requirement this report does not provide, for an error message that names the thing that was missing rather than saying the request was refused.static ProtectionReportnone()A report that answersNOto everything.booleanprovides(Protection protection) Whether this report provides the protection, withUNKNOWNcounting as no.booleansatisfies(Protection[] required) Whether every requirement inrequiredis answeredYES.toString()A human readable line per protection, for diagnostics and for the "what protects this" screen an application that cares about this will end up writing.static ProtectionReportunknown()A report that answersUNKNOWNto everything.
-
Field Details
-
YES
public static final int YESThe protection is provided.- See Also:
-
NO
public static final int NOThe protection is not provided.- See Also:
-
UNKNOWN
public static final int UNKNOWNThe platform cannot say. Treat as not provided when a guarantee is required.- See Also:
-
-
Method Details
-
builder
Starts building a report. Every protection not explicitly set answersUNKNOWN, which is the correct default for a port that has not considered the question. -
none
A report that answersNOto everything. What the fallback returns on a platform with no secure store at all. -
unknown
A report that answersUNKNOWNto everything. What to return when the store could not be reached at all, as distinct from a store that was reached and provides nothing. -
answer
-
provides
Whether this report provides the protection, with
UNKNOWNcounting as no.The method to call when a policy has to be enforced. Use
answer(Protection)when the difference between "no" and "cannot say" matters to the caller, which it does when the answer is being shown to a user. -
satisfies
Whether every requirement in
requiredis answeredYES.Parameters
required: the protections a caller insists on, may be null or empty
Returns
true when all of them are provided
-
firstUnmet
The first requirement this report does not provide, for an error message that names the thing that was missing rather than saying the request was refused.
Parameters
required: the protections a caller insists on, may be null
Returns
the unmet protection, or null when everything is provided
-
toString
-