コード例 #1
0
ファイル: ACEntry.java プロジェクト: schoeberl/yari
  /**
   * Reads PIN information from file and adds a new object into vector.
   *
   * @param r reader for permissions file.
   * @param dest destination vector.
   * @throws IOException if I/O error occurs.
   */
  private static void readAPDUPIN(ACLFileReader r, Vector dest) throws IOException {

    r.checkWord("{");
    r.checkWord("id");
    int id = r.readByte();
    Integer[] commands = new Integer[ACLPermissions.CMD_COUNT];

    while (true) {

      String s = r.readWord();

      if (s.equals("}")) {
        break;
      }

      int index = getPINCommandIndex(s);

      int command = 0;
      for (int i = 0; i < 4; i++) {
        command = (command << 8) | r.readByte();
      }
      commands[index] = new Integer(command);
    }
    dest.addElement(new PINData(id, commands));
  }
コード例 #2
0
ファイル: ACEntry.java プロジェクト: schoeberl/yari
  /**
   * Reads PIN information from file and adds a new object into vector.
   *
   * @param r reader for permissions file.
   * @param dest destination vector.
   * @throws IOException if I/O error occurs.
   */
  private static void readJCRMIPIN(ACLFileReader r, Vector dest) throws IOException {

    r.checkWord("{");
    r.checkWord("id");
    int id = r.readByte();
    String[] commands = new String[ACLPermissions.CMD_COUNT];

    while (true) {

      String s = r.readWord();
      if (s.equals("}")) {
        break;
      }
      commands[getPINCommandIndex(s)] = r.readWord();
    }
    dest.addElement(new PINData(id, commands));
  }
コード例 #3
0
ファイル: ACEntry.java プロジェクト: schoeberl/yari
  /**
   * Reads JCRMI permission from file and places it into the vector.
   *
   * @param r reader for permissions file.
   * @param t_jcrmi vector for JCRMI permissions.
   * @throws IOException if I/O error occurs.
   */
  private static void readJCRMIPermission(ACLFileReader r, Vector t_jcrmi) throws IOException {

    Vector classes = new Vector();
    Vector methods = new Vector();
    String hashModifier = null;

    r.checkWord("{");

    while (true) {

      String s = r.readWord();

      if (s.equals("}")) {
        break;
      }

      if (s.equals("classes")) {
        r.checkWord("{");
        s = r.readWord();
        while (!s.equals("}")) {
          classes.addElement(s);
          s = r.readWord();
        }
      } else if (s.equals("hashModifier")) {
        hashModifier = r.readWord();
      } else if (s.equals("methods")) {
        r.checkWord("{");
        s = r.readWord();
        while (!s.equals("}")) {
          methods.addElement(s);
          s = r.readWord();
        }
      } else {
        throw new IOException();
      }
    }

    t_jcrmi.addElement(new JCRMIPermission(hashModifier, classes, methods));
  }
コード例 #4
0
ファイル: ACEntry.java プロジェクト: schoeberl/yari
  /**
   * Reads APDU permission from file and places it into the vector.
   *
   * @param r reader for permissions file.
   * @param t_apdu vector for APDU permissions.
   * @throws IOException if I/O error occurs.
   */
  private static void readAPDUPermission(ACLFileReader r, Vector t_apdu) throws IOException {

    r.checkWord("{");

    String s = r.readWord();

    while (true) {

      if (s.equals("}")) {
        break;
      }

      byte[] data = new byte[8];

      for (int i = 0; i < 8; i++) {
        data[i] = (byte) Short.parseShort(s, 16);
        s = r.readWord();
      }
      t_apdu.addElement(data);
    }
  }
コード例 #5
0
ファイル: ACEntry.java プロジェクト: schoeberl/yari
  /**
   * Constructs ACE.
   *
   * @param r reader for permissions file.
   * @param pin_info vector for PIN information.
   * @throws IOException if I/O error occurs.
   */
  ACEntry(ACLFileReader r, Vector pin_info) throws IOException {

    Vector t_roots = new Vector();
    Vector t_apdu = new Vector();
    Vector t_jcrmi = new Vector();

    r.checkWord("{");

    while (true) {

      String s = r.readWord();

      if (s.equals("}")) {
        break;
      }

      if (s.equals("root")) {
        t_roots.addElement(r.readLine());
        continue;
      }

      if (s.equals("apdu")) {
        readAPDUPermission(r, t_apdu);
        continue;
      }

      if (s.equals("jcrmi")) {
        readJCRMIPermission(r, t_jcrmi);
        continue;
      }

      if (s.equals("pin_apdu")) {
        readAPDUPIN(r, pin_info);
        continue;
      }

      if (s.equals("pin_jcrmi")) {
        readJCRMIPIN(r, pin_info);
        continue;
      }

      throw new IOException();
    }

    if (!t_roots.isEmpty()) {
      roots = new String[t_roots.size()];
      for (int i = 0; i < t_roots.size(); i++) {
        roots[i] = (String) t_roots.elementAt(i);
      }
    }

    if (!t_apdu.isEmpty()) {
      APDUPermissions = new int[t_apdu.size() * 2];
      for (int i = 0; i < t_apdu.size(); i++) {
        byte[] data = (byte[]) t_apdu.elementAt(i);
        APDUPermissions[i * 2] = Utils.getInt(data, 0);
        APDUPermissions[i * 2 + 1] = Utils.getInt(data, 4);
      }
    }

    if (!t_jcrmi.isEmpty()) {
      JCRMIPermissions = new JCRMIPermission[t_jcrmi.size()];
      t_jcrmi.copyInto(JCRMIPermissions);
    }
  }