public final class Validators extends Object
| Constructor and Description |
|---|
Validators() |
| Modifier and Type | Method and Description |
|---|---|
static void |
validateAesKeySize(int sizeInBytes) |
static void |
validateCryptoKeyUri(String kmsKeyUri) |
static void |
validateExists(File f) |
static String |
validateKmsKeyUriAndRemovePrefix(String expectedPrefix,
String kmsKeyUri)
Validates that
kmsKeyUri starts with expectedPrefix, and removes the prefix. |
static void |
validateNotExists(File f) |
static void |
validateSignatureHash(Enums.HashType hash)
Validates whether
hash is safe to use for digital signature. |
static void |
validateTypeUrl(String typeUrl) |
static void |
validateVersion(int candidate,
int maxExpected) |
public static void validateTypeUrl(String typeUrl) throws GeneralSecurityException
GeneralSecurityException - if typeUrl is in invalid format.public static void validateAesKeySize(int sizeInBytes)
throws InvalidAlgorithmParameterException
InvalidAlgorithmParameterException - if sizeInBytes is not supported.public static void validateVersion(int candidate,
int maxExpected)
throws GeneralSecurityException
GeneralSecurityException - if candidate is negative or larger than maxExpected.public static void validateSignatureHash(Enums.HashType hash) throws GeneralSecurityException
hash is safe to use for digital signature.GeneralSecurityException - if hash is invalid or is not safe to use for digital
signature.public static void validateNotExists(File f) throws IOException
IOExceptionpublic static void validateExists(File f) throws IOException
IOException - if f does not exists.public static String validateKmsKeyUriAndRemovePrefix(String expectedPrefix, String kmsKeyUri) throws IllegalArgumentException
kmsKeyUri starts with expectedPrefix, and removes the prefix.IllegalArgumentExceptionpublic static void validateCryptoKeyUri(String kmsKeyUri) throws GeneralSecurityException
GeneralSecurityException - if kmsKeyUri is not a valid URI of a CryptoKey in
Google Cloud KMS.