Search in sources :

Example 1 with SMIMECapability

use of org.bouncycastle.asn1.smime.SMIMECapability in project keystore-explorer by kaikramer.

the class X509Ext method getSMIMECapabilitiesStringValue.

private String getSMIMECapabilitiesStringValue(byte[] octets) throws IOException {
    // @formatter:off
    /*
			SMIMECapabilities ::= SEQUENCE OF SMIMECapability

			SMIMECapability ::= SEQUENCE
			{
				capabilityID OBJECT IDENTIFIER,
				parameters ANY DEFINED BY capabilityID OPTIONAL
			}
		 */
    // @formatter:on
    StringBuilder sb = new StringBuilder();
    int capabilityNr = 0;
    ASN1Sequence asn1Sequence = ASN1Sequence.getInstance(octets);
    for (ASN1Encodable asn1Encodable : asn1Sequence.toArray()) {
        SMIMECapability capability = SMIMECapability.getInstance(asn1Encodable);
        ASN1ObjectIdentifier oid = capability.getCapabilityID();
        ASN1Encodable parameters = capability.getParameters();
        sb.append(MessageFormat.format(res.getString("SMIMECapability"), ++capabilityNr));
        sb.append(NEWLINE);
        sb.append(INDENT);
        sb.append(MessageFormat.format(res.getString("SMIMECapability.ObjectID"), ObjectIdUtil.toString(oid)));
        sb.append(NEWLINE);
        if (parameters != null) {
            sb.append(INDENT);
            sb.append(MessageFormat.format(res.getString("SMIMECapability.Parameter"), HexUtil.getHexString(parameters.toASN1Primitive().getEncoded())));
            sb.append(NEWLINE);
        }
    }
    return sb.toString();
}
Also used : ASN1Sequence(org.bouncycastle.asn1.ASN1Sequence) ASN1Encodable(org.bouncycastle.asn1.ASN1Encodable) SMIMECapability(org.bouncycastle.asn1.smime.SMIMECapability) IssuingDistributionPoint(org.bouncycastle.asn1.x509.IssuingDistributionPoint) CRLDistPoint(org.bouncycastle.asn1.x509.CRLDistPoint) DistributionPoint(org.bouncycastle.asn1.x509.DistributionPoint) ASN1ObjectIdentifier(org.bouncycastle.asn1.ASN1ObjectIdentifier)

Example 2 with SMIMECapability

use of org.bouncycastle.asn1.smime.SMIMECapability in project xipki by xipki.

the class XmlX509Certprofile method initSmimeCapabilities.

private void initSmimeCapabilities(Set<ASN1ObjectIdentifier> extnIds, ExtensionsType extensionsType) throws CertprofileException {
    ASN1ObjectIdentifier type = ObjectIdentifiers.id_smimeCapabilities;
    if (!extensionControls.containsKey(type)) {
        return;
    }
    extnIds.remove(type);
    SMIMECapabilities extConf = (SMIMECapabilities) getExtensionValue(type, extensionsType, SMIMECapabilities.class);
    if (extConf == null) {
        return;
    }
    List<SMIMECapability> list = extConf.getSMIMECapability();
    ASN1EncodableVector vec = new ASN1EncodableVector();
    for (SMIMECapability m : list) {
        ASN1ObjectIdentifier oid = new ASN1ObjectIdentifier(m.getCapabilityID().getValue());
        ASN1Encodable params = null;
        org.xipki.ca.certprofile.x509.jaxb.SMIMECapability.Parameters capParams = m.getParameters();
        if (capParams != null) {
            if (capParams.getInteger() != null) {
                params = new ASN1Integer(capParams.getInteger());
            } else if (capParams.getBase64Binary() != null) {
                params = readAsn1Encodable(capParams.getBase64Binary().getValue());
            }
        }
        org.bouncycastle.asn1.smime.SMIMECapability cap = new org.bouncycastle.asn1.smime.SMIMECapability(oid, params);
        vec.add(cap);
    }
    ASN1Encodable extValue = new DERSequence(vec);
    smimeCapabilities = new ExtensionValue(extensionControls.get(type).isCritical(), extValue);
}
Also used : ASN1Integer(org.bouncycastle.asn1.ASN1Integer) DERSequence(org.bouncycastle.asn1.DERSequence) ExtensionValue(org.xipki.ca.api.profile.ExtensionValue) SMIMECapabilities(org.xipki.ca.certprofile.x509.jaxb.SMIMECapabilities) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector) SMIMECapability(org.xipki.ca.certprofile.x509.jaxb.SMIMECapability) ASN1Encodable(org.bouncycastle.asn1.ASN1Encodable) ASN1ObjectIdentifier(org.bouncycastle.asn1.ASN1ObjectIdentifier)

