EngineFactory { public T_ENGINE getInstance(String algorithm) throws GeneralSecurityException { Exception cause = null; for (Provider provider : this.policy) { try { return this.instanceBuilder.getInstance(algorithm, provider); } catch (Exception e) { if (cause == null) { cause = e; } } } if (letFallback) { return this.instanceBuilder.getInstance(algorithm, null); } throw new GeneralSecurityException("No good Provider found.", cause); } EngineFactory(T_WRAPPER instanceBuilder);  EngineFactory(T_WRAPPER instanceBuilder, List<Provider> policy);  EngineFactory(T_WRAPPER instanceBuilder, List<Provider> policy, boolean letFallback); static final EngineFactory<EngineWrapper.TCipher, Cipher> getCustomCipherProvider(
      boolean letFallbackToDefault, String... providerNames); static final EngineFactory<EngineWrapper.TMac, Mac> getCustomMacProvider(
      boolean letFallbackToDefault, String... providerNames); static final EngineFactory<EngineWrapper.TSignature, Signature> getCustomSignatureProvider(
      boolean letFallbackToDefault, String... providerNames); static final EngineFactory<EngineWrapper.TMessageDigest, MessageDigest> getCustomMessageDigestProvider(boolean letFallbackToDefault, String... providerNames); static final EngineFactory<EngineWrapper.TKeyAgreement, KeyAgreement> getCustomKeyAgreementProvider(boolean letFallbackToDefault, String... providerNames); static final EngineFactory<EngineWrapper.TKeyPairGenerator, KeyPairGenerator> getCustomKeyPairGeneratorProvider(boolean letFallbackToDefault, String... providerNames); static final EngineFactory<EngineWrapper.TKeyFactory, KeyFactory> getCustomKeyFactoryProvider(boolean letFallbackToDefault, String... providerNames); static List<Provider> toProviderList(String... providerNames); T_ENGINE getInstance(String algorithm); static final EngineFactory<EngineWrapper.TCipher, Cipher> CIPHER; static final EngineFactory<EngineWrapper.TMac, Mac> MAC; static final EngineFactory<EngineWrapper.TSignature, Signature> SIGNATURE; static final EngineFactory<EngineWrapper.TMessageDigest, MessageDigest> MESSAGE_DIGEST; static final EngineFactory<EngineWrapper.TKeyAgreement, KeyAgreement> KEY_AGREEMENT; static final EngineFactory<EngineWrapper.TKeyPairGenerator, KeyPairGenerator> KEY_PAIR_GENERATOR; static final EngineFactory<EngineWrapper.TKeyFactory, KeyFactory> KEY_FACTORY; }
@Test public void testAtLeastGetsACipherByDefault() throws Exception { EngineFactory.CIPHER.getInstance("AES"); }
@Test public void testIsReuseable() throws Exception { EngineFactory.CIPHER.getInstance("AES"); EngineFactory.CIPHER.getInstance("AES"); EngineFactory.CIPHER.getInstance("AES"); }