public VomsAttributeCertificateInfo(final ASN1Sequence seq) throws ProblemException {

    super(seq);

    ASN1Sequence attributes = getAttributes();

    for (int i = 0; i < attributes.size(); i++) {

      ASN1Sequence attribute = (ASN1Sequence) attributes.getObjectAt(i);
      DERObjectIdentifier id = (DERObjectIdentifier) attribute.getObjectAt(0);

      if (VomsCredentialInfo.VOMS_ATTR_OID.equals(id.getId())) {

        DERSet set = (DERSet) attribute.getObjectAt(1);

        for (int j = 0; j < set.size(); j++) {

          IetfAttrSyntax attr = new IetfAttrSyntax((ASN1Sequence) set.getObjectAt(j));
          ASN1Sequence paSeq = (ASN1Sequence) attr.getPolicyAuthority().getDERObject();
          GeneralName paGName = GeneralName.getInstance(paSeq.getObjectAt(0));
          String paString = ((DERIA5String) paGName.getName()).getString();

          int sep = paString.indexOf("://"); // $NON-NLS-1$
          if (sep != -1) {
            this.voNames.add(paString.substring(0, sep));
          }

          for (Object attrValue : attr.getValues()) {
            String fqanString = new String(((ASN1OctetString) attrValue).getOctets());
            this.fqans.add(FullyQualifiedAttributeName.getFqan(fqanString));
          }
        }
      }
    }
  }
Example #2
0
  private SinglePubInfo(ASN1Sequence seq) {
    pubMethod = ASN1Integer.getInstance(seq.getObjectAt(0));

    if (seq.size() == 2) {
      pubLocation = GeneralName.getInstance(seq.getObjectAt(1));
    }
  }
  /**
   * Returns a List of URL for Certificate Revocation List. Must have on or more<br>
   * Otherwise, returns <b>null</b>.<br>
   *
   * @return String
   * @throws IOException
   */
  public List<String> getCRLDistributionPoint() throws IOException {

    List<String> lcrS = new ArrayList<String>();
    // DERObject derObj =
    // getExtensionValue(X509Extensions.CRLDistributionPoints.getId());
    ASN1Object derObj = getExtensionValue(X509Extensions.CRLDistributionPoints.getId());
    if (derObj == null) {
      return null;
    }
    CRLDistPoint crlDistPoint = CRLDistPoint.getInstance(derObj);
    DistributionPoint[] dp = crlDistPoint.getDistributionPoints();
    for (int i = 0; i < dp.length; i++) {
      // @SuppressWarnings("resource")
      DERSequence seq = (DERSequence) dp[i].getDistributionPoint().getName().toASN1Primitive();
      GeneralName url = (GeneralName) seq.getObjectAt(0);
      lcrS.add(url.getName().toString());
    }
    return lcrS;
  }
Example #4
0
  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());
      }
    }
  }
  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));
      }
    }
  }