Class HostPolicy
java.lang.Object
com.codename1.security.shield.HostPolicy
What the shield does for a given host: whether to attach an attestation token, whether to enforce certificate pins, and what to do when a token cannot be obtained.
Hosts are opt-in. A host with no policy registered gets UNPROTECTED and is left completely
alone -- no header, no pin check, no possibility of a blocked request. That default is what
lets an existing app adopt the shield on its own API without disturbing its analytics, CDN,
map-tile or ad traffic.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final HostPolicyAsPROTECTEDbut refuses to send the request without a valid token.static final HostPolicyAttach a token, enforce pins if the service has published any, and let the request through when no token is available.static final HostPolicyThe policy for any host the app did not explicitly register. -
Constructor Summary
ConstructorsConstructorDescriptionHostPolicy(boolean attachToken, boolean enforcePins, FailureMode failureMode) -
Method Summary
Modifier and TypeMethodDescriptionWhat to do when no token could be obtained.booleanTrue when requests to this host carry the attestation header.booleanTrue when the certificate chain for this host is checked against the published pin set.booleanisNoOp()True when this policy does nothing, so callers can skip work entirely.toString()Returns a string representation of the object.
-
Field Details
-
UNPROTECTED
The policy for any host the app did not explicitly register. Does nothing at all. -
PROTECTED
Attach a token, enforce pins if the service has published any, and let the request through when no token is available. The sensible starting point for a protected host. -
ENFORCED
-
-
Constructor Details
-
HostPolicy
-
-
Method Details
-
isAttachToken
public boolean isAttachToken()True when requests to this host carry the attestation header. -
isEnforcePins
public boolean isEnforcePins()True when the certificate chain for this host is checked against the published pin set. Note that enforcement still only happens if a pin set for the host actually exists; seePinSetfor the never-brick rules. -
getFailureMode
What to do when no token could be obtained. -
isNoOp
public boolean isNoOp()True when this policy does nothing, so callers can skip work entirely. -
toString
Description copied from class:ObjectReturns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method. The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of: getClass().getName() + '@' + Integer.toHexString(hashCode())
-