public synchronized P11CryptService getP11CryptService(String moduleName) throws XiSecurityException, P11TokenException { if (p11Conf == null) { throw new IllegalStateException("please set pkcs11ConfFile and then call init() first"); } final String name = getModuleName(moduleName); P11ModuleConf conf = p11Conf.getModuleConf(name); if (conf == null) { throw new XiSecurityException("PKCS#11 module " + name + " is not defined"); } P11CryptService instance = services.get(moduleName); if (instance == null) { P11Module p11Module = p11ModuleFactoryRegister.getP11Module(conf); instance = new P11CryptService(p11Module); LOG.info("added PKCS#11 module {}\n{}", moduleName, instance.getModule().getDescription()); services.put(moduleName, instance); } return instance; }
public synchronized P11CryptService getP11CryptService(String moduleName) throws XiSecurityException, P11TokenException { try { init(); } catch (InvalidConfException ex) { throw new IllegalStateException( "could not initialize P11CryptServiceFactory: " + ex.getMessage(), ex); } if (moduleConfs == null) { throw new IllegalStateException("please set pkcs11ConfFile and then call init() first"); } final String name = getModuleName(moduleName); P11ModuleConf conf = moduleConfs.get(name); if (conf == null) { throw new XiSecurityException("PKCS#11 module " + name + " is not defined"); } P11CryptService instance = services.get(name); if (instance == null) { P11Module p11Module = p11ModuleFactoryRegister.getP11Module(conf); instance = new P11CryptService(p11Module); LOG.info("added PKCS#11 module {}\n{}", name, instance.getModule().getDescription()); services.put(name, instance); } return instance; }
public synchronized P11CryptService getP11CryptService(final String moduleName) throws XiSecurityException, P11TokenException { if (p11Conf == null) { throw new IllegalStateException("please set pkcs11ConfFile and then call init() first"); } final String name = getModuleName(moduleName); P11ModuleConf conf = p11Conf.moduleConf(name); if (conf == null) { throw new XiSecurityException("PKCS#11 module " + name + " is not defined"); } P11CryptService instance = services.get(moduleName); if (instance != null) { return instance; } String nativeLib = conf.nativeLibrary(); P11Module p11Module = modules.get(nativeLib); if (p11Module == null) { if (StringUtil.startsWithIgnoreCase(nativeLib, ProxyP11Module.PREFIX)) { p11Module = ProxyP11Module.getInstance(conf); } else if (StringUtil.startsWithIgnoreCase(nativeLib, EmulatorP11Module.PREFIX)) { p11Module = EmulatorP11Module.getInstance(conf); } else { p11Module = IaikP11Module.getInstance(conf); } } modules.put(nativeLib, p11Module); instance = new P11CryptService(p11Module); services.put(moduleName, instance); return instance; }