Search in sources :

Example 1 with InitializationException

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;
}
Also used : InitializeResponse(iso.std.iso_iec._24727.tech.schema.InitializeResponse) InitializationException(org.openecard.mdlw.sal.exceptions.InitializationException) InternalAppError(org.openecard.common.sal.exception.InternalAppError)

Example 2 with InitializationException

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());
    }
}
Also used : CryptokiException(org.openecard.mdlw.sal.exceptions.CryptokiException) InitializationException(org.openecard.mdlw.sal.exceptions.InitializationException)

Example 3 with InitializationException

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);
    }
}
Also used : DatatypeConfigurationException(javax.xml.datatype.DatatypeConfigurationException) DatatypeFactory(javax.xml.datatype.DatatypeFactory) CryptokiException(org.openecard.mdlw.sal.exceptions.CryptokiException) InitializationException(org.openecard.mdlw.sal.exceptions.InitializationException)

Aggregations

InitializationException (org.openecard.mdlw.sal.exceptions.InitializationException)3 CryptokiException (org.openecard.mdlw.sal.exceptions.CryptokiException)2 InitializeResponse (iso.std.iso_iec._24727.tech.schema.InitializeResponse)1 DatatypeConfigurationException (javax.xml.datatype.DatatypeConfigurationException)1 DatatypeFactory (javax.xml.datatype.DatatypeFactory)1 InternalAppError (org.openecard.common.sal.exception.InternalAppError)1