コード例 #1
0
ファイル: SignerInfo.java プロジェクト: smsj1010/testproject3
  public SignerInfo(ASN1Sequence seq) {
    Enumeration e = seq.getObjects();

    version = (DERInteger) e.nextElement();
    issuerAndSerialNumber = IssuerAndSerialNumber.getInstance(e.nextElement());
    digAlgorithm = AlgorithmIdentifier.getInstance(e.nextElement());

    Object obj = e.nextElement();

    if (obj instanceof ASN1TaggedObject) {
      authenticatedAttributes = ASN1Set.getInstance((ASN1TaggedObject) obj, false);

      digEncryptionAlgorithm = AlgorithmIdentifier.getInstance(e.nextElement());
    } else {
      authenticatedAttributes = null;
      digEncryptionAlgorithm = AlgorithmIdentifier.getInstance(obj);
    }

    encryptedDigest = DEROctetString.getInstance(e.nextElement());

    if (e.hasMoreElements()) {
      unauthenticatedAttributes = ASN1Set.getInstance((ASN1TaggedObject) e.nextElement(), false);
    } else {
      unauthenticatedAttributes = null;
    }
  }
コード例 #2
0
  public SignedData(ASN1Sequence seq) {
    Enumeration e = seq.getObjects();

    version = (ASN1Integer) e.nextElement();
    digestAlgorithms = ((ASN1Set) e.nextElement());
    contentInfo = ContentInfo.getInstance(e.nextElement());

    while (e.hasMoreElements()) {
      ASN1Primitive o = (ASN1Primitive) e.nextElement();

      //
      // an interesting feature of SignedData is that there appear to be varying implementations...
      // for the moment we ignore anything which doesn't fit.
      //
      if (o instanceof DERTaggedObject) {
        DERTaggedObject tagged = (DERTaggedObject) o;

        switch (tagged.getTagNo()) {
          case 0:
            certificates = ASN1Set.getInstance(tagged, false);
            break;
          case 1:
            crls = ASN1Set.getInstance(tagged, false);
            break;
          default:
            throw new IllegalArgumentException("unknown tag value " + tagged.getTagNo());
        }
      } else {
        signerInfos = (ASN1Set) o;
      }
    }
  }
コード例 #3
0
  protected static final Set getQualifierSet(ASN1Sequence qualifiers)
      throws CertPathValidatorException {
    Set pq = new HashSet();

    if (qualifiers == null) {
      return pq;
    }

    ByteArrayOutputStream bOut = new ByteArrayOutputStream();
    ASN1OutputStream aOut = new ASN1OutputStream(bOut);

    Enumeration e = qualifiers.getObjects();

    while (e.hasMoreElements()) {
      try {
        aOut.writeObject((ASN1Encodable) e.nextElement());

        pq.add(new PolicyQualifierInfo(bOut.toByteArray()));
      } catch (IOException ex) {
        throw new ExtCertPathValidatorException("Policy qualifier info cannot be decoded.", ex);
      }

      bOut.reset();
    }

    return pq;
  }
コード例 #4
0
ファイル: X509Name.java プロジェクト: smsj1010/testproject3
  /**
   * Constructor from ASN1Sequence
   *
   * <p>the principal will be a list of constructed sets, each containing an (OID, String) pair.
   */
  public X509Name(ASN1Sequence seq) {
    this.seq = seq;

    Enumeration e = seq.getObjects();

    while (e.hasMoreElements()) {
      ASN1Set set = ASN1Set.getInstance(e.nextElement());

      for (int i = 0; i < set.size(); i++) {
        ASN1Sequence s = ASN1Sequence.getInstance(set.getObjectAt(i));

        if (s.size() != 2) {
          throw new IllegalArgumentException("badly sized pair");
        }

        ordering.addElement(DERObjectIdentifier.getInstance(s.getObjectAt(0)));

        DEREncodable value = s.getObjectAt(1);
        if (value instanceof DERString) {
          values.addElement(((DERString) value).getString());
        } else {
          values.addElement("#" + bytesToString(Hex.encode(value.getDERObject().getDEREncoded())));
        }
        added.addElement((i != 0) ? TRUE : FALSE); // to allow earlier JDK compatibility
      }
    }
  }
