Package org.bouncycastle.sasn1

Examples of org.bouncycastle.sasn1.Asn1Set


  }
  if (value == null) {
      value = new ASN1Null();
  }
  type_ = oid;
  values_ = new ASN1Set(1);

  values_.add(value);

  add(oid);
  add(values_);
View Full Code Here


  type_ = value.getOID();

  if (type_ == null) {
      throw new NullPointerException("Value does not provide an OID!");
  }
  values_ = new ASN1Set(1);
  values_.add(value);

  add(type_);
  add(values_);
    }
View Full Code Here

  add(algorithm_);

  encodedKey_ = new ASN1OctetString(key);
  add(encodedKey_);

  attributes_ = new ASN1Set();
  add(new ASN1TaggedType(0, attributes_, false, true));
    }
View Full Code Here

      throw new InconsistentStateException("Caught ASN1Exception!");
  }
  encodedKey_ = new ASN1OctetString(code);
  add(encodedKey_);

  attributes_ = new ASN1Set();
  add(new ASN1TaggedType(0, attributes_, false, true));
    }
View Full Code Here

  ASN1ObjectIdentifier oid;
  RFC2253Parser p;
  ASN1Sequence seq;
  Iterator i;
  ASN1Set set;
  String key;
  String val;
  AVA entry;

  initMaps();

  if (encType == -1) {
      if (!allowDefaultEncoding_) {
    throw new BadNameException(
      "Use the other constructor with the explicit "
        + "encoding parameter!");
      }
      currentEncoding_ = defaultEncoding_;
  } else {
      if (encType != UTF8_ENCODING && encType != T61_ENCODING
        && encType != PRINTABLE_ENCODING && encType != IA5_ENCODING) {
    throw new BadNameException("Unknown EncodingType: " + encType);
      }
      currentEncoding_ = encType;
  }

  p = new RFC2253Parser();
  set = new ASN1Set(1);

  for (i = p.parse(rfc2253String).iterator(); i.hasNext();) {
      entry = (AVA) i.next();
      key = entry.getKey();
      key = key.toUpperCase();
      oid = (ASN1ObjectIdentifier) a2oid_.get(key);
      seq = new ASN1Sequence(2);

      if (oid == null) {
    try {
        oid = new ASN1ObjectIdentifier(key);
    } catch (Exception e) {
        throw new BadNameException("Unsupported attribute key: \""
          + key + "\"");
    }
      }
      seq.add(oid.clone());

      if (entry.isEncodedValue()) {
    ByteArrayInputStream in;
    BERDecoder dec;
    ASN1Type obj;
    byte[] buf;

    try {
        buf = entry.getEncodedValue();
        in = new ByteArrayInputStream(buf);
        dec = new BERDecoder(in);
        obj = dec.readType();

        dec.close();
    } catch (Exception e) {
        throw new BadNameException(
          "Binary data is not a valid BER encoding!");
    }
    seq.add(obj);
      } else {
    val = entry.getValue();

    /*
     * This is a workaround for email addresses which contain the
     * '@' symbol. This symbol is not in the character set of the
     * ASN.1 PrintableString. Hence, we have to take a IA5String
     * instead.
     */
    if (entry.getKey().equalsIgnoreCase("EMAILADDRESS")
      || entry.getKey().equalsIgnoreCase("UID")) {
        seq.add(new ASN1IA5String(val));
    } else if (entry.getKey().equalsIgnoreCase("C")
      || entry.getKey().equalsIgnoreCase("SERIALNUMBER")) {
        seq.add(new ASN1PrintableString(val));
    } else {
        switch (currentEncoding_) {
        case (ASN1.TAG_UTF8STRING):
      seq.add(new ASN1UTF8String(val));
      break;
        case (ASN1.TAG_IA5STRING):
      seq.add(new ASN1IA5String(val));
      break;
        case (ASN1.TAG_PRINTABLESTRING):
      if (checkPrintableSpelling(val)) {
          seq.add(new ASN1PrintableString(val));
      } else {
          throw new BadNameException(
            "Illegal characters for PrintableString "
              + "in characters");
      }
      break;
        case (ASN1.TAG_T61STRING):
      seq.add(new ASN1T61String(val));
      break;
        }
    }
      }
      set.add(seq);

      if (entry.hasSibling()) {
    continue;
      }
      set.trimToSize();

      super.add(0, set);
      set = new ASN1Set(1);
  }
  trimToSize();
    }