Example 3 with SMIMECapability

use of org.bouncycastle.asn1.smime.SMIMECapability in project xipki by xipki.

the class ProfileConfCreatorDemo method createSmimeCapabilities.

private static ExtensionValueType createSmimeCapabilities() {
    SMIMECapabilities caps = new SMIMECapabilities();
    // DES-EDE3-CBC
    SMIMECapability cap = new SMIMECapability();
    caps.getSMIMECapability().add(cap);
    cap.setCapabilityID(createOidType(new ASN1ObjectIdentifier("1.2.840.113549.3.7"), "DES-EDE3-CBC"));
    // RC2-CBC keysize 128
    cap = new SMIMECapability();
    caps.getSMIMECapability().add(cap);
    cap.setCapabilityID(createOidType(new ASN1ObjectIdentifier("1.2.840.113549.3.2"), "RC2-CBC"));
    cap.setParameters(new org.xipki.ca.certprofile.x509.jaxb.SMIMECapability.Parameters());
    cap.getParameters().setInteger(BigInteger.valueOf(128));
    // RC2-CBC keysize 64
    cap = new SMIMECapability();
    caps.getSMIMECapability().add(cap);
    cap.setCapabilityID(createOidType(new ASN1ObjectIdentifier("1.2.840.113549.3.2"), "RC2-CBC"));
    cap.setParameters(new org.xipki.ca.certprofile.x509.jaxb.SMIMECapability.Parameters());
    Base64BinaryWithDescType binary = new Base64BinaryWithDescType();
    try {
        binary.setValue(new ASN1Integer(64).getEncoded());
        binary.setDescription("INTEGER 64");
    } catch (IOException ex) {
        throw new RuntimeException(ex.getMessage());
    }
    cap.getParameters().setBase64Binary(binary);
    return createExtensionValueType(caps);
}
Also used : SMIMECapabilities(org.xipki.ca.certprofile.x509.jaxb.SMIMECapabilities) Base64BinaryWithDescType(org.xipki.ca.certprofile.x509.jaxb.Base64BinaryWithDescType) SMIMECapability(org.xipki.ca.certprofile.x509.jaxb.SMIMECapability) ASN1Integer(org.bouncycastle.asn1.ASN1Integer) IOException(java.io.IOException) ASN1ObjectIdentifier(org.bouncycastle.asn1.ASN1ObjectIdentifier)

Aggregations

ASN1ObjectIdentifier (org.bouncycastle.asn1.ASN1ObjectIdentifier)3 ASN1Encodable (org.bouncycastle.asn1.ASN1Encodable)2 ASN1Integer (org.bouncycastle.asn1.ASN1Integer)2 SMIMECapabilities (org.xipki.ca.certprofile.x509.jaxb.SMIMECapabilities)2 SMIMECapability (org.xipki.ca.certprofile.x509.jaxb.SMIMECapability)2 IOException (java.io.IOException)1 ASN1EncodableVector (org.bouncycastle.asn1.ASN1EncodableVector)1 ASN1Sequence (org.bouncycastle.asn1.ASN1Sequence)1 DERSequence (org.bouncycastle.asn1.DERSequence)1 SMIMECapability (org.bouncycastle.asn1.smime.SMIMECapability)1 CRLDistPoint (org.bouncycastle.asn1.x509.CRLDistPoint)1 DistributionPoint (org.bouncycastle.asn1.x509.DistributionPoint)1 IssuingDistributionPoint (org.bouncycastle.asn1.x509.IssuingDistributionPoint)1 ExtensionValue (org.xipki.ca.api.profile.ExtensionValue)1 Base64BinaryWithDescType (org.xipki.ca.certprofile.x509.jaxb.Base64BinaryWithDescType)1