Search in sources :

Example 6 with CmpUtf8Pairs

use of org.xipki.cmp.CmpUtf8Pairs in project xipki by xipki.

the class X509CmpRequestor method buildPkiMessage.

private PKIMessage buildPkiMessage(EnrollCertRequest req) {
    PKIHeader header = buildPkiHeader(implicitConfirm, null);
    List<EnrollCertRequestEntry> reqEntries = req.getRequestEntries();
    CertReqMsg[] certReqMsgs = new CertReqMsg[reqEntries.size()];
    for (int i = 0; i < reqEntries.size(); i++) {
        EnrollCertRequestEntry reqEntry = reqEntries.get(i);
        CmpUtf8Pairs utf8Pairs = new CmpUtf8Pairs(CmpUtf8Pairs.KEY_CERTPROFILE, reqEntry.getCertprofile());
        AttributeTypeAndValue certprofileInfo = CmpUtil.buildAttributeTypeAndValue(utf8Pairs);
        AttributeTypeAndValue[] atvs = (certprofileInfo == null) ? null : new AttributeTypeAndValue[] { certprofileInfo };
        certReqMsgs[i] = new CertReqMsg(reqEntry.getCertReq(), reqEntry.getPopo(), atvs);
    }
    int bodyType;
    switch(req.getType()) {
        case CERT_REQ:
            bodyType = PKIBody.TYPE_CERT_REQ;
            break;
        case KEY_UPDATE:
            bodyType = PKIBody.TYPE_KEY_UPDATE_REQ;
            break;
        default:
            bodyType = PKIBody.TYPE_CROSS_CERT_REQ;
    }
    PKIBody body = new PKIBody(bodyType, new CertReqMessages(certReqMsgs));
    return new PKIMessage(header, body);
}
Also used : PKIHeader(org.bouncycastle.asn1.cmp.PKIHeader) PKIMessage(org.bouncycastle.asn1.cmp.PKIMessage) PKIBody(org.bouncycastle.asn1.cmp.PKIBody) CertReqMessages(org.bouncycastle.asn1.crmf.CertReqMessages) CmpUtf8Pairs(org.xipki.cmp.CmpUtf8Pairs) CertReqMsg(org.bouncycastle.asn1.crmf.CertReqMsg) EnrollCertRequestEntry(org.xipki.ca.client.api.dto.EnrollCertRequestEntry) AttributeTypeAndValue(org.bouncycastle.asn1.crmf.AttributeTypeAndValue)

Example 7 with CmpUtf8Pairs

use of org.xipki.cmp.CmpUtf8Pairs in project xipki by xipki.

the class X509CmpRequestor method buildPkiMessage.

// method buildPkiMessage
private PKIMessage buildPkiMessage(CertRequest req, ProofOfPossession pop, String profileName) {
    PKIHeader header = buildPkiHeader(implicitConfirm, null);
    CmpUtf8Pairs utf8Pairs = new CmpUtf8Pairs(CmpUtf8Pairs.KEY_CERTPROFILE, profileName);
    AttributeTypeAndValue certprofileInfo = CmpUtil.buildAttributeTypeAndValue(utf8Pairs);
    CertReqMsg[] certReqMsgs = new CertReqMsg[1];
    certReqMsgs[0] = new CertReqMsg(req, pop, new AttributeTypeAndValue[] { certprofileInfo });
    PKIBody body = new PKIBody(PKIBody.TYPE_CERT_REQ, new CertReqMessages(certReqMsgs));
    return new PKIMessage(header, body);
}
Also used : PKIHeader(org.bouncycastle.asn1.cmp.PKIHeader) PKIMessage(org.bouncycastle.asn1.cmp.PKIMessage) PKIBody(org.bouncycastle.asn1.cmp.PKIBody) CertReqMessages(org.bouncycastle.asn1.crmf.CertReqMessages) CmpUtf8Pairs(org.xipki.cmp.CmpUtf8Pairs) CertReqMsg(org.bouncycastle.asn1.crmf.CertReqMsg) AttributeTypeAndValue(org.bouncycastle.asn1.crmf.AttributeTypeAndValue)

Example 8 with CmpUtf8Pairs

use of org.xipki.cmp.CmpUtf8Pairs in project xipki by xipki.

