public final class ShieldConfig
- Object
- 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.
Fields
public static final String DEFAULT_TOKEN_HEADER = "X-CN1-Attest" | Header that carries the attestation token. |
Constructors
public ShieldConfig() |
Methods
Inherited methods
Field details
DEFAULT_TOKEN_HEADER
public static final String DEFAULT_TOKEN_HEADER = "X-CN1-Attest"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.
Constructor details
ShieldConfig
public ShieldConfig()Method details
endpoint
public ShieldConfig endpoint(String url)tokenHeader
public ShieldConfig tokenHeader(String name)Overrides the header used to carry the token. Change this only if it collides with something already in use on your backend.
Content-Type is refused. ConnectionRequest.addRequestHeader
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
public ShieldConfig defaultFailureMode(FailureMode mode)refreshThresholdPercent
public ShieldConfig refreshThresholdPercent(int percent)collectSignals
public ShieldConfig collectSignals(boolean collect)protect
public ShieldConfig protect(String hostPattern, HostPolicy policy)*. wildcard covering its
subdomains. Hosts not registered here are never touched.protect
public ShieldConfig protect(String hostPattern)defaultFailureMode(FailureMode).getEndpoint
public String getEndpoint()getTokenHeader
public String getTokenHeader()getDefaultFailureMode
public FailureMode getDefaultFailureMode()getRefreshThresholdPercent
public int getRefreshThresholdPercent()isCollectSignals
public boolean isCollectSignals()policyFor
public HostPolicy policyFor(String host)*. wildcard, then
HostPolicy.UNPROTECTED. Never returns null.hasProtectedHosts
public boolean hasProtectedHosts()protectedHosts
public Enumeration protectedHosts()