aspyct / eid-applet

Automatically exported from code.google.com/p/eid-applet
Other
0 stars 0 forks source link

Non-blocking delegate for this.cardTerminal.isCardPresent() #60

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
be.fedict.eid.applet.sc.PcscEid:

Looking for a way to test that the current eid is still present in the 
cardTerminal we've accessed it from, without blocking if it is.

removeCard has the right functionality but it's blocking.

Any attempts to use isEidPresent() fail because of its exclusive lock on 
this.card. (And it does too much work to be called in a relatively tight loop 
anyway)

removeCard() has a small loop in it that I would like to loop myself, taking 
the occasional action while generally testing for the card's presence.

I did the following and the result does the trick for me (pulled the delegated 
isCardPresent() call into a new method isCardStillPresent()):

    public void removeCard() throws CardException {
        /*
         * Next doesn't work all the time.
         */
        // this.cardTerminal.waitForCardAbsent(0);
        while (isCardStillPresent()) {
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                this.view.addDetailMessage("sleep error: " + e.getMessage());
            }
        }
    }

public boolean isCardStillPresent() throws CardException
{
   return this.cardTerminal.isCardPresent();
}

Could isCardStillPresent or something similar be implemented officially, please?

WKR
FrankM.

Original issue reported on code.google.com by fr...@apsu.be on 23 Nov 2010 at 12:40

GoogleCodeExporter commented 9 years ago
I don't know where this became a "Defect" while it's a request for an 
enhancement..

Original comment by fr...@apsu.be on 23 Nov 2010 at 12:42

GoogleCodeExporter commented 9 years ago
Index: PcscEid.java
===================================================================
--- PcscEid.java        (revision 475)
+++ PcscEid.java        (working copy)
@@ -442,7 +442,7 @@
                 * Next doesn't work all the time.
                 */
                // this.cardTerminal.waitForCardAbsent(0);
-               while (this.cardTerminal.isCardPresent()) {
+               while (isCardStillPresent()) {
                        try {
                                Thread.sleep(100);
                        } catch (InterruptedException e) {
@@ -451,6 +451,11 @@
                }
        }

+        public boolean isCardStillPresent() throws CardException
+        {
+            return this.cardTerminal.isCardPresent();
+       }
+
        public List<X509Certificate> getAuthnCertificateChain()
                        throws CardException, IOException, CertificateException {
                List<X509Certificate> authnCertificateChain = new LinkedList<X509Certificate>();

Original comment by fr...@apsu.be on 30 Nov 2010 at 3:18

GoogleCodeExporter commented 9 years ago
http://code.google.com/p/eid-applet/source/detail?r=478

Original comment by frank.co...@gmail.com on 6 Dec 2010 at 4:27