Package org.bouncycastle.asn1

Examples of org.bouncycastle.asn1.DEREncodable


      if (attributes != null) {
        log.debug("Adding attributes in the request");
        Iterator<DEREncodable> iter = attributes.iterator();
      ASN1EncodableVector vec = new ASN1EncodableVector();
        while (iter.hasNext()) {
          DEREncodable o = (DEREncodable)iter.next();
          vec.add(o);
          attrset = new DERSet(vec);
        }
      }
        X509NameEntryConverter converter = null;
View Full Code Here


          // from the request, if AllowExtensionOverride is enabled.
          // Two extensions with the same oid is not allowed in the standard.
          if (overridenexts.getExtension(new DERObjectIdentifier(oid)) == null) {
              CertificateExtension certExt = fact.getStandardCertificateExtension(oid, certProfile);
              if (certExt != null) {
                DEREncodable value = certExt.getValue(subject, this, certProfile, publicKey, caPublicKey);
                if (value != null) {
                  extgen.addExtension(new DERObjectIdentifier(certExt.getOID()),certExt.isCriticalFlag(),value);                                      
                }
              }           
          } else {
            if (log.isDebugEnabled()) {
              log.debug("Extension with oid "+oid+" has been overridden, standard extension will not be added.");
            }
          }
        }

         // Fourth, check for custom Certificate Extensions that should be added.
         // Custom certificate extensions is defined in certextensions.properties
         fact = CertificateExtensionFactory.getInstance();
         List<Integer> usedCertExt = certProfile.getUsedCertificateExtensions();
         Iterator<Integer> certExtIter = usedCertExt.iterator();
         while(certExtIter.hasNext()){
           Integer id = certExtIter.next();
           CertificateExtension certExt = fact.getCertificateExtensions(id);
           if (certExt != null) {
               // We don't want to try to add custom extensions with the same oid if we have already added them
               // from the request, if AllowExtensionOverride is enabled.
               // Two extensions with the same oid is not allowed in the standard.
             if (overridenexts.getExtension(new DERObjectIdentifier(certExt.getOID())) == null) {
               DEREncodable value = certExt.getValue(subject, this, certProfile, publicKey, caPublicKey);
               if (value != null) {
                 extgen.addExtension(new DERObjectIdentifier(certExt.getOID()),certExt.isCriticalFlag(),value);                                      
               }                
             } else {
               if (log.isDebugEnabled()) {
View Full Code Here

   * @param certProfile not used
   * @see org.ejbca.core.model.ca.certextensions.CertificateExtension#getValue(org.ejbca.core.model.ra.UserDataVO, org.ejbca.core.model.ca.caadmin.CA, org.ejbca.core.model.ca.certificateprofiles.CertificateProfile, PublicKey)
   */
  private DEREncodable parseValue(String encoding, String value) throws CertificateExtentionConfigurationException, CertificateExtensionException {

    DEREncodable toret = null;

    if(!encoding.equalsIgnoreCase(ENCODING_DERNULL) && (value == null || value.trim().equals(""))){
      throw new CertificateExtentionConfigurationException(intres.getLocalizedMessage("certext.basic.incorrectvalue", Integer.valueOf(getId())));
    }

View Full Code Here

          dEREncodable = parseValue(encoding, value);
        } else {
          ASN1EncodableVector ev = new ASN1EncodableVector();
          for (int i=1; i<=nvalues; i++) {
            value = getProperties().getProperty(PROPERTY_VALUE+Integer.toString(i));
            DEREncodable derval = parseValue(encoding, value);
            ev.add(derval);
          }
          dEREncodable = new DERSequence(ev);
        }
      }
View Full Code Here

    return dEREncodable;
  }

    private DEREncodable parseDERBitString(String value) throws CertificateExtentionConfigurationException {
    DEREncodable retval = null;
    try{
      BigInteger bigInteger = new BigInteger(value,2);     
      int padBits = value.length() - 1 - value.lastIndexOf("1");
      if(padBits == 8){
        padBits = 0;
View Full Code Here

   
    return retval;
  }
 
    private DEREncodable parseDEROID(String value) throws CertificateExtentionConfigurationException {
        DEREncodable retval = null;
        try{
            retval = new DERObjectIdentifier(value);
        }catch(Exception e){
            throw new CertificateExtentionConfigurationException(intres.getLocalizedMessage("certext.basic.illegalvalue",value,Integer.valueOf(getId())));
        }
View Full Code Here

    super.setCriticalFlag(false);
  }
 
  @Override
  public DEREncodable getValue(final UserDataVO subject, final CA ca, final CertificateProfile certProfile, final PublicKey userPublicKey, final PublicKey caPublicKey ) throws CertificateExtentionConfigurationException, CertificateExtensionException {
    DEREncodable ret = null;
    final String dirAttrString  = subject.getExtendedinformation() != null ? subject.getExtendedinformation().getSubjectDirectoryAttributes() : null;
    if (StringUtils.isNotEmpty(dirAttrString)) {
      // Subject Directory Attributes is a sequence of Attribute
      final Collection<Attribute> attr = SubjectDirAttrExtension.getSubjectDirectoryAttributes(dirAttrString);
      final ASN1EncodableVector vec = new ASN1EncodableVector();
View Full Code Here

 
  @Override
  public DEREncodable getValue(final UserDataVO userData, final CA ca, final CertificateProfile certProfile, final PublicKey userPublicKey, final PublicKey caPublicKey)
      throws CertificateExtentionConfigurationException, CertificateExtensionException {
    final String cardnumber = userData.getCardNumber();
    DEREncodable ret = null;
    if (StringUtils.isNotEmpty(cardnumber)) {
      ret = new DERPrintableString(cardnumber);
      if (log.isDebugEnabled()) {
        log.debug("Seis card numer: "+cardnumber);
      }
View Full Code Here

    {
        Enumeration e = seq.getObjects();

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

            if (obj instanceof ASN1TaggedObject)
            {
                ASN1TaggedObject tag = (ASN1TaggedObject)obj;
                if (tag.getTagNo() == tagNo)
View Full Code Here

                       throw new IllegalArgumentException("badly sized pair");
                   }

                   ordering.addElement(DERObjectIdentifier.getInstance(s.getObjectAt(0)));
                  
                   DEREncodable value = s.getObjectAt(1);
                   if (value instanceof DERString && !(value instanceof DERUniversalString))
                   {
                       String v = ((DERString)value).getString();
                       if (v.length() > 0 && v.charAt(0) == '#')
                       {
                           values.addElement("\\" + v);
                       }
                       else
                       {
                           values.addElement(v);
                       }
                   }
                   else
                   {
                       values.addElement("#" + bytesToString(Hex.encode(value.getDERObject().getDEREncoded())));
                   }
                   added.addElement((i != 0) ? TRUE : FALSE)// to allow earlier JDK compatibility
            }
        }
    }
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.