FileDocCategorySizeDatePackage
DIRF.javaAPI DocphoneME MR2 API (J2ME)6342Wed May 02 18:00:38 BST 2007com.sun.satsa.util.pkcs15

DIRF

public class DIRF extends PKCS15File
This class represents the PKCS15 DIR file abstraction.
It is assumed that the DIR file contains information about
files in the following format:
APP_CONSTRUCTED_1 { [APPLICATION 1]
APP_PRIMITIVE_15 Aid (Octet_string)
APP_PRIMITIVE_16 label (UTF8String / opt)
APP_PRIMITIVE_17 path (octet_string)
APP_PRIMITIVE_19 { DDO (ddo / opt)
SEQUENCE {
oid OBJECT IDENTIFIER,
odfPath Path OPTIONAL,
tokenInfoPath [0] Path OPTIONAL,
unusedPath [1] Path OPTIONAL,
}
}
}

Fields Summary
public static final int
WRONG_DIR_FILE
Wrong DIR file status code
public static final int
SUCCESS
Success status code
public static final int
AID_NOT_FOUND
AID is not found status code
public static final int
ROOT_NOT_SELECTED
Root is not selected status code
byte[]
PKCS_AID
The PKCS15 application AID (according to pkcs15 spec.
short[]
DIR_FILE
The PKCS15 DIR file name
public static final int
APPLICATION
ASN application specific flag used in types (0x40).
public static final int
APP_CONSTRUCTED_0
ASN application specific constructed flag used in types (0x60).
public static final int
APP_PRIMITIVE_0
ASN application specific primitive flag
public static final int
APP_CONSTRUCTED_1
ASN application specific constructed flag used in types (0x60).
public static final int
APP_PRIMITIVE_15
ASN application specific flag for [APPLICATION 15] (aid)
public static final int
APP_PRIMITIVE_16
ASN application specific flag for [APPLICATION 16] (label)
public static final int
APP_PRIMITIVE_17
ASN application specific flag for [APPLICATION 17] (path)
public static final int
APP_CONSTRUCTED_19
ASN application specific flag for [APPLICATION 19] (ddo)
private Vector
DIR
This vector contains parsed objects from DIR
Constructors Summary
public DIRF(FileSystemAbstract fs)
Creates the DIRF object

param
fs FileSystemAbstract file system that is used to reading from file.


                         
       
        super(fs);
    
Methods Summary
private TLVgetApp(byte[] aid)
Seeks record in the DIR file according to the pointed AID

param
aid byte[] required AID
return
TLV containing the required record
throws
TLVException if TLV error occurs

        TLV root = (TLV) DIR.firstElement();
        if (root.type != APP_CONSTRUCTED_1) {
            throw new TLVException("The first tag shall be APPLICATION 1");
        }
        while (root != null) {
            TLV t = root.child;  /* APP_PRIMITIVE_15 */
            if (t.type != APP_PRIMITIVE_15) {
                throw new TLVException(
                        "The first tag shall be APPLICATION 15 (AID)");
            }
            if (Utils.byteMatch(aid, t.getValue())) {
                return root;
            }
            root = root.next;
        }
        return null;
    
public voidload()
Reads DIR .

throws
IOException if I/O error occurs
throws
TLVException if TLV error occurs

        DIR = new Vector();
        resetLoader(DIR, null, null);
        parseDF(DIR_FILE);
    
public intsetPKCSRoot()
Sets a root for the PKCS15 application

return
int Status code.

        return setRoot(PKCS_AID);
    
public intsetRoot(byte[] aid)
Sets a root for the application with the pointed AID

param
aid byte[] required AID
return
int Status code.

        TLV root;
        try {
            root = getApp(aid);
        } catch (TLVException e) {
            return WRONG_DIR_FILE;
        }
        if (root == null) {
            return AID_NOT_FOUND;
        }
        TLV t = root.child;   /* AID */
        /* Find the path item */
        while ((t != null) && (t.type != APP_PRIMITIVE_17)) {
            t = t.next;
        }
        if (t == null) {
            return WRONG_DIR_FILE;
        }
        byte[] pth = t.getValue();
        short[] path = new short[pth.length / 2];
        for (int i = 0; i < pth.length; i = i+2) {
            path[i/2] = Utils.getShort(pth, i);
        }
        try {
            files.selectRoot(path);
        }  catch (IOException ie) {
            return ROOT_NOT_SELECTED;
        }
        return SUCCESS;