View Full Code Here

  ASN1Sequence ava;
  ArrayList list;
  ASN1Type obj;
  Iterator i;
  boolean sibling;
  ASN1Set rdn;
  String val;
  String key;
  AVA entry;
  int j;
  int n;

  list = new ArrayList(size());

  for (i = iterator(); i.hasNext();) {
      rdn = (ASN1Set) i.next();
      n = rdn.size();

      for (j = 0; j < n; j++) {
    /*
     * We have to mark siblings. An AVA has a sibling if it is not
     * the last AVA in the set.
     */
    sibling = (j < n - 1);

    /*
     * Convert key and value into strings. These values are then put
     * into an AVA instance.
     */
    ava = (ASN1Sequence) rdn.get(j);
    oid = (ASN1ObjectIdentifier) ava.get(0);
    obj = (ASN1Type) ava.get(1);
    key = (String) oid2a_.get(oid);

    if (key == null) {
View Full Code Here

  ASN1ObjectIdentifier oid;
  ASN1Sequence ava;
  ArrayList list;
  ASN1Type obj;
  boolean sibling;
  ASN1Set rdn;
  String val;
  String key;
  AVA entry;
  int i;
  int j;
  int n;

  list = new ArrayList(size());

  for (i = size() - 1; i >= 0; i--) {
      rdn = (ASN1Set) get(i);
      n = rdn.size();

      for (j = 0; j < n; j++) {
    /*
     * We have to mark siblings. An AVA has a sibling if it is not
     * the last AVA in the set.
     */
    sibling = (j < n - 1);

    /*
     * Convert key and value into strings. These values are then put
     * into an AVA instance.
     */
    ava = (ASN1Sequence) rdn.get(j);
    oid = (ASN1ObjectIdentifier) ava.get(0);
    obj = (ASN1Type) ava.get(1);
    key = (String) oid2a_.get(oid);

    if (key == null) {
View Full Code Here

     */
    public boolean add(ASN1Set o) {
  ASN1Sequence seq;
  Iterator it;
  // Iterator j;
  ASN1Set set;
  Object p;

  if (o == null) {
      throw new NullPointerException("parameter is null");
  }
  set = o;

  for (it = set.iterator(); it.hasNext();) {
      p = it.next();

      if (!(p instanceof ASN1Sequence)) {
    throw new IllegalArgumentException("not a sequence: "
      + p.getClass().getName());
View Full Code Here

  if (isOptional()) {
      super.encode(enc);
      return;
  }
  if (cache_ == null) {
      cache_ = new ASN1Set(size());
  }
  /*
   * Copy all relevant parameters into the cache instance, e.g. whether we
   * are tagged EXPLICT, are OPTIONAL etc.
   */
 
View Full Code Here

        } catch(CertificateEncodingException e) {
            log.warn(e.toString()+" while retrieving subject from certificate to create CSR.  Using subjectDN instead.");
            subject = new X509Name(cert.getSubjectDN().toString());
        }
        PublicKey publicKey = cert.getPublicKey();
        ASN1Set attributes = null;

        PKCS10CertificationRequest csr = new PKCS10CertificationRequest(sigalg,
                subject, publicKey, attributes, signingKey);

        if (!csr.verify()) {
View Full Code Here

TOP

Related Classes of org.bouncycastle.sasn1.Asn1Set

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.