use of com.android.org.bouncycastle.asn1.x509.GeneralName in project ddf by codice.
the class PkiToolsTest method testMakeGeneralNameForRID.
@Test
public void testMakeGeneralNameForRID() {
final String value = "0.2.1.4";
final GeneralName gname = PkiTools.makeGeneralName("RID:" + value);
assertThat(gname.getTagNo(), equalTo(GeneralName.registeredID));
assertThat(gname.getName().toString(), equalTo(value));
}
use of com.android.org.bouncycastle.asn1.x509.GeneralName in project ddf by codice.
the class PkiToolsTest method testMakeGeneralNameForDirName.
@Test
public void testMakeGeneralNameForDirName() {
final String value = "C=UK+CN=My Name+OU=My Unit+O=My Organization";
final GeneralName gname = PkiTools.makeGeneralName("dirName:" + value);
assertThat(gname.getTagNo(), equalTo(GeneralName.directoryName));
assertThat(gname.getName().toString(), equalTo(value));
}
use of com.android.org.bouncycastle.asn1.x509.GeneralName in project qpid-broker-j by apache.
the class TlsResourceBuilder method createDistributionPointExtension.
private static Extension createDistributionPointExtension(final String crlUri) throws CertificateException {
try {
final GeneralName generalName = new GeneralName(GeneralName.uniformResourceIdentifier, crlUri);
final DistributionPointName pointName = new DistributionPointName(new GeneralNames(generalName));
final DistributionPoint[] points = new DistributionPoint[] { new DistributionPoint(pointName, null, null) };
return new Extension(Extension.cRLDistributionPoints, false, new CRLDistPoint(points).getEncoded());
} catch (IOException e) {
throw new CertificateException(e);
}
}
use of com.android.org.bouncycastle.asn1.x509.GeneralName in project athenz by yahoo.
the class Crypto method extractX509CSRSANField.
private static List<String> extractX509CSRSANField(PKCS10CertificationRequest certReq, int tagNo) {
List<String> values = new ArrayList<>();
Attribute[] attributes = certReq.getAttributes(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest);
for (Attribute attribute : attributes) {
for (ASN1Encodable value : attribute.getAttributeValues()) {
Extensions extensions = Extensions.getInstance(value);
GeneralNames gns = GeneralNames.fromExtensions(extensions, Extension.subjectAlternativeName);
// /CLOVER:OFF
if (gns == null) {
continue;
}
// /CLOVER:ON
for (GeneralName name : gns.getNames()) {
if (name.getTagNo() == tagNo) {
values.add(((DERIA5String) name.getName()).getString());
}
}
}
}
return values;
}
use of com.android.org.bouncycastle.asn1.x509.GeneralName in project athenz by yahoo.
the class CryptoTest method testX509CSRrequest.
@Test(dataProvider = "x500Principal")
public void testX509CSRrequest(String x500Principal, boolean badRequest) {
PublicKey publicKey = Crypto.loadPublicKey(rsaPublicKey);
PrivateKey privateKey = Crypto.loadPrivateKey(rsaPrivateKey);
String certRequest = null;
GeneralName otherName1 = new GeneralName(GeneralName.otherName, new DERIA5String("role1"));
GeneralName otherName2 = new GeneralName(GeneralName.otherName, new DERIA5String("role2"));
GeneralName[] sanArray = new GeneralName[] { otherName1, otherName2 };
try {
certRequest = Crypto.generateX509CSR(privateKey, publicKey, x500Principal, sanArray);
} catch (Exception e) {
if (!badRequest) {
fail("Should not have failed to create csr");
}
}
if (!badRequest) {
// Now validate the csr
Crypto.getPKCS10CertRequest(certRequest);
}
}
Aggregations