use of org.openecard.mdlw.sal.exceptions.InitializationException in project open-ecard by ecsec.
the class MiddlewareSAL method initialize.
@Override
public InitializeResponse initialize(Initialize parameters) {
InitializeResponse resp = WSHelper.makeResponse(InitializeResponse.class, WSHelper.makeResultOK());
try {
mwModule.initialize();
eventMan.initialize();
if (gui == null) {
throw new InternalAppError("GUI is not initialized.");
}
} catch (UnsatisfiedLinkError | InitializationException ex) {
String mwSALName = mwSALConfig.getMiddlewareName();
String msg = String.format("Failed to initialize Middleware for '%s'-SAL.", mwSALName);
if (mwSALConfig.isSALRequired()) {
LOG.error(msg, ex);
resp.setResult(WSHelper.makeResultError(ECardConstants.Minor.Disp.COMM_ERROR, msg));
} else {
LOG.warn(msg, ex);
resp.setResult(WSHelper.makeResult(ECardConstants.Major.WARN, ECardConstants.Minor.App.NOT_INITIALIZED, msg));
}
} catch (InternalAppError ex) {
LOG.error(ex.getMessage());
resp.setResult(ex.getResult());
}
return resp;
}
use of org.openecard.mdlw.sal.exceptions.InitializationException in project open-ecard by ecsec.
the class MwModule method initialize.
/**
* Initializes the Cryptoki library.
*
* @throws UnsatisfiedLinkError Thrown in case the library could not be found.
* @throws InitializationException Thrown in case the Middleware could not be initialized.
*/
public void initialize() throws UnsatisfiedLinkError, InitializationException {
try {
mw = new MiddleWareWrapper(mwSALConfig);
mw.initialize();
} catch (CryptokiException ex) {
throw new InitializationException("Failed to initalize PKCS#11 middleware.", ex.getErrorCode());
}
}
use of org.openecard.mdlw.sal.exceptions.InitializationException in project open-ecard by ecsec.
the class MwEventManager method initialize.
public void initialize() throws InitializationException {
// start watcher thread
try {
DatatypeFactory dataFactory = DatatypeFactory.newInstance();
MwEventRunner runner = new MwEventRunner(env, builder, dataFactory, mwSAL.getMwModule(), mwCallback);
runner.initRunner();
watcher = new FutureTask<>(runner, null);
Thread t = new Thread(watcher, "MwEventManager");
t.start();
} catch (CryptokiException ex) {
LOG.error("Failed to initialize middleware event runner.", ex);
throw new InitializationException("Failed to request initial status from middleware.", ex.getErrorCode());
} catch (DatatypeConfigurationException ex) {
throw new UnsupportedOperationException("Datatype factory not supported.", ex);
}
}
Aggregations