@CheckReturnValue
@ExperimentalApi(value="https://github.com/grpc/grpc-java/issues/8022")
public final class SecurityPolicies
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static SecurityPolicy |
allOf(SecurityPolicy... securityPolicies)
Creates a
SecurityPolicy that allows access if and only if *all* of the specified
securityPolicies allow access. |
static SecurityPolicy |
anyOf(SecurityPolicy... securityPolicies)
Creates a
SecurityPolicy that allows access if *any* of the specified securityPolicies allow access. |
static SecurityPolicy |
hasPermissions(android.content.pm.PackageManager packageManager,
com.google.common.collect.ImmutableSet<java.lang.String> permissions)
Creates a
SecurityPolicy which checks if the caller has all of the given permissions
from permissions. |
static SecurityPolicy |
hasSignature(android.content.pm.PackageManager packageManager,
java.lang.String packageName,
android.content.pm.Signature requiredSignature)
Creates a
SecurityPolicy which checks if the package signature
matches requiredSignature. |
static SecurityPolicy |
hasSignatureSha256Hash(android.content.pm.PackageManager packageManager,
java.lang.String packageName,
byte[] requiredSignatureSha256Hash)
Creates
SecurityPolicy which checks if the SHA-256 hash of the package signature
matches requiredSignatureSha256Hash. |
static SecurityPolicy |
internalOnly() |
static SecurityPolicy |
oneOfSignatures(android.content.pm.PackageManager packageManager,
java.lang.String packageName,
java.util.Collection<android.content.pm.Signature> requiredSignatures)
Creates a
SecurityPolicy which checks if the package signature
matches any of requiredSignatures. |
static SecurityPolicy |
oneOfSignatureSha256Hash(android.content.pm.PackageManager packageManager,
java.lang.String packageName,
java.util.List<byte[]> requiredSignatureSha256Hashes)
Creates
SecurityPolicy which checks if the SHA-256 hash of the package signature
matches any of requiredSignatureSha256Hashes. |
static SecurityPolicy |
permissionDenied(java.lang.String description) |
static ServerSecurityPolicy |
serverInternalOnly() |
public static ServerSecurityPolicy serverInternalOnly()
public static SecurityPolicy internalOnly()
public static SecurityPolicy permissionDenied(java.lang.String description)
public static SecurityPolicy hasSignature(android.content.pm.PackageManager packageManager, java.lang.String packageName, android.content.pm.Signature requiredSignature)
SecurityPolicy which checks if the package signature
matches requiredSignature.packageName - the package name of the allowed package.requiredSignature - the allowed signature of the allowed package.java.lang.NullPointerException - if any of the inputs are null.public static SecurityPolicy hasSignatureSha256Hash(android.content.pm.PackageManager packageManager, java.lang.String packageName, byte[] requiredSignatureSha256Hash)
SecurityPolicy which checks if the SHA-256 hash of the package signature
matches requiredSignatureSha256Hash.packageName - the package name of the allowed package.requiredSignatureSha256Hash - the SHA-256 digest of the signature of the allowed package.java.lang.NullPointerException - if any of the inputs are null.java.lang.IllegalArgumentException - if requiredSignatureSha256Hash is not of length 32.public static SecurityPolicy oneOfSignatures(android.content.pm.PackageManager packageManager, java.lang.String packageName, java.util.Collection<android.content.pm.Signature> requiredSignatures)
SecurityPolicy which checks if the package signature
matches any of requiredSignatures.packageName - the package name of the allowed package.requiredSignatures - the allowed signatures of the allowed package.java.lang.NullPointerException - if any of the inputs are null.java.lang.IllegalArgumentException - if requiredSignatures is empty.public static SecurityPolicy oneOfSignatureSha256Hash(android.content.pm.PackageManager packageManager, java.lang.String packageName, java.util.List<byte[]> requiredSignatureSha256Hashes)
SecurityPolicy which checks if the SHA-256 hash of the package signature
matches any of requiredSignatureSha256Hashes.packageName - the package name of the allowed package.requiredSignatureSha256Hashes - the SHA-256 digests of the signatures of the allowed
package.java.lang.NullPointerException - if any of the inputs are null.java.lang.IllegalArgumentException - if requiredSignatureSha256Hashes is empty, or if any
of the requiredSignatureSha256Hashes are not of length 32.public static SecurityPolicy allOf(SecurityPolicy... securityPolicies)
SecurityPolicy that allows access if and only if *all* of the specified
securityPolicies allow access.securityPolicies - the security policies that all must allow access.java.lang.NullPointerException - if any of the inputs are null.java.lang.IllegalArgumentException - if securityPolicies is empty.public static SecurityPolicy anyOf(SecurityPolicy... securityPolicies)
SecurityPolicy that allows access if *any* of the specified securityPolicies allow access.
Policies will be checked in the order that they are passed. If a policy allows access, subsequent policies will not be checked.
If all policies deny access, the Status returned by checkAuthorization will included the concatenated descriptions of the failed policies and
attach any additional causes as suppressed throwables. The status code will be that of the
first failed policy.
securityPolicies - the security policies that will be checked.java.lang.NullPointerException - if any of the inputs are null.java.lang.IllegalArgumentException - if securityPolicies is empty.public static SecurityPolicy hasPermissions(android.content.pm.PackageManager packageManager, com.google.common.collect.ImmutableSet<java.lang.String> permissions)
SecurityPolicy which checks if the caller has all of the given permissions
from permissions.permissions - all permissions that the calling package needs to havejava.lang.NullPointerException - if any of the inputs are nulljava.lang.IllegalArgumentException - if permissions is empty