@Test public void newKeyData_wrongKeySize_throws() throws Exception { KeyManager<Aead> keyManager = new KeyManagerImpl<>(new TestKeyTypeManager(), Aead.class); try { keyManager.newKeyData(AesGcmKeyFormat.newBuilder().setKeySize(17).build().toByteString()); fail("expected GeneralSecurityException"); } catch (GeneralSecurityException e) { assertThat(e.toString()).contains("validateKeyFormat(AesGcmKeyFormat) failed"); } }
@Override public final KeyData newKeyData(ByteString serializedKeyFormat) throws GeneralSecurityException { try { KeyProtoT key = keyFactoryHelper().parseValidateCreate(serializedKeyFormat); return KeyData.newBuilder() .setTypeUrl(getKeyType()) .setValue(key.toByteString()) .setKeyMaterialType(keyTypeManager.keyMaterialType()) .build(); } catch (InvalidProtocolBufferException e) { throw new GeneralSecurityException("Unexpected proto", e); } }
KeyManagerImpl implements KeyManager<PrimitiveT> { @Override public final KeyData newKeyData(ByteString serializedKeyFormat) throws GeneralSecurityException { try { KeyProtoT key = keyFactoryHelper().parseValidateCreate(serializedKeyFormat); return KeyData.newBuilder() .setTypeUrl(getKeyType()) .setValue(key.toByteString()) .setKeyMaterialType(keyTypeManager.keyMaterialType()) .build(); } catch (InvalidProtocolBufferException e) { throw new GeneralSecurityException("Unexpected proto", e); } } }
KeyManagerImpl implements KeyManager<PrimitiveT> { @Override public final KeyData newKeyData(ByteString serializedKeyFormat) throws GeneralSecurityException { try { KeyProtoT key = keyFactoryHelper().parseValidateCreate(serializedKeyFormat); return KeyData.newBuilder() .setTypeUrl(getKeyType()) .setValue(key.toByteString()) .setKeyMaterialType(keyTypeManager.keyMaterialType()) .build(); } catch (InvalidProtocolBufferException e) { throw new GeneralSecurityException("Unexpected proto", e); } } KeyManagerImpl(
      KeyTypeManager<KeyProtoT> keyTypeManager, Class<PrimitiveT> primitiveClass); }
KeyManagerImpl implements KeyManager<PrimitiveT> { @Override public final KeyData newKeyData(ByteString serializedKeyFormat) throws GeneralSecurityException { try { KeyProtoT key = keyFactoryHelper().parseValidateCreate(serializedKeyFormat); return KeyData.newBuilder() .setTypeUrl(getKeyType()) .setValue(key.toByteString()) .setKeyMaterialType(keyTypeManager.keyMaterialType()) .build(); } catch (InvalidProtocolBufferException e) { throw new GeneralSecurityException("Unexpected proto", e); } } KeyManagerImpl(
      KeyTypeManager<KeyProtoT> keyTypeManager, Class<PrimitiveT> primitiveClass); @Override final PrimitiveT getPrimitive(ByteString serializedKey); @Override final PrimitiveT getPrimitive(MessageLite key); @Override final MessageLite newKey(ByteString serializedKeyFormat); @Override final MessageLite newKey(MessageLite keyFormat); @Override final boolean doesSupport(String typeUrl); @Override final String getKeyType(); @Override int getVersion(); @Override final KeyData newKeyData(ByteString serializedKeyFormat); @Override final Class<PrimitiveT> getPrimitiveClass(); }
KeyManagerImpl implements KeyManager<PrimitiveT> { @Override public final KeyData newKeyData(ByteString serializedKeyFormat) throws GeneralSecurityException { try { KeyProtoT key = keyFactoryHelper().parseValidateCreate(serializedKeyFormat); return KeyData.newBuilder() .setTypeUrl(getKeyType()) .setValue(key.toByteString()) .setKeyMaterialType(keyTypeManager.keyMaterialType()) .build(); } catch (InvalidProtocolBufferException e) { throw new GeneralSecurityException("Unexpected proto", e); } } KeyManagerImpl(
      KeyTypeManager<KeyProtoT> keyTypeManager, Class<PrimitiveT> primitiveClass); @Override final PrimitiveT getPrimitive(ByteString serializedKey); @Override final PrimitiveT getPrimitive(MessageLite key); @Override final MessageLite newKey(ByteString serializedKeyFormat); @Override final MessageLite newKey(MessageLite keyFormat); @Override final boolean doesSupport(String typeUrl); @Override final String getKeyType(); @Override int getVersion(); @Override final KeyData newKeyData(ByteString serializedKeyFormat); @Override final Class<PrimitiveT> getPrimitiveClass();  }