Class ShieldConfig
Configuration for AppShield.init(ShieldConfig). Chainable.
AppShield.init(new ShieldConfig()
.protect("api.mybank.example", HostPolicy.PROTECTED)
.protect("*.mybank.example", HostPolicy.PROTECTED));
The defaults are chosen so that adding the shield to an existing app changes nothing until hosts are explicitly protected: no host is touched, failures are open, and signal collection is on because reporting costs nothing and is what makes the service useful.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncollectSignals(boolean collect) Whether to gather runtime self-protection observations.The failure mode applied to hosts registered without an explicit one.Overrides the attestation service endpoint.intbooleanTrue when at least one host is registered, so callers can skip work entirely.booleanResolves a host to its policy: exact match first, then the nearest*.wildcard, thenHostPolicy.UNPROTECTED.Registers a host with the default policy, which honoursdefaultFailureMode(FailureMode).protect(String hostPattern, HostPolicy policy) Registers a host to protect.The registered host patterns, explicit and implicit alike.refreshThresholdPercent(int percent) How far through a token's lifetime to trigger a background refresh, as a percentage.tokenHeader(String name) Overrides the header used to carry the token.
-
Field Details
-
DEFAULT_TOKEN_HEADER
Header that carries the attestation token.
Deliberately not
Authorization: that slot belongs to the app's own user authentication, and the two answer different questions -- who the user is, versus whether this is a genuine unmodified app on an uncompromised device. A backend needs both, so they must compose.- See Also:
-
-
Constructor Details
-
ShieldConfig
public ShieldConfig()
-
-
Method Details
-
endpoint
Overrides the attestation service endpoint. Only needed for a private deployment or a test double. -
tokenHeader
Overrides the header used to carry the token. Change this only if it collides with something already in use on your backend.
Content-Typeis refused.ConnectionRequest.addRequestHeader(String, String)special-cases that name into the request's own content type rather than the header map, so the token would replace the request's media type and -- because the removal path only clears the map -- would survive a redirect to an unprotected host and be handed to it. A leak with no symptom on the way there.- Throws:
IllegalArgumentException- if the name cannot carry a token safely
-
defaultFailureMode
The failure mode applied to hosts registered without an explicit one. -
refreshThresholdPercent
How far through a token's lifetime to trigger a background refresh, as a percentage. Refreshing early is what stops a request ever having to wait on the network. -
collectSignals
Whether to gather runtime self-protection observations. On by default; they ride along with the token fetch, so there is no extra request and no extra battery cost. -
protect
Registers a host to protect. Accepts an exact host or a leading*.wildcard covering its subdomains. Hosts not registered here are never touched. -
protect
Registers a host with the default policy, which honoursdefaultFailureMode(FailureMode). -
getEndpoint
-
getTokenHeader
-
getDefaultFailureMode
-
getRefreshThresholdPercent
public int getRefreshThresholdPercent() -
isCollectSignals
public boolean isCollectSignals() -
policyFor
Resolves a host to its policy: exact match first, then the nearest*.wildcard, thenHostPolicy.UNPROTECTED. Never returns null. -
hasProtectedHosts
public boolean hasProtectedHosts()True when at least one host is registered, so callers can skip work entirely. -
protectedHosts
The registered host patterns, explicit and implicit alike.
-