001: /*
002: *
003: *
004: * Copyright 1990-2007 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License version
009: * 2 only, as published by the Free Software Foundation.
010: *
011: * This program is distributed in the hope that it will be useful, but
012: * WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * General Public License version 2 for more details (a copy is
015: * included at /legal/license.txt).
016: *
017: * You should have received a copy of the GNU General Public License
018: * version 2 along with this work; if not, write to the Free Software
019: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA
021: *
022: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023: * Clara, CA 95054 or visit www.sun.com if you need additional
024: * information or have any questions.
025: */
026: package com.sun.satsa.util.pkcs15;
027:
028: import java.util.Vector;
029: import java.io.IOException;
030: import com.sun.satsa.util.*;
031:
032: /**
033: * This class represents the PKCS15 AODF file abstraction
034: */
035: public class AODF extends PKCS15File {
036: /** This vector contains parsed objects from DF(AODF). */
037: private Vector AODF;
038:
039: /** Number of thr PIN entries */
040: private int size = 0;
041: /** Array for the PIN entries */
042: private TLV[] Entries;
043:
044: /**
045: * Creates AODF object for the pointed location and file system
046: * @param location Location required location
047: * @param files FileSystemAbstract requred file system
048: */
049: public AODF(Location location, FileSystemAbstract files) {
050: super (location, files);
051: }
052:
053: /**
054: * Loads DODF object from the file system
055: * @throws IOException if I/O error occurs
056: * @throws TLVException if TLV error occurs
057: */
058: public void load() throws IOException, TLVException {
059: AODF = new Vector();
060: resetLoader(AODF, null, null);
061: parseDF(location.path);
062: readAODF();
063: }
064:
065: /**
066: * Reads AODF data from the AODF vector.
067: * @throws TLVException if TLV error occurs
068: */
069: /*
070: * It is assumed that the AODF file contains information
071: * about AUF files in the following format:
072: * AuthenticationType,
073: * ...
074: * AuthenticationType,
075: */
076: private void readAODF() throws TLVException {
077: TLV root = (TLV) AODF.firstElement(); /* SEQUENCE OF */
078: size = AODF.size();
079: Entries = new TLV[size];
080: for (int i = 0; i < size; i++) {
081: Entries[i] = (TLV) AODF.elementAt(i);
082: }
083: }
084:
085: /**
086: * Returns number of the Authentication objects
087: * @return int
088: */
089: public int getEntryCount() {
090: return size;
091: }
092:
093: /**
094: * Returns pointed authentication object
095: * @param index int index of the authentication object
096: * @return TLV required authentication object
097: */
098: public TLV getEntry(int index) {
099: return Entries[index];
100: }
101:
102: }
|