CVS MCardApplet/src

CVS User rousseau ludovic.rousseau@free.fr
Sun, 28 Nov 2004 07:53:18 -0700


Update of /cvsroot/muscleplugins/MCardApplet/src
In directory haydn:/tmp/cvs-serv31072/src

Modified Files:
	CardEdge.java ObjectManager.java 
Log Message:
Do not list objects/keys not usable by the currently logged in identities
See http://archives.neohapsis.com/archives/dev/muscle/2004-q4/0250.html

Thanks to Peter Stamfest for the patch


--- /cvsroot/muscleplugins/MCardApplet/src/CardEdge.java	2003/11/19 13:07:19	1.7
+++ /cvsroot/muscleplugins/MCardApplet/src/CardEdge.java	2004/11/28 14:53:18	1.8
@@ -14,7 +14,7 @@
 //
 //      License:          See LICENSE file                       
 //
-//      $Id: CardEdge.java,v 1.7 2003/11/19 13:07:19 rousseau Exp $
+//      $Id: CardEdge.java,v 1.8 2004/11/28 14:53:18 rousseau Exp $
 
 package com.musclecard.CardEdge;
 
@@ -1394,7 +1394,7 @@
         else
         if (buffer[ISO7816.OFFSET_P1] != 1)
             ISOException.throwIt((short)SW_INCORRECT_P1);
-        for(; key_it < MAX_NUM_KEYS && (keys[key_it] == null || !keys[key_it].isInitialized()); key_it++);
+        for(; key_it < MAX_NUM_KEYS && (keys[key_it] == null || !keys[key_it].isInitialized() || (!authorizeKeyUse(key_it) && !authorizeKeyRead(key_it) && !authorizeKeyWrite(key_it))); key_it++);
         if (key_it < MAX_NUM_KEYS)
         {
             Key key = keys[key_it];
@@ -1421,12 +1421,12 @@
         boolean found = false;
         
         if (buffer[ISO7816.OFFSET_P1] == 0)
-            found = om.getFirstRecord(buffer, (short)0);
+            found = om.getFirstRecord(buffer, (short)0, logged_ids);
         else
         if (buffer[ISO7816.OFFSET_P1] != 1)
             ISOException.throwIt((short)SW_INCORRECT_P1);
         else
-            found = om.getNextRecord(buffer, (short)0);
+            found = om.getNextRecord(buffer, (short)0, logged_ids);
         if (found)
             apdu.setOutgoingAndSend((short)0, (short)14);
         else
--- /cvsroot/muscleplugins/MCardApplet/src/ObjectManager.java	2003/11/19 13:07:19	1.3
+++ /cvsroot/muscleplugins/MCardApplet/src/ObjectManager.java	2004/11/28 14:53:18	1.4
@@ -14,7 +14,7 @@
 //
 //      License:          See LICENSE file                       
 //
-//      $Id: ObjectManager.java,v 1.3 2003/11/19 13:07:19 rousseau Exp $
+//      $Id: ObjectManager.java,v 1.4 2004/11/28 14:53:18 rousseau Exp $
 
 package com.musclecard.CardEdge;
 
@@ -346,10 +346,10 @@
      *
      * @see #getNextRecord(byte[], short)
      */
-    public boolean getFirstRecord(byte buffer[], short offset)
+    public boolean getFirstRecord(byte buffer[], short offset, short logged_ids)
     {
         it = obj_list_head;
-        return getNextRecord(buffer, offset);
+        return getNextRecord(buffer, offset, logged_ids);
     }
 
     /**
@@ -364,21 +364,23 @@
      *
      * @see #getFirstRecord(byte[], short)
      */
-    public boolean getNextRecord(byte buffer[], short offset)
+    public boolean getNextRecord(byte buffer[], short offset, short logged_ids)
     {
-        if(it == -1)
-        {
-            return false;
-        } else
-        {
-            Util.setShort(buffer, offset, mem.getShort(it, (short)2));
-            Util.setShort(buffer, (short)(offset + 2), mem.getShort(it, (short)4));
-            Util.setShort(buffer, (short)(offset + 4), (short)0);
-            Util.setShort(buffer, (short)(offset + 6), mem.getShort(it, (short)12));
-            Util.arrayCopyNonAtomic(mem.getBuffer(), (short)(it + 6), buffer, (short)(offset + 8), (short)6);
-            it = mem.getShort(it, (short)0);
-            return true;
-        }
+        while (it != -1)
+		{
+			if (authorizeReadFromAddress((short)(it + 14), logged_ids))
+			{
+				Util.setShort(buffer, offset, mem.getShort(it, (short)2));
+				Util.setShort(buffer, (short)(offset + 2), mem.getShort(it, (short)4));
+				Util.setShort(buffer, (short)(offset + 4), (short)0);
+				Util.setShort(buffer, (short)(offset + 6), mem.getShort(it, (short)12));
+				Util.arrayCopyNonAtomic(mem.getBuffer(), (short)(it + 6), buffer, (short)(offset + 8), (short)6);
+				it = mem.getShort(it, (short)0);
+				return true;
+			}
+			it = mem.getShort(it, (short)0);
+		}
+		return false;
     }
 
     /**