the class X509CmpRequestor method buildPkiMessage.

// method buildUnrevokeOrRemoveCertRequest
private PKIMessage buildPkiMessage(CsrEnrollCertRequest csr, Date notBefore, Date notAfter) {
    CmpUtf8Pairs utf8Pairs = new CmpUtf8Pairs(CmpUtf8Pairs.KEY_CERTPROFILE, csr.getCertprofile());
    if (notBefore != null) {
        utf8Pairs.putUtf8Pair(CmpUtf8Pairs.KEY_NOTBEFORE, DateUtil.toUtcTimeyyyyMMddhhmmss(notBefore));
    }
    if (notAfter != null) {
        utf8Pairs.putUtf8Pair(CmpUtf8Pairs.KEY_NOTAFTER, DateUtil.toUtcTimeyyyyMMddhhmmss(notAfter));
    }
    PKIHeader header = buildPkiHeader(implicitConfirm, null, utf8Pairs);
    PKIBody body = new PKIBody(PKIBody.TYPE_P10_CERT_REQ, csr.getCsr());
    return new PKIMessage(header, body);
}
Also used : PKIHeader(org.bouncycastle.asn1.cmp.PKIHeader) PKIMessage(org.bouncycastle.asn1.cmp.PKIMessage) PKIBody(org.bouncycastle.asn1.cmp.PKIBody) CmpUtf8Pairs(org.xipki.cmp.CmpUtf8Pairs)

Example 9 with CmpUtf8Pairs

use of org.xipki.cmp.CmpUtf8Pairs in project xipki by xipki.

the class CmpUtf8PairsTest method test2.

@Test
public void test2() {
    CmpUtf8Pairs pairs = new CmpUtf8Pairs("key-a?value-a%");
    String expEncoded = "key-a?value-a%";
    Map<String, String> expNameValues = new HashMap<>();
    expNameValues.put("key-a", "value-a");
    check(pairs, expEncoded, expNameValues);
}
Also used : CmpUtf8Pairs(org.xipki.cmp.CmpUtf8Pairs) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 10 with CmpUtf8Pairs

use of org.xipki.cmp.CmpUtf8Pairs in project xipki by xipki.

the class CmpUtf8PairsTest method test4.

@Test
public void test4() {
    CmpUtf8Pairs pairs = new CmpUtf8Pairs("key-a?value-a%3f%");
    String expEncoded = "key-a?value-a%3f%";
    Map<String, String> expNameValues = new HashMap<>();
    expNameValues.put("key-a", "value-a?");
    check(pairs, expEncoded, expNameValues);
}
Also used : CmpUtf8Pairs(org.xipki.cmp.CmpUtf8Pairs) HashMap(java.util.HashMap) Test(org.junit.Test)

Aggregations

CmpUtf8Pairs (org.xipki.cmp.CmpUtf8Pairs)10 HashMap (java.util.HashMap)6 Test (org.junit.Test)5 PKIBody (org.bouncycastle.asn1.cmp.PKIBody)4 PKIHeader (org.bouncycastle.asn1.cmp.PKIHeader)3 PKIMessage (org.bouncycastle.asn1.cmp.PKIMessage)3 CertReqMsg (org.bouncycastle.asn1.crmf.CertReqMsg)3 Date (java.util.Date)2 ASN1Integer (org.bouncycastle.asn1.ASN1Integer)2 ASN1OctetString (org.bouncycastle.asn1.ASN1OctetString)2 DERUTF8String (org.bouncycastle.asn1.DERUTF8String)2 CMPCertificate (org.bouncycastle.asn1.cmp.CMPCertificate)2 CertRepMessage (org.bouncycastle.asn1.cmp.CertRepMessage)2 CertResponse (org.bouncycastle.asn1.cmp.CertResponse)2 AttributeTypeAndValue (org.bouncycastle.asn1.crmf.AttributeTypeAndValue)2 CertReqMessages (org.bouncycastle.asn1.crmf.CertReqMessages)2 CertTemplateData (org.xipki.ca.server.impl.CertTemplateData)2 BigInteger (java.math.BigInteger)1 ArrayList (java.util.ArrayList)1 ASN1GeneralizedTime (org.bouncycastle.asn1.ASN1GeneralizedTime)1