use of org.bouncycastle.asn1.x509.ReasonFlags in project keystore-explorer by kaikramer.
the class X509Ext method getIssuingDistributionPointStringValue.
private String getIssuingDistributionPointStringValue(byte[] value) throws IOException {
// @formatter:off
/*
* IssuingDistributionPoint ::= ASN1Sequence {
* distributionPoint [0] DistributionPointName OPTIONAL,
* onlyContainsUserCerts [1] ASN1Boolean DEFAULT FALSE,
* onlyContainsCACerts [2] ASN1Boolean DEFAULT FALSE,
* onlySomeReasons [3] ReasonFlags OPTIONAL,
* indirectCRL [4] ASN1Boolean DEFAULT FALSE,
* onlyContainsAttributeCerts [5] ASN1Boolean DEFAULT FALSE }
*/
// @formatter:on
/*
* Getting any DEFAULTS returns a false ASN1Boolean when no value
* present which saves the bother of a null check
*/
StringBuilder sb = new StringBuilder();
IssuingDistributionPoint issuingDistributionPoint = IssuingDistributionPoint.getInstance(value);
DistributionPointName distributionPointName = issuingDistributionPoint.getDistributionPoint();
if (distributionPointName != null) {
// Optional
sb.append(getDistributionPointNameString(distributionPointName, ""));
}
boolean onlyContainsUserCerts = issuingDistributionPoint.onlyContainsUserCerts();
sb.append(MessageFormat.format(res.getString("OnlyContainsUserCerts"), onlyContainsUserCerts));
sb.append(NEWLINE);
boolean onlyContainsCaCerts = issuingDistributionPoint.onlyContainsCACerts();
sb.append(MessageFormat.format(res.getString("OnlyContainsCaCerts"), onlyContainsCaCerts));
sb.append(NEWLINE);
ReasonFlags onlySomeReasons = issuingDistributionPoint.getOnlySomeReasons();
if (onlySomeReasons != null) {
// Optional
sb.append(res.getString("OnlySomeReasons"));
sb.append(NEWLINE);
String[] reasonFlags = getReasonFlagsStrings(onlySomeReasons);
for (String reasonFlag : reasonFlags) {
sb.append(INDENT);
sb.append(reasonFlag);
sb.append(NEWLINE);
}
}
boolean indirectCrl = issuingDistributionPoint.isIndirectCRL();
sb.append(MessageFormat.format(res.getString("IndirectCrl"), indirectCrl));
sb.append(NEWLINE);
boolean onlyContainsAttributeCerts = issuingDistributionPoint.onlyContainsAttributeCerts();
sb.append(MessageFormat.format(res.getString("OnlyContainsAttributeCerts"), onlyContainsAttributeCerts));
sb.append(NEWLINE);
return sb.toString();
}
use of org.bouncycastle.asn1.x509.ReasonFlags in project keystore-explorer by kaikramer.
the class X509Ext method getDistributionPointString.
private String getDistributionPointString(DistributionPoint distributionPoint, String baseIndent) throws IOException {
// @formatter:off
/*
* DistributionPoint ::= ASN1Sequence {
* distributionPoint [0] DistributionPointName OPTIONAL,
* reasons [1] ReasonFlags OPTIONAL,
* cRLIssuer [2] GeneralNames OPTIONAL
* }
*
* GeneralNames ::= ASN1Sequence SIZE (1..MAX) OF GeneralName
*/
// @formatter:on
StringBuilder sb = new StringBuilder();
DistributionPointName distributionPointName = distributionPoint.getDistributionPoint();
ReasonFlags reasons = distributionPoint.getReasons();
GeneralNames crlIssuer = distributionPoint.getCRLIssuer();
if (distributionPointName != null) {
// Optional
sb.append(getDistributionPointNameString(distributionPointName, baseIndent));
}
if (reasons != null) {
// Optional
sb.append(baseIndent);
sb.append(res.getString("DistributionPointReasons"));
sb.append(NEWLINE);
String[] reasonFlags = getReasonFlagsStrings(reasons);
for (String reasonFlag : reasonFlags) {
sb.append(baseIndent);
sb.append(INDENT);
sb.append(reasonFlag);
sb.append(NEWLINE);
}
}
if (crlIssuer != null) {
// Optional
sb.append(baseIndent);
sb.append(res.getString("DistributionPointCrlIssuer"));
sb.append(NEWLINE);
for (GeneralName generalName : crlIssuer.getNames()) {
sb.append(baseIndent);
sb.append(INDENT);
sb.append(GeneralNameUtil.toString(generalName));
sb.append(NEWLINE);
}
}
return sb.toString();
}
Aggregations