示例#1
0
  public static KeyBundle findKeyBundle(ExtendedKeyStore ring, String principal) throws Exception {

    for (Enumeration e = ring.aliases(); e.hasMoreElements(); ) {
      String aliasId = (String) e.nextElement();
      KeyBundle bundle = ring.getKeyBundle(aliasId);
      if (bundle != null) {
        for (Iterator users = bundle.getPrincipals(); users.hasNext(); ) {
          Principal princ = (Principal) users.next();
          System.out.println("aliasId:" + aliasId + ", user:"******"KeyBundle not found for " + principal);
  }
示例#2
0
  private void readPublicKeyRing() throws Exception {
    logger.debug(System.getProperties().get("user.dir"));
    InputStream in = IOUtils.getResourceAsStream(publicKeyRingFileName, getClass());

    ExtendedKeyStore ring = (ExtendedKeyStore) ExtendedKeyStore.getInstance("OpenPGP/KeyRing");
    ring.load(in, null);
    in.close();

    for (Enumeration e = ring.aliases(); e.hasMoreElements(); ) {
      String aliasId = (String) e.nextElement();

      KeyBundle bundle = ring.getKeyBundle(aliasId);

      if (bundle != null) {
        for (Iterator users = bundle.getPrincipals(); users.hasNext(); ) {
          Principal princ = (Principal) users.next();

          principalsKeyBundleMap.put(princ.getName(), bundle);
        }
      }
    }
  }