Examples of DERUTF8String


Examples of org.bouncycastle.asn1.DERUTF8String

        if ( seq != null) {                   
            // First in sequence is the object identifier, that we must check
            DERObjectIdentifier id = DERObjectIdentifier.getInstance(seq.getObjectAt(0));
            if (id.getId().equals(CertTools.UPN_OBJECTID)) {
                ASN1TaggedObject obj = (ASN1TaggedObject) seq.getObjectAt(1);
                DERUTF8String str = DERUTF8String.getInstance(obj.getObject());
                return str.getString();                       
            }
        }
        return null;
    }
View Full Code Here

Examples of org.bouncycastle.asn1.DERUTF8String

        if (!upn.isEmpty()) {           
            Iterator<String> iter = upn.iterator();            
            while (iter.hasNext()) {
                ASN1EncodableVector v = new ASN1EncodableVector();
                v.add(new DERObjectIdentifier(CertTools.UPN_OBJECTID));
                v.add(new DERTaggedObject(true, 0, new DERUTF8String((String)iter.next())));
                //GeneralName gn = new GeneralName(new DERSequence(v), 0);
                DERObject gn = new DERTaggedObject(false, 0, new DERSequence(v));
                vec.add(gn);
            }
        }
       
       
        ArrayList<String> guid =  CertTools.getPartsFromDN(altName, CertTools.GUID);
        if (!guid.isEmpty()) {           
            Iterator<String> iter = guid.iterator();               
            while (iter.hasNext()) {                   
                ASN1EncodableVector v = new ASN1EncodableVector();
                byte[] guidbytes = Hex.decode((String)iter.next());
                if (guidbytes != null) {
                    v.add(new DERObjectIdentifier(CertTools.GUID_OBJECTID));
                    v.add(new DERTaggedObject(true, 0, new DEROctetString(guidbytes)));
                    DERObject gn = new DERTaggedObject(false, 0, new DERSequence(v));
                    vec.add(gn);                   
                } else {
                    log.error("Cannot decode hexadecimal guid: "+guid);
                }
            }
        }
       
        // Krb5PrincipalName is an OtherName, see method getKrb5Principal...for ASN.1 definition
        ArrayList<String> krb5principalname =  CertTools.getPartsFromDN(altName, CertTools.KRB5PRINCIPAL);
        if (!krb5principalname.isEmpty()) {           
            Iterator<String> iter = krb5principalname.iterator();            
            while (iter.hasNext()) {
              // Start by parsing the input string to separate it in different parts
                String principalString = (String)iter.next();
                if (log.isDebugEnabled()) {
                    log.debug("principalString: "+principalString);                 
                }
                // The realm is the last part moving back until an @
                int index = principalString.lastIndexOf('@');
                String realm = "";
                if (index > 0) {
                  realm = principalString.substring(index+1);
                }
                if (log.isDebugEnabled()) {
                    log.debug("realm: "+realm);                 
                }
                // Now we can have several principals separated by /
                ArrayList<String> principalarr = new ArrayList<String>();
                int jndex = 0;
              int bindex = 0;
                while (jndex < index) {
                  // Loop and add all strings separated by /
                    jndex = principalString.indexOf('/', bindex);
                  if (jndex == -1) {
                    jndex = index;
                  }
                  String s = principalString.substring(bindex, jndex);
                  if (log.isDebugEnabled()) {
                    log.debug("adding principal name: "+s);                 
                  }                 
                  principalarr.add(s);
                  bindex = jndex+1;
                }
               
                // Now we must construct the rather complex asn.1...
                ASN1EncodableVector v = new ASN1EncodableVector(); // this is the OtherName
                v.add(new DERObjectIdentifier(CertTools.KRB5PRINCIPAL_OBJECTID));

                // First the Krb5PrincipalName sequence
                ASN1EncodableVector krb5p = new ASN1EncodableVector();
                // The realm is the first tagged GeneralString
                krb5p.add(new DERTaggedObject(true, 0, new DERGeneralString(realm)));
                // Second is the sequence of principal names, which is at tagged position 1 in the krb5p
                ASN1EncodableVector principals = new ASN1EncodableVector();
                // According to rfc4210 the type NT-UNKNOWN is 0, and according to some other rfc this type should be used...
                principals.add(new DERTaggedObject(true, 0, new DERInteger(0)));
                // The names themselves are yet another sequence
                Iterator<String> i = principalarr.iterator();
                ASN1EncodableVector names = new ASN1EncodableVector();
                while (i.hasNext()) {
                    String principalName = (String)i.next();
                    names.add(new DERGeneralString(principalName));
                }
                principals.add(new DERTaggedObject(true, 1, new DERSequence(names)));                 
                krb5p.add(new DERTaggedObject(true, 1, new DERSequence(principals)));
               
                v.add(new DERTaggedObject(true, 0, new DERSequence(krb5p)));
                DERObject gn = new DERTaggedObject(false, 0, new DERSequence(v));
                vec.add(gn);
            }
        }

      // To support custom OIDs in altNames, they must be added as an OtherName of plain type UTF8String
        ArrayList<String> customoids =  CertTools.getCustomOids(altName);
        if (!customoids.isEmpty()) {           
          Iterator<String> iter = customoids.iterator();
          while (iter.hasNext()) {
            String oid = (String)iter.next();
            ArrayList<String> oidval =  CertTools.getPartsFromDN(altName, oid);
            if (!oidval.isEmpty()) {           
              Iterator<String> valiter = oidval.iterator();
              while (valiter.hasNext()) {
                ASN1EncodableVector v = new ASN1EncodableVector();
                v.add(new DERObjectIdentifier(oid));
                v.add(new DERTaggedObject(true, 0, new DERUTF8String((String)valiter.next())));
                DERObject gn = new DERTaggedObject(false, 0, new DERSequence(v));
                vec.add(gn);
              }
            }
          }
View Full Code Here

Examples of org.bouncycastle.asn1.DERUTF8String

        myCertTemplate.setExtensions(new X509Extensions(oids, values));
        CertRequest myCertRequest = new CertRequest(new DERInteger(4), myCertTemplate);
        CertReqMsg myCertReqMsg = new CertReqMsg(myCertRequest);
        ProofOfPossession myProofOfPossession = new ProofOfPossession(new DERNull(), 0);
        myCertReqMsg.setPop(myProofOfPossession);
        AttributeTypeAndValue av = new AttributeTypeAndValue(CRMFObjectIdentifiers.regCtrl_regToken, new DERUTF8String("foo123"));
        myCertReqMsg.addRegInfo(av);
        CertReqMessages myCertReqMessages = new CertReqMessages(myCertReqMsg);
        PKIHeader myPKIHeader = new PKIHeader(new DERInteger(2), new GeneralName(new X509Name("CN=bogusSubject")), new GeneralName(new X509Name("CN=bogusIssuer")));
        myPKIHeader.setMessageTime(new DERGeneralizedTime(new Date()));
        myPKIHeader.setSenderNonce(new DEROctetString(CmpMessageHelper.createSenderNonce()));
View Full Code Here

Examples of org.bouncycastle.asn1.DERUTF8String

    PKIStatusInfo myPKIStatusInfo = new PKIStatusInfo(new DERInteger(2)); // 2 = rejection
    if (failInfo != null) {
      myPKIStatusInfo.setFailInfo(failInfo.getAsBitString());     
    }
    if (failText != null) {   
      myPKIStatusInfo.setStatusString(new PKIFreeText(new DERUTF8String(failText)));
    }
    PKIBody myPKIBody = null;
    log.debug("Create error message from requestType: "+requestType);
    if (requestType==0 || requestType==2) {
      myPKIBody = CmpMessageHelper.createCertRequestRejectBody(myPKIHeader, myPKIStatusInfo, requestId, requestType);
View Full Code Here

Examples of org.bouncycastle.asn1.DERUTF8String

        myCertReqMsg.setPop(myProofOfPossession);
        // myCertReqMsg.addRegInfo(new AttributeTypeAndValue(new
        // DERObjectIdentifier("1.3.6.2.2.2.2.3.1"), new
        // DERInteger(1122334455)));
        AttributeTypeAndValue av = new AttributeTypeAndValue(CRMFObjectIdentifiers.regCtrl_regToken, new DERUTF8String("foo123"));
        myCertReqMsg.addRegInfo(av);

        CertReqMessages myCertReqMessages = new CertReqMessages(myCertReqMsg);
        // myCertReqMessages.addCertReqMsg(myCertReqMsg);
View Full Code Here

Examples of org.bouncycastle.asn1.DERUTF8String

        assertEquals(i.getValue().intValue(), 2);
        DERBitString b = info.getFailInfo();
        assertEquals("Return wrong error code.", errorCode, b.intValue());
        if (errorMsg != null) {
            PKIFreeText freeText = info.getStatusString();
            DERUTF8String utf = freeText.getString(0);
            assertEquals(errorMsg, utf.getString());
        }
    }
View Full Code Here

Examples of org.bouncycastle.asn1.DERUTF8String

                myProofOfPossession = new ProofOfPossession(myPOPOSigningKey, 1);          
            }

            myCertReqMsg.setPop(myProofOfPossession);

            final AttributeTypeAndValue av = new AttributeTypeAndValue(CRMFObjectIdentifiers.regCtrl_regToken, new DERUTF8String("foo123"));
            myCertReqMsg.addRegInfo(av);

            final CertReqMessages myCertReqMessages = new CertReqMessages(myCertReqMsg);

            final PKIHeader myPKIHeader =
