I need a '开发者_如何学Pythonjava' source code on how to extract a cap file from the computer and divide it into blocks in order to send it using APDUs to the smart card to install or load or delete an application. Thanks in advance.
You're talking about GlobalPlatform and there's a right open source tool out there for this, called GPJ
I think you should start at http://java.sun.com/javacard/
Get the source code from http://gpj.svn.sourceforge.net/viewvc/gpj/
You may get some idea about dealing with CAP file in the method getEntries(ZipInputStream in)
of CapFile.java
private Map<String, byte[]> getEntries(ZipInputStream in)
throws IOException {
Map<String, byte[]> result = new HashMap<String, byte[]>();
while (true) {
ZipEntry entry = in.getNextEntry();
if (entry == null) {
break;
}
if (entry.getName().indexOf("MANIFEST.MF") != -1) {
continue;
}
ByteArrayOutputStream bos = new ByteArrayOutputStream();
byte[] buf = new byte[1024];
int c;
while ((c = in.read(buf)) > 0)
bos.write(buf, 0, c);
result.put(entry.getName(), bos.toByteArray());
}
return result;
}
精彩评论