Example usage for org.bouncycastle.asn1.cmp PKIHeader CMP_2000

List of usage examples for org.bouncycastle.asn1.cmp PKIHeader CMP_2000

Introduction

In this page you can find the example usage for org.bouncycastle.asn1.cmp PKIHeader CMP_2000.

Prototype

int CMP_2000

To view the source code for org.bouncycastle.asn1.cmp PKIHeader CMP_2000.

Click Source Link

Usage

From source file:org.xipki.ca.client.impl.CmpRequestor.java

License:Open Source License

protected PKIHeader buildPKIHeader(final boolean addImplictConfirm, final ASN1OctetString tid,
        final CmpUtf8Pairs utf8Pairs, final InfoTypeAndValue... additionalGeneralInfos) {
    if (additionalGeneralInfos != null) {
        for (InfoTypeAndValue itv : additionalGeneralInfos) {
            ASN1ObjectIdentifier type = itv.getInfoType();
            if (CMPObjectIdentifiers.it_implicitConfirm.equals(type)) {
                throw new IllegalArgumentException(
                        "" + "additionGeneralInfos contains unpermitted ITV implicitConfirm");
            }//w  ww. j a va2 s  .  co  m

            if (CMPObjectIdentifiers.regInfo_utf8Pairs.equals(type)) {
                throw new IllegalArgumentException(
                        "" + "additionGeneralInfos contains unpermitted ITV utf8Pairs");
            }
        }
    }

    PKIHeaderBuilder hBuilder = new PKIHeaderBuilder(PKIHeader.CMP_2000, sender,
            recipient != null ? recipient : DUMMY_RECIPIENT);
    hBuilder.setMessageTime(new ASN1GeneralizedTime(new Date()));

    ASN1OctetString _tid;
    if (tid == null) {
        _tid = new DEROctetString(randomTransactionId());
    } else {
        _tid = tid;
    }

    hBuilder.setTransactionID(_tid);

    List<InfoTypeAndValue> itvs = new ArrayList<>(2);
    if (addImplictConfirm) {
        itvs.add(CmpUtil.getImplictConfirmGeneralInfo());
    }

    if (utf8Pairs != null) {
        itvs.add(CmpUtil.buildInfoTypeAndValue(utf8Pairs));
    }

    if (additionalGeneralInfos != null) {
        for (InfoTypeAndValue itv : additionalGeneralInfos) {
            if (itv != null) {
                itvs.add(itv);
            }
        }
    }

    if (CollectionUtil.isNotEmpty(itvs)) {
        hBuilder.setGeneralInfo(itvs.toArray(new InfoTypeAndValue[0]));
    }

    return hBuilder.build();
}

From source file:org.xipki.commons.security.pkcs11.proxy.ProxyP11Module.java

License:Open Source License

private PKIHeader buildPkiHeader(final ASN1OctetString tid) {
    PKIHeaderBuilder hdrBuilder = new PKIHeaderBuilder(PKIHeader.CMP_2000, sender, recipient);
    hdrBuilder.setMessageTime(new ASN1GeneralizedTime(new Date()));

    ASN1OctetString tmpTid = (tid == null) ? new DEROctetString(randomTransactionId()) : tid;
    hdrBuilder.setTransactionID(tmpTid);

    return hdrBuilder.build();
}

From source file:org.xipki.pki.ca.client.impl.CmpRequestor.java

License:Open Source License

protected PKIHeader buildPkiHeader(final boolean addImplictConfirm, final ASN1OctetString tid,
        final CmpUtf8Pairs utf8Pairs, final InfoTypeAndValue... additionalGeneralInfos) {
    if (additionalGeneralInfos != null) {
        for (InfoTypeAndValue itv : additionalGeneralInfos) {
            ASN1ObjectIdentifier type = itv.getInfoType();
            if (CMPObjectIdentifiers.it_implicitConfirm.equals(type)) {
                throw new IllegalArgumentException(
                        "additionGeneralInfos contains not-permitted ITV implicitConfirm");
            }/*  ww  w  .jav a2  s  .c om*/

            if (CMPObjectIdentifiers.regInfo_utf8Pairs.equals(type)) {
                throw new IllegalArgumentException("additionGeneralInfos contains not-permitted ITV utf8Pairs");
            }
        }
    }

    PKIHeaderBuilder hdrBuilder = new PKIHeaderBuilder(PKIHeader.CMP_2000, sender, recipient);
    hdrBuilder.setMessageTime(new ASN1GeneralizedTime(new Date()));

    ASN1OctetString tmpTid = (tid == null) ? new DEROctetString(randomTransactionId()) : tid;
    hdrBuilder.setTransactionID(tmpTid);

    List<InfoTypeAndValue> itvs = new ArrayList<>(2);
    if (addImplictConfirm) {
        itvs.add(CmpUtil.getImplictConfirmGeneralInfo());
    }

    if (utf8Pairs != null) {
        itvs.add(CmpUtil.buildInfoTypeAndValue(utf8Pairs));
    }

    if (additionalGeneralInfos != null) {
        for (InfoTypeAndValue itv : additionalGeneralInfos) {
            if (itv != null) {
                itvs.add(itv);
            }
        }
    }

    if (CollectionUtil.isNonEmpty(itvs)) {
        hdrBuilder.setGeneralInfo(itvs.toArray(new InfoTypeAndValue[0]));
    }

    return hdrBuilder.build();
}

From source file:org.xipki.security.p11.remote.RemoteP11CryptService.java

License:Open Source License

private PKIHeader buildPKIHeader(ASN1OctetString tid) {
    PKIHeaderBuilder hBuilder = new PKIHeaderBuilder(PKIHeader.CMP_2000, sender, recipient);
    hBuilder.setMessageTime(new ASN1GeneralizedTime(new Date()));

    if (tid == null) {
        tid = new DEROctetString(randomTransactionId());
    }//from w w  w .ja v a  2s.c o m
    hBuilder.setTransactionID(tid);

    return hBuilder.build();
}