View Full Code Here

Examples of org.bouncycastle.asn1.DERUTF8String

        // }
        ASN1EncodableVector challpwdattr = new ASN1EncodableVector();
        // Challenge password attribute
        challpwdattr.add(PKCSObjectIdentifiers.pkcs_9_at_challengePassword);
        ASN1EncodableVector pwdvalues = new ASN1EncodableVector();
        pwdvalues.add(new DERUTF8String(password));
        challpwdattr.add(new DERSet(pwdvalues));
        // Requested extensions attribute
        ASN1EncodableVector extensionattr = new ASN1EncodableVector();
        extensionattr.add(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest);
        // AltNames
View Full Code Here

Examples of org.bouncycastle.asn1.DERUTF8String

        this.cacert = ca;
        this.reqdn = dn;


        ASN1EncodableVector vec = new ASN1EncodableVector();
        vec.add(new DERUTF8String(ca.getIssuerDN().getName()));
        vec.add(new DERUTF8String(dn));
        DERSequence seq = new DERSequence(vec);
             
        // wrap message in pkcs#7
        byte[] msg = wrap(seq.getEncoded(), "20");
        return msg;       
View Full Code Here

Examples of org.bouncycastle.asn1.DERUTF8String

    if (status != ResponseStatus.SUCCESS && status != ResponseStatus.GRANTED_WITH_MODS) {
      log.debug("Creating a rejection message");
      myPKIStatusInfo = new PKIStatusInfo(new DERInteger(2)); // 2 = rejection     
      myPKIStatusInfo.setFailInfo(failInfo.getAsBitString());
      if (failText != null) {
        myPKIStatusInfo.setStatusString(new PKIFreeText(new DERUTF8String(failText)));         
      }
    }
    RevRepContent myRevrepMessage = new RevRepContent(myPKIStatusInfo);

    PKIBody myPKIBody = new PKIBody(myRevrepMessage, CmpPKIBodyConstants.REVOCATIONRESPONSE);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.