use of de.carne.certmgr.certs.x509.DistributionPoint in project certmgr by hdecarne.
the class ASN1DataTest method testDistributionPoint.
/**
* Test encoding & decoding of {@link DistributionPoint} object.
*/
@Test
public void testDistributionPoint() {
try {
// DistributionPointName based
GeneralNames in1FullName = new GeneralNames();
StringName in1NameA = new StringName(GeneralNameType.UNIFORM_RESOURCE_IDENTIFIER, "https://localhost/test.crl");
DirectoryName in1NameB = new DirectoryName(new X500Principal("CN=localhost"));
in1FullName.addName(in1NameA);
in1FullName.addName(in1NameB);
DistributionPointName in1Name = new DistributionPointName(in1FullName);
DistributionPoint in1 = new DistributionPoint(in1Name);
byte[] in1Encoded = in1.getEncoded();
DistributionPoint out1 = DistributionPoint.decode(decodeBytes(in1Encoded));
byte[] out1Encoded = out1.getEncoded();
Assert.assertArrayEquals(in1Encoded, out1Encoded);
// GeneralName based
GeneralNames in2CrlIssuers = new GeneralNames();
StringName in2NameA = new StringName(GeneralNameType.UNIFORM_RESOURCE_IDENTIFIER, "https://localhost/test.crl");
DirectoryName in2NameB = new DirectoryName(new X500Principal("CN=localhost"));
in1FullName.addName(in2NameA);
in1FullName.addName(in2NameB);
DistributionPoint in2 = new DistributionPoint(in2CrlIssuers);
byte[] in2Encoded = in2.encode().toASN1Primitive().getEncoded();
DistributionPoint out2 = DistributionPoint.decode(decodeBytes(in2Encoded));
byte[] out2Encoded = out2.encode().toASN1Primitive().getEncoded();
Assert.assertArrayEquals(in2Encoded, out2Encoded);
} catch (IOException e) {
e.printStackTrace();
Assert.fail(e.getLocalizedMessage());
}
}
use of de.carne.certmgr.certs.x509.DistributionPoint in project certmgr by hdecarne.
the class CRLDistributionPointsController method onApply.
private void onApply(ActionEvent evt) {
try {
boolean critical = this.ctlCritical.isSelected();
DistributionPoint distributionPoint = validateAndGetDistributionPoint();
this.extensionDataResult = new CRLDistributionPointsExtensionData(critical);
this.extensionDataResult.addDistributionPoint(distributionPoint);
} catch (ValidationException e) {
ValidationAlerts.error(e).showAndWait();
evt.consume();
}
}
use of de.carne.certmgr.certs.x509.DistributionPoint in project signer by demoiselle.
the class BasicCertificate method getCRLDistributionPoint.
/**
* @return A list of ulrs that inform the location of the certificate revocation lists
* @throws IOException exception
*/
public List<String> getCRLDistributionPoint() throws IOException {
List<String> crlUrls = new ArrayList<>();
ASN1Primitive primitive = getExtensionValue(Extension.cRLDistributionPoints.getId());
if (primitive == null) {
return null;
}
CRLDistPoint crlDistPoint = CRLDistPoint.getInstance(primitive);
DistributionPoint[] distributionPoints = crlDistPoint.getDistributionPoints();
for (DistributionPoint distributionPoint : distributionPoints) {
DistributionPointName dpn = distributionPoint.getDistributionPoint();
// Look for URIs in fullName
if (dpn != null) {
if (dpn.getType() == DistributionPointName.FULL_NAME) {
GeneralName[] genNames = GeneralNames.getInstance(dpn.getName()).getNames();
for (GeneralName genName : genNames) {
if (genName.getTagNo() == GeneralName.uniformResourceIdentifier) {
String url = DERIA5String.getInstance(genName.getName()).getString();
crlUrls.add(url);
logger.info("Adicionando a url {}", url);
}
}
}
}
}
return crlUrls;
}
use of de.carne.certmgr.certs.x509.DistributionPoint in project keystore-explorer by kaikramer.
the class X509Ext method getCrlDistributionPointsStringValue.
private String getCrlDistributionPointsStringValue(byte[] value) throws IOException {
// @formatter:off
/*
* CRLDistPointSyntax ::= ASN1Sequence SIZE (1..MAX) OF
* DistributionPoint
*/
// @formatter:on
StringBuilder sb = new StringBuilder();
CRLDistPoint crlDistributionPoints = CRLDistPoint.getInstance(value);
int distPoint = 0;
for (DistributionPoint distributionPoint : crlDistributionPoints.getDistributionPoints()) {
distPoint++;
sb.append(MessageFormat.format(res.getString("CrlDistributionPoint"), distPoint));
sb.append(NEWLINE);
sb.append(getDistributionPointString(distributionPoint, INDENT.toString(1)));
}
return sb.toString();
}
use of de.carne.certmgr.certs.x509.DistributionPoint in project keystore-explorer by kaikramer.
the class CRLDistributionPoints method toASN1Primitive.
@Override
public ASN1Primitive toASN1Primitive() {
ASN1EncodableVector v = new ASN1EncodableVector();
Iterator<DistributionPoint> it = distributionPointList.iterator();
while (it.hasNext()) {
v.add(it.next().toASN1Primitive());
}
return new DERSequence(v);
}
Aggregations