/** * Convenience method for generating a new key for the specified {@code format}. * * <p>It looks up a {@link KeyManager} identified by {@code keyTemplate.type_url}, and calls * {@link KeyManager#newKey} with {@code format} as the parameter. * * @return a new key */ public static synchronized <P> MessageLite newKey(String typeUrl, MessageLite format) throws GeneralSecurityException { KeyManager<P> manager = getKeyManager(typeUrl); if (newKeyAllowedMap.get(typeUrl).booleanValue()) { return manager.newKey(format); } else { throw new GeneralSecurityException("newKey-operation not permitted for key type " + typeUrl); } }
/** * Convenience method for generating a new key for the specified {@code keyTemplate}. * * <p>It looks up a {@link KeyManager} identified by {@code keyTemplate.type_url}, and calls * {@link KeyManager#newKey} with {@code keyTemplate} as the parameter. * * @return a new key */ public static synchronized <P> MessageLite newKey(KeyTemplate keyTemplate) throws GeneralSecurityException { KeyManager<P> manager = getKeyManager(keyTemplate.getTypeUrl()); if (newKeyAllowedMap.get(keyTemplate.getTypeUrl()).booleanValue()) { return manager.newKey(keyTemplate.getValue()); } else { throw new GeneralSecurityException( "newKey-operation not permitted for key type " + keyTemplate.getTypeUrl()); } }