use of iaik.pkcs.pkcs11.DefaultInitializeArgs in project xipki by xipki.
the class IaikP11Module method getInstance.
public static P11Module getInstance(P11ModuleConf moduleConf) throws P11TokenException {
ParamUtil.requireNonNull("moduleConf", moduleConf);
Module module;
try {
module = Module.getInstance(moduleConf.getNativeLibrary());
} catch (IOException ex) {
final String msg = "could not load the PKCS#11 module " + moduleConf.getName();
LogUtil.error(LOG, ex, msg);
throw new P11TokenException(msg, ex);
}
try {
module.initialize(new DefaultInitializeArgs());
} catch (PKCS11Exception ex) {
if (ex.getErrorCode() != PKCS11Constants.CKR_CRYPTOKI_ALREADY_INITIALIZED) {
LogUtil.error(LOG, ex);
close(moduleConf.getName(), module);
throw new P11TokenException(ex.getMessage(), ex);
} else {
LOG.info("PKCS#11 module already initialized");
if (LOG.isInfoEnabled()) {
try {
LOG.info("pkcs11.getInfo():\n{}", module.getInfo());
} catch (TokenException e2) {
LOG.debug("module.getInfo()", e2);
}
}
}
} catch (Throwable th) {
LOG.error("unexpected Exception", th);
close(moduleConf.getName(), module);
throw new P11TokenException(th.getMessage());
}
return new IaikP11Module(module, moduleConf);
}
Aggregations