@Test public void getPrimitive_ByteString_throwsInvalidKey() throws Exception { KeyManager<Aead> keyManager = new KeyManagerImpl<>(new TestKeyTypeManager(), Aead.class); MessageLite notAKey = AesGcmKey.getDefaultInstance(); try { keyManager.getPrimitive(notAKey.toByteString()); fail("expected GeneralSecurityException"); } catch (GeneralSecurityException e) { assertThat(e.toString()).contains("validateKey(AesGcmKey) failed"); } }
@Override public final PrimitiveT getPrimitive(ByteString serializedKey) throws GeneralSecurityException { try { KeyProtoT keyProto = keyTypeManager.parseKey(serializedKey); return validateKeyAndGetPrimitive(keyProto); } catch (InvalidProtocolBufferException e) { throw new GeneralSecurityException( "Failures parsing proto of type " + keyTypeManager.getKeyClass().getName(), e); } }
KeyManagerImpl implements KeyManager<PrimitiveT> { @Override public final PrimitiveT getPrimitive(ByteString serializedKey) throws GeneralSecurityException { try { KeyProtoT keyProto = keyTypeManager.parseKey(serializedKey); return validateKeyAndGetPrimitive(keyProto); } catch (InvalidProtocolBufferException e) { throw new GeneralSecurityException( "Failures parsing proto of type " + keyTypeManager.getKeyClass().getName(), e); } } }
KeyManagerImpl implements KeyManager<PrimitiveT> { @Override public final PrimitiveT getPrimitive(ByteString serializedKey) throws GeneralSecurityException { try { KeyProtoT keyProto = keyTypeManager.parseKey(serializedKey); return validateKeyAndGetPrimitive(keyProto); } catch (InvalidProtocolBufferException e) { throw new GeneralSecurityException( "Failures parsing proto of type " + keyTypeManager.getKeyClass().getName(), e); } } KeyManagerImpl(
      KeyTypeManager<KeyProtoT> keyTypeManager, Class<PrimitiveT> primitiveClass); }
KeyManagerImpl implements KeyManager<PrimitiveT> { @Override public final PrimitiveT getPrimitive(ByteString serializedKey) throws GeneralSecurityException { try { KeyProtoT keyProto = keyTypeManager.parseKey(serializedKey); return validateKeyAndGetPrimitive(keyProto); } catch (InvalidProtocolBufferException e) { throw new GeneralSecurityException( "Failures parsing proto of type " + keyTypeManager.getKeyClass().getName(), 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 PrimitiveT getPrimitive(ByteString serializedKey) throws GeneralSecurityException { try { KeyProtoT keyProto = keyTypeManager.parseKey(serializedKey); return validateKeyAndGetPrimitive(keyProto); } catch (InvalidProtocolBufferException e) { throw new GeneralSecurityException( "Failures parsing proto of type " + keyTypeManager.getKeyClass().getName(), 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();  }