@Test public void validateKey_notValid_throws() throws Exception { JwtHmacKey validKey = factory.createKey(makeJwtHmacKeyFormat(32, HashType.SHA256)); try { manager.validateKey( JwtHmacKey.newBuilder(validKey) .setKeyValue(ByteString.copyFrom(Random.randBytes(31))) .build()); fail(); } catch (GeneralSecurityException e) { } }
@Override public void validateKey(JwtHmacKey key) throws GeneralSecurityException { Validators.validateVersion(key.getVersion(), getVersion()); if (key.getKeyValue().size() < MIN_KEY_SIZE_IN_BYTES) { throw new GeneralSecurityException("key too short"); } }
JwtHmacKeyManager extends KeyTypeManager<JwtHmacKey> { @Override public void validateKey(JwtHmacKey key) throws GeneralSecurityException { Validators.validateVersion(key.getVersion(), getVersion()); if (key.getKeyValue().size() < MIN_KEY_SIZE_IN_BYTES) { throw new GeneralSecurityException("key too short"); } } }
JwtHmacKeyManager extends KeyTypeManager<JwtHmacKey> { @Override public void validateKey(JwtHmacKey key) throws GeneralSecurityException { Validators.validateVersion(key.getVersion(), getVersion()); if (key.getKeyValue().size() < MIN_KEY_SIZE_IN_BYTES) { throw new GeneralSecurityException("key too short"); } } JwtHmacKeyManager(); }
JwtHmacKeyManager extends KeyTypeManager<JwtHmacKey> { @Override public void validateKey(JwtHmacKey key) throws GeneralSecurityException { Validators.validateVersion(key.getVersion(), getVersion()); if (key.getKeyValue().size() < MIN_KEY_SIZE_IN_BYTES) { throw new GeneralSecurityException("key too short"); } } JwtHmacKeyManager(); @Override String getKeyType(); @Override int getVersion(); @Override KeyMaterialType keyMaterialType(); @Override void validateKey(JwtHmacKey key); @Override JwtHmacKey parseKey(ByteString byteString); @Override KeyFactory<JwtHmacKeyFormat, JwtHmacKey> keyFactory(); static void register(boolean newKeyAllowed); static final KeyTemplate hs256Template(); static final KeyTemplate hs384Template(); static final KeyTemplate hs512Template(); }
JwtHmacKeyManager extends KeyTypeManager<JwtHmacKey> { @Override public void validateKey(JwtHmacKey key) throws GeneralSecurityException { Validators.validateVersion(key.getVersion(), getVersion()); if (key.getKeyValue().size() < MIN_KEY_SIZE_IN_BYTES) { throw new GeneralSecurityException("key too short"); } } JwtHmacKeyManager(); @Override String getKeyType(); @Override int getVersion(); @Override KeyMaterialType keyMaterialType(); @Override void validateKey(JwtHmacKey key); @Override JwtHmacKey parseKey(ByteString byteString); @Override KeyFactory<JwtHmacKeyFormat, JwtHmacKey> keyFactory(); static void register(boolean newKeyAllowed); static final KeyTemplate hs256Template(); static final KeyTemplate hs384Template(); static final KeyTemplate hs512Template();  }