|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.ibm.jc.CapFile
Allows to load a Java Card package from a CAP-file. After loading various information is avaliable from public fields. Furthermore, this class allows to manage Global Platform properties such as DAP blocks and Delegated Management tokens, which can be stored in CAP-files.
| Field Summary | |
static byte |
ACC_APPLET
CAP file package flag indicating if an Applet component is included in this package. |
static byte |
ACC_EXPORT
CAP file package flag indicating if an Export component is included in this package. |
static byte |
ACC_INT
CAP file package flag indicating if Java type int is used in this package. |
byte[][] |
aids
The list of applets contained in this package. |
byte[][] |
allComponents
CAP components available in this CAP file. |
static int |
CAP_V21
CAP file version 2.1 |
static int |
CAP_V22
CAP file version 2.2 |
int |
capVersion
The CAP file version as indicated in the Header Component. |
byte[] |
code
The package data which is actually uploaded to the card. |
byte[][] |
components
CAP components in the sequence as to be loaded onto the card. |
static int |
DAP_DEBUG
Flag indicating DESCRIPTOR/DEBUG component to be included in signature. |
DAPBlock[] |
dapBlocks
A list of Load File DAP blocks. |
int |
effCodeSize
Effective code size of the package when loaded onto the card. |
byte |
flags
Bit mask holding CAP file package flags. |
byte[][] |
imports
The list of packages imported by this package. |
InstallToken[] |
installTokens
A list of Install Tokens for delegated installation. |
LoadToken[] |
loadTokens
A list of Load Tokens for delegated loading. |
int |
numDapBlocks
Number of DAP blocks in the dapBlocks array. |
int |
numInstallTokens
Number of Install Tokens in the installTokens array. |
int |
numLoadTokens
Number of Load Tokens in the loadTokens array. |
java.lang.String |
pkg
The Java package name. |
byte[] |
pkgId
The package AID. |
java.lang.String |
pkgInternal
Internal package name as included in Header component. |
java.lang.String |
pkgPath
The package path in the CAP file. |
int |
pkgVersion
Package version. |
int |
s_applets
Size of all applet AIDs in this package (in bytes). |
int |
s_classes
Size of all class information in this package (in bytes). |
int |
s_exports
Size of all export information this package (in bytes). |
int |
s_methods
Size of all methods in this package (in bytes). |
int |
s_pkgAID
Size of the package AID (in bytes). |
int |
s_statics
Size of all static data this package (in bytes). |
| Constructor Summary | |
CapFile(java.lang.String f,
java.lang.String pkg)
Constructor. |
|
| Method Summary | |
void |
appendDapBlock(byte[] aid,
byte[] sig)
Deprecated. |
void |
appendDapBlock(byte[] aid,
byte[] sig,
java.lang.String targetFile)
Deprecated. |
void |
appendDapBlock(byte[] aid,
byte[] sig,
java.lang.String targetFile,
int dapAlg,
java.lang.Object cert)
Add a new DAP block to the CAP-file. |
void |
appendInstallToken(byte[] sig,
byte[] appAID,
byte[] instAID,
int privs,
byte[] params)
Deprecated. |
void |
appendInstallToken(byte[] sig,
byte[] appAID,
byte[] instAID,
int privs,
byte[] params,
java.lang.String targetFile)
Add a new Install Token to the CAP-file |
void |
appendLoadToken(byte[] sig,
byte[] sdaid,
byte[] params)
Deprecated. |
void |
appendLoadToken(byte[] sig,
byte[] sdaid,
byte[] params,
java.lang.String targetFile)
Add a new Load Token to the CAP-file. |
void |
clearMetaInf()
Remove all DAP/DM information for the current package from the CAP-file. |
static java.lang.String |
fSig(java.lang.String sig,
int indent,
int len)
Formats a signature string for printing. |
byte[] |
generateDAP(java.lang.Object key)
Deprecated. |
byte[] |
generateDAP(java.lang.Object key,
int dapAlg)
Generates a Load File Data Block signature. |
static byte[] |
generateInstallToken(byte[] pkg,
int pkgBeg,
int pkgLen,
byte[] app,
int appBeg,
int appLen,
byte[] inst,
int instBeg,
int instLen,
int privs,
byte[] param,
int paramBeg,
int paramLen,
java.lang.Object key)
Generates an install token to be used in delegated installation. |
byte[] |
generateLoadToken(byte[] sd,
int sdBeg,
int sdLen,
byte[] param,
int paramBeg,
int paramLen,
java.lang.Object key)
Generates a load token to be used in delegated loading. |
byte[] |
getCodeDebug()
Returns the package code including the DESCRIPTOR/DEBUG component. |
byte[] |
getCodeHeader()
Returns information to be prepended to the code before loading onto the card. |
byte[] |
getEncodedDapBlocks()
Concatenates all encoded DAP blocks as needed for loading. |
byte[] |
getLoadFile()
Builds the concatentaion of the load file header and the load file data. |
byte[] |
getLoadFileDataHash()
Generates a SHA-1 digest over the load file data. |
byte[] |
getLoadFileDataHash(int flags)
Generates a SHA-1 digest over the load file data. |
byte[] |
getLoadFileHash()
Generates a SHA-1 digest over the load file. |
java.lang.String |
infoString()
Returns a printable string providing all known information about the CAP file. |
void |
installAuthorize(byte[] appAID,
byte[] instAID,
int privs,
byte[] params,
java.lang.Object key)
Deprecated. |
void |
installAuthorize(byte[] appAID,
byte[] instAID,
int privs,
byte[] params,
java.lang.Object key,
java.lang.String targetFile)
Generates an Install Token and writes the Install Token information to the CAP-file. |
void |
loadAuthorize(byte[] sdaid,
byte[] params,
java.lang.Object key)
Deprecated. |
void |
loadAuthorize(byte[] sdaid,
byte[] params,
java.lang.Object key,
java.lang.String targetFile)
Generates a Load Token and writes the Load Token information to the CAP-file. |
static java.lang.Object |
makePrivateCert(byte[] x509,
byte[] pkcs8)
Makes a private certificate object from X.509 and PKCS#8 data. |
static java.lang.Object |
makePrivateCert(byte[] pkcs12,
java.lang.String pin)
Makes a private certificate object from PKCS#12 data. |
static java.lang.Object |
makePublicCert(byte[] x509)
Makes a public certificate object from X.509 data. |
void |
readCapFile(java.lang.String f,
java.lang.String pkg)
Loads a Java Card package from a CAP-file and fills up the public fields. |
void |
signCapFile(byte[] aid,
java.lang.Object key)
Deprecated. |
void |
signCapFile(byte[] aid,
java.lang.Object key,
java.lang.String targetFile)
Deprecated. |
void |
signCapFile(byte[] aid,
java.lang.Object key,
java.lang.String targetFile,
int dapAlg)
Generates a DAP block and writes the DAP information to the CAP-file. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int DAP_DEBUG
public static final int CAP_V21
capVersion,
Constant Field Valuespublic static final int CAP_V22
capVersion,
Constant Field Valuespublic static final byte ACC_INT
int is used in this package.
flags,
Constant Field Valuespublic static final byte ACC_EXPORT
flags,
Constant Field Valuespublic static final byte ACC_APPLET
flags,
Constant Field Valuespublic int capVersion
CAP_V21,
CAP_V22public byte[][] components
null.
code,
allComponentspublic byte[][] allComponents
null.
code,
componentspublic byte[] code
components,
allComponentspublic int pkgVersion
public byte flags
ACC_INT,
ACC_EXPORT,
ACC_APPLETpublic byte[] pkgId
public java.lang.String pkg
public java.lang.String pkgInternal
public java.lang.String pkgPath
public byte[][] aids
null if no applets
are included in this package.
public byte[][] imports
public int effCodeSize
s_pkgAID,
s_applets,
s_classes,
s_methods,
s_statics,
s_exportspublic int s_pkgAID
effCodeSizepublic int s_applets
effCodeSizepublic int s_classes
effCodeSizepublic int s_methods
effCodeSizepublic int s_statics
effCodeSizepublic int s_exports
effCodeSizepublic DAPBlock[] dapBlocks
numDapBlockspublic int numDapBlocks
dapBlocks array.
dapBlockspublic LoadToken[] loadTokens
numLoadTokenspublic int numLoadTokens
loadTokens array.
loadTokenspublic InstallToken[] installTokens
numInstallTokenspublic int numInstallTokens
installTokens array.
installTokens| Constructor Detail |
public CapFile(java.lang.String f,
java.lang.String pkg)
throws java.lang.Exception
f - CAP file to be loaded.pkg - Java package name of the package in the JAR file.
If null the first package found will be loaded.
java.lang.Exception - If the CAP-file could no be loaded or parsed.readCapFile(java.lang.String, java.lang.String)| Method Detail |
public void readCapFile(java.lang.String f,
java.lang.String pkg)
throws java.lang.Exception
f - CAP-file to be loaded.pkg - Java package name of the package in the JAR file.
If null the first package found will be loaded.
java.lang.Exception - If CAP file could no be loaded or parsed.public byte[] getCodeDebug()
code[] array is returned.
public byte[] getLoadFileDataHash(int flags)
flags - DAP_DEBUG defines that DESCRIPTOR/DEBUG components are included
in the digest, otherwise this parameter can be zero.
JCException - if the key is not valid or no
load file data available.DAP_DEBUGpublic byte[] getLoadFileDataHash()
JCException - if the key is not valid or no
load file data available.public byte[] getLoadFileHash()
public byte[] getLoadFile()
JCException - if the key is not valid or no
load file data available.
public static byte[] generateInstallToken(byte[] pkg,
int pkgBeg,
int pkgLen,
byte[] app,
int appBeg,
int appLen,
byte[] inst,
int instBeg,
int instLen,
int privs,
byte[] param,
int paramBeg,
int paramLen,
java.lang.Object key)
pkg - package AID.pkgBeg - offset in pkg.pkgLen - length of the AID in pkg.app - applet AID in the package.appBeg - offset in app.appLen - length of the AID in app.inst - desired instance AID. If null it defaults
to the applet AID.instBeg - offset in inst.instLen - length of the AID in inst.privs - desired application privileges.param - install parameters (raw format). This parameter
is optional and can be null.paramBeg - offset in param.paramLen - length of install parameters.key - the RSA private certificate to be used for
token generation.
JCException - if the key is not validmakePrivateCert(byte[], java.lang.String)
public byte[] generateLoadToken(byte[] sd,
int sdBeg,
int sdLen,
byte[] param,
int paramBeg,
int paramLen,
java.lang.Object key)
sd - AID of the security domain to be associated
withe the package and it's applets. This
parameter is optional and can be null.sdBeg - offset in sd.sdLen - length of the AID in sd.param - load parameters (raw format). This parameter
is optional and can be null.paramBeg - offset in param.paramLen - length of install parameters.key - the RSA private certificate to be used for
token generation.
JCException - if the key is not valid or no
load file data available.makePrivateCert(byte[], java.lang.String)
public byte[] generateDAP(java.lang.Object key,
int dapAlg)
key - DES key or RSA private key to be used
for signature generation. This can be
an OPKey object (DES) or a private certificate object (RSA).dapAlg - the DAP generation algorithm. The flag DAP_DEBUG
might additionaly be set.
JCException - if the key is not valid or no
load file data available.DAPBlock.DES_DAP_ALG_201,
DAPBlock.DES_DAP_ALG_211,
DAPBlock.PK_DAP_ALG_201,
DAPBlock.PK_DAP_ALG_211,
DAP_DEBUG,
makePrivateCert(byte[], java.lang.String)public byte[] generateDAP(java.lang.Object key)
key - DES key or RSA private key to be used
for signature generation. This can be
an OPKey object (DES) or a private certificate object (RSA).
JCException - if the key is not valid or no
load file data available.makePrivateCert(byte[], java.lang.String)
public void signCapFile(byte[] aid,
java.lang.Object key,
java.lang.String targetFile,
int dapAlg)
aid - AID of the target Security Domain to
do the DAP verification.key - the DAP generation key (OPKey obejct for DES keys, private
certificate object otherwise).targetFile - the location and name of the target CAP-file if
the original file is not to be modified, null otherwise.
Note: if targetFile is not null, the CAP-file object
represents the target file upon method invocation.dapAlg - the DAP generation algorithm. The flag DAP_DEBUG
might additionaly be set.DAPBlock.DES_DAP_ALG_201,
DAPBlock.DES_DAP_ALG_211,
DAPBlock.PK_DAP_ALG_201,
DAPBlock.PK_DAP_ALG_211,
DAP_DEBUG,
makePrivateCert(byte[], java.lang.String)
public void signCapFile(byte[] aid,
java.lang.Object key,
java.lang.String targetFile)
aid - AID of the target Security Domain to
do the DAP verification.key - the DAP generation key (OPKey obejct for DES keys, private
certificate object otherwise).targetFile - the location and name of the target CAP-file if
the original file is not to be modified, null otherwise.
Note: if targetFile is not null, the CAP-file object
represents the target file upon method invocation.makePrivateCert(byte[], java.lang.String)
public void signCapFile(byte[] aid,
java.lang.Object key)
aid - AID of the target Security Domain to
do the DAP verification.key - the DAP generation key (OPKey obejct for DES keys, private
certificate object otherwise).makePrivateCert(byte[], java.lang.String)
public void loadAuthorize(byte[] sdaid,
byte[] params,
java.lang.Object key,
java.lang.String targetFile)
sdaid - AID of the Security Domain to be associated
with the package and it's applets (null meand CardManager).params - load parameters or null.key - the Load Token generation key (a private certificate object).targetFile - the location and name of the target CAP-file if
the original file is not to be modified, null otherwise.
Note: if targetFile is not null, the CAP-file object
represents the target file upon method invocation.makePrivateCert(byte[], java.lang.String)
public void loadAuthorize(byte[] sdaid,
byte[] params,
java.lang.Object key)
sdaid - AID of the Security Domain to be associated
with the package and it's applets (null meand CardManager).params - load parameters or null.key - the Load Token generation key (a private certificate object).makePrivateCert(byte[], java.lang.String)
public void installAuthorize(byte[] appAID,
byte[] instAID,
int privs,
byte[] params,
java.lang.Object key,
java.lang.String targetFile)
appAID - the applet AID.instAID - the instance AID or null.privs - the application privileges.params - install parameters or null.key - the Install Token generation key (a private certificate object).targetFile - the location and name of the target CAP-file if
the original file is not to be modified, null otherwise.
Note: if targetFile is not null, the CAP-file object
represents the target file upon method invocation.makePrivateCert(byte[], java.lang.String)
public void installAuthorize(byte[] appAID,
byte[] instAID,
int privs,
byte[] params,
java.lang.Object key)
appAID - the applet AID.instAID - the instance AID or null.privs - the application privileges.params - install parameters or null.key - the Install Token generation key (a private certificate object).makePrivateCert(byte[], java.lang.String)
public void appendLoadToken(byte[] sig,
byte[] sdaid,
byte[] params,
java.lang.String targetFile)
sig - the Load Token.sdaid - Security Domain AID.params - load parametes.targetFile - the location and name of the target CAP-file if
the original file is not to be modified, null otherwise.
Note: if targetFile is not null, the CAP-file object
represents the target file upon method invocation.
public void appendLoadToken(byte[] sig,
byte[] sdaid,
byte[] params)
sig - the Load Token.sdaid - Security Domain AID.params - load parametes.
public void appendInstallToken(byte[] sig,
byte[] appAID,
byte[] instAID,
int privs,
byte[] params,
java.lang.String targetFile)
sig - the Install Token.appAID - the applet AID.instAID - the instance AID or null.privs - the application privileges.params - install parameters or null.targetFile - the location and name of the target CAP-file if
the original file is not to be modified, null otherwise.
Note: if targetFile is not null, the CAP-file object
represents the target file upon method invocation.
public void appendInstallToken(byte[] sig,
byte[] appAID,
byte[] instAID,
int privs,
byte[] params)
sig - the Install Token.appAID - the applet AID.instAID - the instance AID or null.privs - the application privileges.params - install parameters or null.public void clearMetaInf()
public byte[] getCodeHeader()
public byte[] getEncodedDapBlocks()
public void appendDapBlock(byte[] aid,
byte[] sig,
java.lang.String targetFile,
int dapAlg,
java.lang.Object cert)
aid - Security Domain AID.sig - DAP.targetFile - the location and name of the target CAP-file if
the original file is not to be modified, null otherwise.
Note: if targetFile is not null, the CAP-file object
represents the target file upon method invocation.dapAlg - the DAP generation algorithm.cert - certificate object used to generate the DAP (can be a public or private
certificate since only the X.509 data, not the private key, is added to the CAP-file).
This parameter is only applicalbe in case of PK DAP.
This parameter might be null.DAPBlock.DES_DAP_ALG_201,
DAPBlock.DES_DAP_ALG_211,
DAPBlock.PK_DAP_ALG_201,
DAPBlock.PK_DAP_ALG_211,
makePrivateCert(byte[], java.lang.String),
makePublicCert(byte[])
public void appendDapBlock(byte[] aid,
byte[] sig,
java.lang.String targetFile)
aid - Security Domain AID.sig - DAP.targetFile - the location and name of the target CAP-file if
the original file is not to be modified, null otherwise.
Note: if targetFile is not null, the CAP-file object
represents the target file upon method invocation.
public void appendDapBlock(byte[] aid,
byte[] sig)
aid - Security Domain AID.sig - DAP.public java.lang.String infoString()
public static java.lang.Object makePrivateCert(byte[] pkcs12,
java.lang.String pin)
pkcs12 - the PKCS#12 encoded data.pin - the PIN protecting the PKCS#12 data.
null
if the method fails for any reason.generateInstallToken(byte[], int, int, byte[], int, int, byte[], int, int, int, byte[], int, int, java.lang.Object),
generateLoadToken(byte[], int, int, byte[], int, int, java.lang.Object),
generateDAP(java.lang.Object, int),
signCapFile(byte[], java.lang.Object, java.lang.String, int),
loadAuthorize(byte[], byte[], java.lang.Object, java.lang.String),
installAuthorize(byte[], byte[], int, byte[], java.lang.Object, java.lang.String),
appendDapBlock(byte[], byte[], java.lang.String, int, java.lang.Object)
public static java.lang.Object makePrivateCert(byte[] x509,
byte[] pkcs8)
x509 - the X.509 certificate.pkcs8 - the corresponding PKCS#8 encoded private key.
null
if the method fails for any reason.generateInstallToken(byte[], int, int, byte[], int, int, byte[], int, int, int, byte[], int, int, java.lang.Object),
generateLoadToken(byte[], int, int, byte[], int, int, java.lang.Object),
generateDAP(java.lang.Object, int),
signCapFile(byte[], java.lang.Object, java.lang.String, int),
loadAuthorize(byte[], byte[], java.lang.Object, java.lang.String),
installAuthorize(byte[], byte[], int, byte[], java.lang.Object, java.lang.String),
appendDapBlock(byte[], byte[], java.lang.String, int, java.lang.Object)public static java.lang.Object makePublicCert(byte[] x509)
appendDapBlock().
x509 - the X.509 certificate.
null
if the method fails for any reason.appendDapBlock(byte[], byte[], java.lang.String, int, java.lang.Object)
public static java.lang.String fSig(java.lang.String sig,
int indent,
int len)
sig - signature string to be formated.indent - number of blanks to be prepended to
each line except the first.len - desired line length.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||