← Back to overview
September 9, 2011 · Belgian eID C++

Belgian eID and .NET - Part 2: Modify the middleware and remove the confirmation dialog

In my previous post I talked about how you could build the eID middleware and create a sample application that uses the eID. When you start an application that uses the middleware you’ll see the following confirmation dialog that asks the user for permission to access the card.

An end user wouldn’t want this dialog to pop up all the time while working with eID cards. But since we have the sources we can modify the middleware and suppress the confirmation dialog. Let’s get started!

Modify the sources

Open the Visual Studio solution ‘eid-mw-3.5.5\eid-mw_src\eidmw_Builds\BeidEasyBuild_VS2008.sln’ we downloaded in the previous article. The confirmation dialog shows the message: The following application ‘xxx’ is trying to read data on the eID card. This is a good starting point to find the code resulting in this confirmation dialog.

When you search for this text in the solution you’ll find the text in the header file ‘eid-mw-3.5.5\eid-mw_src\eidmw\dialogs\language.h’ where the string is saved in a constant named TheFollowingApplication1IsTrying. This constant is used in the file ‘eid-mw-3.5.5\eid-mw_src\eidmw\dialogs\langUtil.cpp’ where it is part of the complete dialog text. This text is built in a switch statement under the DLGMESSAGEUSERWARNING case. Finally we can track this back to the APLEIDCard::askWarningLevel method in ‘eid-mw-3.5.5\eid-mw_src\eidmw\applayer\APLCardBeid.cpp’. Adapt the method to always set the warning level to ACCEPTED and return immediately.

void APL_EIDCard::askWarningLevel()  
{
    APL_AccessWarningLevel lWarningLevel=getWarningLevel();

    if(lWarningLevel==APL_ACCESSWARNINGLEVEL_REFUSED)
        throw CMWEXCEPTION(EIDMW_ERR_NOT_ALLOW_BY_USER);

    if(lWarningLevel==APL_ACCESSWARNINGLEVEL_BEING_ASKED)
        throw CMWEXCEPTION(EIDMW_ERR_USER_MUST_ANSWER);

    if(lWarningLevel==APL_ACCESSWARNINGLEVEL_TO_ASK)
    {
        // Set the warning level to accepted without displaying the dialog.
        setWarningLevel(APL_ACCESSWARNINGLEVEL_ACCEPTED);
        return;
    }
}

That’s it. Now it’s time to rebuild correctly.

Rebuild

First you need to rebuild the applayer project. Just like in the previous article you need to copy the .lib file to the other directory. So copy ‘eid-mw-3.5.5\eid-mw_src\eidmw_Builds\Release\applayer.lib’ to ‘eid-mw-3.5.5\eid-mw_src\eidmw_Binaries35\Release\’ and rename the file to beid35applayer.lib. After the file has been renamed you need to build the libCS_Wrapper *project by right clicking it and choosing **Build.

The directory ‘eid-mw-3.5.5\eid-mw_src\eidmw_Binaries35\Release’ will contain the updated libraries. Now just copy these files to the output directory of your application and you’ll be able to access the eID card without confirmation from the user.

Download the sample application (C#): SanLib.eID.Test.zip (932.19 kb)

Enjoy…

  • LinkedIn
  • Tumblr
  • Reddit
  • Google+
  • Pinterest
  • Pocket
Comments powered by Disqus