class EncryptionProviderFactory {

  public EncryptionProvider getEncryptionService(final EncryptionKeyProvider provider) throws Exception {
    final EncryptionProvider encryptionService;

    if (map.containsKey(provider.getProviderName())) {
      return map.get(provider.getProviderName());
    } else {
      switch (provider.getProviderType()) {
        case HSM:
          encryptionService = new LunaEncryptionService(new LunaConnection(provider.getConfiguration()),
            encryptionKeysConfiguration.isKeyCreationEnabled(),
            timedRetry);
          break;
        case KMS_PLUGIN:
          encryptionService = new KMSEncryptionProvider(provider.getConfiguration());
          break;
        default:
          encryptionService = new PasswordEncryptionService(passwordKeyProxyFactory);
          break;
      }
      map.put(provider.getProviderName(), encryptionService);
      return encryptionService;
    }
  }

  @Autowired public  EncryptionProviderFactory(final EncryptionKeysConfiguration keysConfiguration, final TimedRetry timedRetry,
                                   final PasswordKeyProxyFactory passwordKeyProxyFactory);

}