コード例 #5
0
 /**
  * Returns the targets in this target information extension.
  *
  * @return Returns the targets.
  */
 public Targets[] getTargetsObjects() {
   Targets[] copy = new Targets[targets.size()];
   int count = 0;
   for (Enumeration e = targets.getObjects(); e.hasMoreElements(); ) {
     copy[count++] = Targets.getInstance(e.nextElement());
   }
   return copy;
 }
コード例 #6
0
  public ContentInfo(ASN1Sequence seq) {
    Enumeration e = seq.getObjects();

    contentType = (DERObjectIdentifier) e.nextElement();

    if (e.hasMoreElements()) {
      content = ((ASN1TaggedObject) e.nextElement()).getObject();
    }
  }
コード例 #7
0
 private MonetaryValue(ASN1Sequence seq) {
   Enumeration e = seq.getObjects();
   // currency
   currency = Iso4217CurrencyCode.getInstance(e.nextElement());
   // hashAlgorithm
   amount = ASN1Integer.getInstance(e.nextElement());
   // exponent
   exponent = ASN1Integer.getInstance(e.nextElement());
 }
コード例 #8
0
ファイル: X509Name.java プロジェクト: smsj1010/testproject3
  public int hashCode() {
    ASN1Sequence seq = (ASN1Sequence) this.getDERObject();
    Enumeration e = seq.getObjects();
    int hashCode = 0;

    while (e.hasMoreElements()) {
      hashCode ^= e.nextElement().hashCode();
    }

    return hashCode;
  }
コード例 #9
0
ファイル: PBES2Parameters.java プロジェクト: hakeemsm/XobotOS
  public PBES2Parameters(ASN1Sequence obj) {
    Enumeration e = obj.getObjects();
    ASN1Sequence funcSeq =
        ASN1Sequence.getInstance(((DEREncodable) e.nextElement()).getDERObject());

    if (funcSeq.getObjectAt(0).equals(id_PBKDF2)) {
      func = new KeyDerivationFunc(id_PBKDF2, PBKDF2Params.getInstance(funcSeq.getObjectAt(1)));
    } else {
      func = new KeyDerivationFunc(funcSeq);
    }

    scheme = (EncryptionScheme) EncryptionScheme.getInstance(e.nextElement());
  }
コード例 #10
0
ファイル: ErrorMsgContent.java プロジェクト: XShandow/bc-java
  private ErrorMsgContent(ASN1Sequence seq) {
    Enumeration en = seq.getObjects();

    pkiStatusInfo = PKIStatusInfo.getInstance(en.nextElement());

    while (en.hasMoreElements()) {
      Object o = en.nextElement();

      if (o instanceof ASN1Integer) {
        errorCode = ASN1Integer.getInstance(o);
      } else {
        errorDetails = PKIFreeText.getInstance(o);
      }
    }
  }
コード例 #11
0
  protected static void prepareNextCertB1(
      int i, List[] policyNodes, String id_p, Map m_idp, X509Certificate cert)
      throws AnnotatedException, CertPathValidatorException {
    boolean idp_found = false;
    Iterator nodes_i = policyNodes[i].iterator();
    while (nodes_i.hasNext()) {
      PKIXPolicyNode node = (PKIXPolicyNode) nodes_i.next();
      if (node.getValidPolicy().equals(id_p)) {
        idp_found = true;
        node.expectedPolicies = (Set) m_idp.get(id_p);
        break;
      }
    }

    if (!idp_found) {
      nodes_i = policyNodes[i].iterator();
      while (nodes_i.hasNext()) {
        PKIXPolicyNode node = (PKIXPolicyNode) nodes_i.next();
        if (ANY_POLICY.equals(node.getValidPolicy())) {
          Set pq = null;
          ASN1Sequence policies = (ASN1Sequence) getExtensionValue(cert, CERTIFICATE_POLICIES);
          Enumeration e = policies.getObjects();
          while (e.hasMoreElements()) {
            PolicyInformation pinfo = PolicyInformation.getInstance(e.nextElement());
            if (ANY_POLICY.equals(pinfo.getPolicyIdentifier().getId())) {
              pq = getQualifierSet(pinfo.getPolicyQualifiers());
              break;
            }
          }
          boolean ci = false;
          if (cert.getCriticalExtensionOIDs() != null) {
            ci = cert.getCriticalExtensionOIDs().contains(CERTIFICATE_POLICIES);
          }

          PKIXPolicyNode p_node = (PKIXPolicyNode) node.getParent();
          if (ANY_POLICY.equals(p_node.getValidPolicy())) {
            PKIXPolicyNode c_node =
                new PKIXPolicyNode(new ArrayList(), i, (Set) m_idp.get(id_p), p_node, pq, id_p, ci);
            p_node.addChild(c_node);
            policyNodes[i].add(c_node);
          }
          break;
        }
      }
    }
  }
