Validators { public static void validateSignatureHash(HashType hash) throws GeneralSecurityException { switch (hash) { case SHA256: case SHA384: case SHA512: return; default: break; } throw new GeneralSecurityException("Unsupported hash: " + hash.name()); } private  Validators(); static void validateTypeUrl(String typeUrl); static void validateAesKeySize(int sizeInBytes); static void validateVersion(int candidate, int maxExpected); static void validateSignatureHash(HashType hash); static void validateRsaModulusSize(int modulusSize); static void validateRsaPublicExponent(
      BigInteger publicExponent); static void validateNotExists(File f); static void validateExists(File f); static String validateKmsKeyUriAndRemovePrefix(String expectedPrefix, String kmsKeyUri); static void validateCryptoKeyUri(String kmsKeyUri);  }
@Test public void testValidateSignatureHash() throws Exception { try { Validators.validateSignatureHash(HashType.SHA256); Validators.validateSignatureHash(HashType.SHA512); } catch (GeneralSecurityException e) { fail("Valid signature algorithm should work " + e); } try { Validators.validateSignatureHash(HashType.SHA1); fail("Expected GeneralSecurityException"); } catch (GeneralSecurityException e) { TestUtil.assertExceptionContains(e, "Unsupported hash: SHA1"); } }