use of org.bouncycastle.asn1.DERTaggedObject in project XobotOS by xamarin.
the class V3TBSCertificateGenerator method generateTBSCertificate.
public TBSCertificateStructure generateTBSCertificate() {
if ((serialNumber == null) || (signature == null) || (issuer == null) || (startDate == null) || (endDate == null) || (subject == null && !altNamePresentAndCritical) || (subjectPublicKeyInfo == null)) {
throw new IllegalStateException("not all mandatory fields set in V3 TBScertificate generator");
}
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(version);
v.add(serialNumber);
v.add(signature);
v.add(issuer);
//
// before and after dates
//
ASN1EncodableVector validity = new ASN1EncodableVector();
validity.add(startDate);
validity.add(endDate);
v.add(new DERSequence(validity));
if (subject != null) {
v.add(subject);
} else {
v.add(new DERSequence());
}
v.add(subjectPublicKeyInfo);
if (issuerUniqueID != null) {
v.add(new DERTaggedObject(false, 1, issuerUniqueID));
}
if (subjectUniqueID != null) {
v.add(new DERTaggedObject(false, 2, subjectUniqueID));
}
if (extensions != null) {
v.add(new DERTaggedObject(3, extensions));
}
return new TBSCertificateStructure(new DERSequence(v));
}
use of org.bouncycastle.asn1.DERTaggedObject in project wildfly by wildfly.
the class KerberosTestUtils method generateSpnegoTokenInit.
/**
* Generates SPNEGO init token with given initial ticket and supported mechanisms.
*
* @param ticket initial ticket for the preferred (the first) mechanism.
* @param supMechOids object identifiers (OIDs) of supported mechanisms for the SPNEGO.
* @return ASN.1 encoded SPNEGO init token
*/
public static byte[] generateSpnegoTokenInit(byte[] ticket, String... supMechOids) throws IOException {
DEROctetString ticketForPreferredMech = new DEROctetString(ticket);
ASN1EncodableVector mechSeq = new ASN1EncodableVector();
for (String mech : supMechOids) {
mechSeq.add(new ASN1ObjectIdentifier(mech));
}
DERTaggedObject taggedMechTypes = new DERTaggedObject(0, new DERSequence(mechSeq));
DERTaggedObject taggedMechToken = new DERTaggedObject(2, ticketForPreferredMech);
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(taggedMechTypes);
v.add(taggedMechToken);
DERSequence seqNegTokenInit = new DERSequence(v);
DERTaggedObject taggedSpnego = new DERTaggedObject(0, seqNegTokenInit);
ASN1EncodableVector appVec = new ASN1EncodableVector();
appVec.add(new ASN1ObjectIdentifier(OID_SPNEGO));
appVec.add(taggedSpnego);
DERApplicationSpecific app = new DERApplicationSpecific(0, appVec);
return app.getEncoded();
}
use of org.bouncycastle.asn1.DERTaggedObject in project robovm by robovm.
the class CMSSignedGenerator method addAttributeCertificates.
// BEGIN android-removed
// /**
// * Add a single instance of otherRevocationData to the CRL set to be included with the generated SignedData message.
// *
// * @param otherRevocationInfoFormat the OID specifying the format of the otherRevocationInfo data.
// * @param otherRevocationInfo the otherRevocationInfo ASN.1 structure.
// */
// public void addOtherRevocationInfo(
// ASN1ObjectIdentifier otherRevocationInfoFormat,
// ASN1Encodable otherRevocationInfo)
// {
// crls.add(new DERTaggedObject(false, 1, new OtherRevocationInfoFormat(otherRevocationInfoFormat, otherRevocationInfo)));
// }
//
// /**
// * Add a Store of otherRevocationData to the CRL set to be included with the generated SignedData message.
// *
// * @param otherRevocationInfoFormat the OID specifying the format of the otherRevocationInfo data.
// * @param otherRevocationInfos a Store of otherRevocationInfo data to add.
// */
// public void addOtherRevocationInfo(
// ASN1ObjectIdentifier otherRevocationInfoFormat,
// Store otherRevocationInfos)
// {
// crls.addAll(CMSUtils.getOthersFromStore(otherRevocationInfoFormat, otherRevocationInfos));
// }
// END android-removed
/**
* Add the attribute certificates contained in the passed in store to the
* generator.
*
* @param store a store of Version 2 attribute certificates
* @throws CMSException if an error occurse processing the store.
* @deprecated use basic Store method
*/
public void addAttributeCertificates(X509Store store) throws CMSException {
try {
for (Iterator it = store.getMatches(null).iterator(); it.hasNext(); ) {
X509AttributeCertificate attrCert = (X509AttributeCertificate) it.next();
certs.add(new DERTaggedObject(false, 2, AttributeCertificate.getInstance(ASN1Primitive.fromByteArray(attrCert.getEncoded()))));
}
} catch (IllegalArgumentException e) {
throw new CMSException("error processing attribute certs", e);
} catch (IOException e) {
throw new CMSException("error processing attribute certs", e);
}
}
use of org.bouncycastle.asn1.DERTaggedObject in project robovm by robovm.
the class CertBag method toASN1Primitive.
public ASN1Primitive toASN1Primitive() {
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(certId);
v.add(new DERTaggedObject(0, certValue));
return new DERSequence(v);
}
use of org.bouncycastle.asn1.DERTaggedObject in project robovm by robovm.
the class PrivateKeyInfo method toASN1Primitive.
/**
* write out an RSA private key with its associated information
* as described in PKCS8.
* <pre>
* PrivateKeyInfo ::= SEQUENCE {
* version Version,
* privateKeyAlgorithm AlgorithmIdentifier {{PrivateKeyAlgorithms}},
* privateKey PrivateKey,
* attributes [0] IMPLICIT Attributes OPTIONAL
* }
* Version ::= INTEGER {v1(0)} (v1,...)
*
* PrivateKey ::= OCTET STRING
*
* Attributes ::= SET OF Attribute
* </pre>
*/
public ASN1Primitive toASN1Primitive() {
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(new ASN1Integer(0));
v.add(algId);
v.add(privKey);
if (attributes != null) {
v.add(new DERTaggedObject(false, 0, attributes));
}
return new DERSequence(v);
}
Aggregations