@Test public void testRefusesToClonePKCS11Cipher() throws NoSuchAlgorithmException, NoSuchPaddingException { final Provider pkcs11Provider = ExternalSecurityProviderLoader.getPkcs11Provider(); if (pkcs11Provider == null) { throw new SkipException("PKCS11 Security Provider not present."); } final String cipherName = DefaultsConfigContext.DEFAULT_CIPHER.getCipherAlgorithm(); final Cipher cipher = Cipher.getInstance(cipherName, pkcs11Provider); Assert.assertThrows(MantaMemoizationException.class, () -> { new CipherCloner().createClone(cipher); }); }
@Override public Cipher createClone(final Cipher source) { final Provider pkcs11Provider = ExternalSecurityProviderLoader.getPkcs11Provider(); final Provider cipherProvider = source.getProvider(); if (pkcs11Provider != null && cipherProvider.equals(pkcs11Provider)) { String msg = String.format("Cannot create clone of Cipher with provider: %s", source.getProvider()); throw new MantaMemoizationException(msg); } return INSTANCE.deepClone(source); }
CipherCloner implements Cloner<Cipher> { @Override public Cipher createClone(final Cipher source) { final Provider pkcs11Provider = ExternalSecurityProviderLoader.getPkcs11Provider(); final Provider cipherProvider = source.getProvider(); if (pkcs11Provider != null && cipherProvider.equals(pkcs11Provider)) { String msg = String.format("Cannot create clone of Cipher with provider: %s", source.getProvider()); throw new MantaMemoizationException(msg); } return INSTANCE.deepClone(source); } }
CipherCloner implements Cloner<Cipher> { @Override public Cipher createClone(final Cipher source) { final Provider pkcs11Provider = ExternalSecurityProviderLoader.getPkcs11Provider(); final Provider cipherProvider = source.getProvider(); if (pkcs11Provider != null && cipherProvider.equals(pkcs11Provider)) { String msg = String.format("Cannot create clone of Cipher with provider: %s", source.getProvider()); throw new MantaMemoizationException(msg); } return INSTANCE.deepClone(source); }  }
CipherCloner implements Cloner<Cipher> { @Override public Cipher createClone(final Cipher source) { final Provider pkcs11Provider = ExternalSecurityProviderLoader.getPkcs11Provider(); final Provider cipherProvider = source.getProvider(); if (pkcs11Provider != null && cipherProvider.equals(pkcs11Provider)) { String msg = String.format("Cannot create clone of Cipher with provider: %s", source.getProvider()); throw new MantaMemoizationException(msg); } return INSTANCE.deepClone(source); }  @Override Cipher createClone(final Cipher source); }
CipherCloner implements Cloner<Cipher> { @Override public Cipher createClone(final Cipher source) { final Provider pkcs11Provider = ExternalSecurityProviderLoader.getPkcs11Provider(); final Provider cipherProvider = source.getProvider(); if (pkcs11Provider != null && cipherProvider.equals(pkcs11Provider)) { String msg = String.format("Cannot create clone of Cipher with provider: %s", source.getProvider()); throw new MantaMemoizationException(msg); } return INSTANCE.deepClone(source); }  @Override Cipher createClone(final Cipher source);  }