コード例 #12
0
ファイル: PKIHeader.java プロジェクト: SreejitS/isaacyang1988
  private PKIHeader(ASN1Sequence seq) {
    Enumeration en = seq.getObjects();

    pvno = DERInteger.getInstance(en.nextElement());
    sender = GeneralName.getInstance(en.nextElement());
    recipient = GeneralName.getInstance(en.nextElement());

    while (en.hasMoreElements()) {
      ASN1TaggedObject tObj = (ASN1TaggedObject) en.nextElement();

      switch (tObj.getTagNo()) {
        case 0:
          messageTime = DERGeneralizedTime.getInstance(tObj, true);
          break;
        case 1:
          protectionAlg = AlgorithmIdentifier.getInstance(tObj, true);
          break;
        case 2:
          senderKID = ASN1OctetString.getInstance(tObj, true);
          break;
        case 3:
          recipKID = ASN1OctetString.getInstance(tObj, true);
          break;
        case 4:
          transactionID = ASN1OctetString.getInstance(tObj, true);
          break;
        case 5:
          senderNonce = ASN1OctetString.getInstance(tObj, true);
          break;
        case 6:
          recipNonce = ASN1OctetString.getInstance(tObj, true);
          break;
        case 7:
          freeText = PKIFreeText.getInstance(tObj, true);
          break;
        case 8:
          generalInfo = ASN1Sequence.getInstance(tObj, true);
          break;
        default:
          throw new IllegalArgumentException("unknown tag number: " + tObj.getTagNo());
      }
    }
  }
コード例 #13
0
ファイル: OOBCertHash.java プロジェクト: zxlooong/ejbca4
  public OOBCertHash(ASN1Sequence seq) {
    Enumeration e = seq.getObjects();

    while (e.hasMoreElements()) {
      Object obj = e.nextElement();

      if (obj instanceof ASN1TaggedObject) {
        ASN1TaggedObject tagObj = (ASN1TaggedObject) obj;

        switch (tagObj.getTagNo()) {
          case 0:
            hashAlg = AlgorithmIdentifier.getInstance(tagObj.getObject());
            break;
          case 1:
            certId = CertId.getInstance(tagObj.getObject());
            break;
        }
      } else {
        hashVal = DERBitString.getInstance(obj);

        break;
      }
    }
  }
コード例 #14
0
  public SemanticsInformation(ASN1Sequence seq) {
    Enumeration e = seq.getObjects();
    if (seq.size() < 1) {
      throw new IllegalArgumentException("no objects in SemanticsInformation");
    }

    Object object = e.nextElement();
    if (object instanceof DERObjectIdentifier) {
      semanticsIdentifier = DERObjectIdentifier.getInstance(object);
      if (e.hasMoreElements()) {
        object = e.nextElement();
      } else {
        object = null;
      }
    }

    if (object != null) {
      ASN1Sequence generalNameSeq = ASN1Sequence.getInstance(object);
      nameRegistrationAuthorities = new GeneralName[generalNameSeq.size()];
      for (int i = 0; i < generalNameSeq.size(); i++) {
        nameRegistrationAuthorities[i] = GeneralName.getInstance(generalNameSeq.getObjectAt(i));
      }
    }
  }