Package org.bouncycastle.asn1

Examples of org.bouncycastle.asn1.DEREncodable


    props.put("id1.property.value", "DBE81232");
   
    BasicCertificateExtension baseExt = new BasicCertificateExtension();
    baseExt.init(1, "1.2.3", false, props);
   
    DEREncodable value = baseExt.getValue(null, null, null, null, null);
    assertTrue(value.getClass().toString(),value instanceof DEROctetString);
    assertTrue(((DEROctetString)value).toString(),((DEROctetString)value).toString().equalsIgnoreCase("#DBE81232"));
   
    props = new Properties();
    props.put("id1.property.encoding", "DEROCTETSTRING");
    props.put("id1.property.value", "123SA4");
View Full Code Here


    props.put("id1.property.value", "This is a printable string");
   
    BasicCertificateExtension baseExt = new BasicCertificateExtension();
    baseExt.init(1, "1.2.3", false, props);
   
    DEREncodable value = baseExt.getValue(null, null, null, null, null);
    assertTrue(value.getClass().toString(),value instanceof DERPrintableString);
    assertTrue(((DERPrintableString)value).toString(),((DERPrintableString)value).toString().equals("This is a printable string"));
   
    props = new Properties();
    props.put("id1.property.encoding", "DERPRINTABLESTRING");
    props.put("id1.property.value", "This is a non  printable string ���");
View Full Code Here

    boolean found = false;
    for (int i = 0; i < gns.length; i++) {
      int tag = gns[i].getTagNo();
      if (tag == 4) {
        found = true;
        DEREncodable enc = gns[i].getName();
        X509Name dir = (X509Name) enc;
        String str = dir.toString();
        log.debug("DirectoryName: " + str);
        assertEquals("CN=testDirName,O=Foo,OU=Bar,C=SE", str);
      }

    }
    assertTrue(found);

    altName = "rfc822name=foo@bar.se, rfc822name=foo@bar.com, uri=http://foo.bar.se, directoryName="
        + LDAPDN.escapeRDN("CN=testDirName, O=Foo, OU=Bar, C=SE")
        + ", dnsName=foo.bar.se, dnsName=foo.bar.com";
    san = CertTools.getGeneralNamesFromAltName(altName);
    gns = san.getNames();
    int dnscount = 0;
    int rfc822count = 0;
    for (int i = 0; i < gns.length; i++) {
      int tag = gns[i].getTagNo();
      if (tag == 2) {
        dnscount++;
        DEREncodable enc = gns[i].getName();
        DERIA5String dir = (DERIA5String) enc;
        String str = dir.getString();
        log.info("DnsName: " + str);
      }
      if (tag == 1) {
        rfc822count++;
        DEREncodable enc = gns[i].getName();
        DERIA5String dir = (DERIA5String) enc;
        String str = dir.getString();
        log.info("Rfc822Name: " + str);
      }
View Full Code Here

        }
        if (attributes == null) {
            return null;
        }       
        Attribute attr = attributes.get(PKCSObjectIdentifiers.pkcs_9_at_challengePassword);
        DEREncodable obj = null;
        if (attr == null) {
            // See if we have it embedded in an extension request instead
            attr = attributes.get(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest);
            if (attr == null) {
                return null;               
View Full Code Here

            // Get self signed cert to identify the senders public key
            ASN1Set certs = sd.getCertificates();
            if (certs.size() > 0) {
                // There should be only one...
                DEREncodable dercert = certs.getObjectAt(0);
                if (dercert != null) {
                    // Requestors self-signed certificate is requestKeyInfo
                    ByteArrayOutputStream bOut = new ByteArrayOutputStream();
                    DEROutputStream dOut = new DEROutputStream(bOut);
                    dOut.writeObject(dercert);
View Full Code Here

        return retval;
    }

  private DEREncodable parseDERInteger(String value) throws CertificateExtentionConfigurationException {
    DEREncodable retval = null;
    try{
      BigInteger intValue = new BigInteger(value,10);
      retval = new DERInteger(intValue);
    }catch(NumberFormatException e){
      throw new CertificateExtentionConfigurationException(intres.getLocalizedMessage("certext.basic.illegalvalue",value,Integer.valueOf(getId())));
View Full Code Here

    return retval;
  }
 
  private DEREncodable parseDEROctetString(String value) throws CertificateExtentionConfigurationException {
    DEREncodable retval = null;
    if(value.matches("^\\p{XDigit}*")){     
      byte[] bytes = Hex.decode(value);
      retval = new DEROctetString(bytes);
    }else{   
      throw new CertificateExtentionConfigurationException(intres.getLocalizedMessage("certext.basic.illegalvalue",value,Integer.valueOf(getId())));
View Full Code Here

  /**
   * Tries to read the hex-string as an DERObject. If it contains more than one DEREncodable object, return a DERSequence of the objects.
   */
  private DEREncodable parseHexEncodedDERObject(String value) throws CertificateExtentionConfigurationException {
    DEREncodable retval = null;
    if(value.matches("^\\p{XDigit}*")){     
      byte[] bytes = Hex.decode(value);
      try {
        ASN1InputStream ais = new ASN1InputStream(bytes);
        DEREncodable firstObject = ais.readObject();
        if (ais.available() > 0) {
          ASN1EncodableVector ev = new ASN1EncodableVector();
          ev.add(firstObject);
          while (ais.available() > 0) {
            ev.add(ais.readObject());
View Full Code Here

    }
    return retval;
  }

  private DEREncodable parseDERBoolean(String value) throws CertificateExtentionConfigurationException {
    DEREncodable retval = null;
    if(value.equalsIgnoreCase("TRUE")){
      retval = DERBoolean.TRUE;
    }
   
    if(value.equalsIgnoreCase("FALSE")){
View Full Code Here

      int i = 0;
      do {
        av = getReq().getRegInfo(i);
        if (av != null) {
          if (StringUtils.equals(CRMFObjectIdentifiers.regCtrl_regToken.getId(), av.getObjectId().getId())) {
            final DEREncodable enc = av.getParameters();
            final DERUTF8String str = DERUTF8String.getInstance(enc);
            ret = str.getString();
            if (log.isDebugEnabled()) {
              log.debug("Found a request password in CRMF request regCtrl_regToken");
            }
          }
        }
        i++;
      } while ( (av != null) && (ret == null) );
    }   
    if (ret == null) {
      // If there is "Registration Token Control" in the CertRequest controls containing a password, we can use that
      // Note, this is the correct way to use the regToken according to RFC4211, section "6.1.  Registration Token Control"
      AttributeTypeAndValue av = null;
      int i = 0;
      do {
        av = getReq().getCertReq().getControls(i);
        if (av != null) {
          if (StringUtils.equals(CRMFObjectIdentifiers.regCtrl_regToken.getId(), av.getObjectId().getId())) {
            final DEREncodable enc = av.getParameters();
            final DERUTF8String str = DERUTF8String.getInstance(enc);
            ret = str.getString();
            if (log.isDebugEnabled()) {
              log.debug("Found a request password in CRMF request regCtrl_regToken");
            }
View Full Code Here

TOP

Related Classes of org.bouncycastle.asn1.DEREncodable

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.