use of sun.security.x509.GeneralNames in project keystore-explorer by kaikramer.
the class X509Ext method getAuthorityKeyIdentifierStringValue.
private String getAuthorityKeyIdentifierStringValue(byte[] value) throws IOException {
// @formatter:off
/*
* AuthorityKeyIdentifier ::= ASN1Sequence { keyIdentifier [0]
* KeyIdentifier OPTIONAL, authorityCertIssuer [1] GeneralNames
* OPTIONAL, authorityCertSerialNumber [2] CertificateSerialNumber
* OPTIONAL }
*
* KeyIdentifier ::= OCTET STRING
*
* GeneralNames ::= ASN1Sequence SIZE (1..MAX) OF GeneralName
*
* CertificateSerialNumber ::= ASN1Integer
*/
// @formatter:on
StringBuilder sb = new StringBuilder();
AuthorityKeyIdentifier authorityKeyIdentifier = AuthorityKeyIdentifier.getInstance(value);
byte[] keyIdentifier = authorityKeyIdentifier.getKeyIdentifier();
GeneralNames authorityCertIssuer = authorityKeyIdentifier.getAuthorityCertIssuer();
BigInteger certificateSerialNumber = authorityKeyIdentifier.getAuthorityCertSerialNumber();
if (keyIdentifier != null) {
// Optional
// Output as a hex string
sb.append(MessageFormat.format(res.getString("AuthorityKeyIdentifier"), HexUtil.getHexString(keyIdentifier)));
sb.append(NEWLINE);
}
if (authorityCertIssuer != null) {
// Optional
sb.append(res.getString("CertificateIssuer"));
sb.append(NEWLINE);
for (GeneralName generalName : authorityCertIssuer.getNames()) {
sb.append(INDENT);
sb.append(GeneralNameUtil.toString(generalName));
sb.append(NEWLINE);
}
}
if (certificateSerialNumber != null) {
// Optional
// Output as an integer
sb.append(MessageFormat.format(res.getString("CertificateSerialNumber"), HexUtil.getHexString(certificateSerialNumber)));
sb.append(NEWLINE);
}
return sb.toString();
}
use of sun.security.x509.GeneralNames in project keystore-explorer by kaikramer.
the class X509Ext method getSubjectAlternativeNameStringValue.
private String getSubjectAlternativeNameStringValue(byte[] value) throws IOException {
// @formatter:off
/*
* SubjectAltName ::= GeneralNames
*
* GeneralNames ::= ASN1Sequence SIZE (1..MAX) OF GeneralName
*/
// @formatter:on
StringBuilder sb = new StringBuilder();
GeneralNames subjectAltName = GeneralNames.getInstance(value);
for (GeneralName generalName : subjectAltName.getNames()) {
sb.append(GeneralNameUtil.toString(generalName));
sb.append(NEWLINE);
}
return sb.toString();
}
use of sun.security.x509.GeneralNames in project keystore-explorer by kaikramer.
the class X509Ext method getCertificateIssuerStringValue.
private String getCertificateIssuerStringValue(byte[] value) throws IOException {
// @formatter:off
/*
* certificateIssuer ::= GeneralNames
*
* GeneralNames ::= ASN1Sequence SIZE (1..MAX) OF GeneralName
*/
// @formatter:on
StringBuilder sb = new StringBuilder();
GeneralNames certificateIssuer = GeneralNames.getInstance(value);
for (GeneralName generalName : certificateIssuer.getNames()) {
sb.append(GeneralNameUtil.toString(generalName));
sb.append(NEWLINE);
}
return sb.toString();
}
use of sun.security.x509.GeneralNames in project keystore-explorer by kaikramer.
the class X509Ext method getDistributionPointNameString.
private String getDistributionPointNameString(DistributionPointName distributionPointName, String baseIndent) throws IOException {
// @formatter:off
/*
* DistributionPointName ::= CHOICE {
* fullname [0] GeneralNames,
* nameRelativeToCRLIssuer [1] RelativeDistinguishedName
* }
*
* RelativeDistinguishedName ::= SET SIZE (1 .. MAX) OF
* AttributeTypeAndValue
*
* AttributeTypeAndValue ::= ASN1Sequence { type AttributeType, value
* AttributeValue }
*/
// @formatter: on
StringBuilder sb = new StringBuilder();
sb.append(baseIndent);
sb.append(res.getString("DistributionPointName"));
sb.append(NEWLINE);
if (distributionPointName.getType() == DistributionPointName.FULL_NAME) {
sb.append(baseIndent);
sb.append(INDENT);
sb.append(res.getString("DistributionPointFullName"));
sb.append(NEWLINE);
GeneralNames generalNames = GeneralNames.getInstance(distributionPointName.getName());
for (GeneralName generalName : generalNames.getNames()) {
sb.append(baseIndent);
sb.append(INDENT);
sb.append(INDENT);
sb.append(GeneralNameUtil.toString(generalName));
sb.append(NEWLINE);
}
} else {
// DistributionPointName.TAG_NAMERELATIVETOCRLISSUER
sb.append(baseIndent);
sb.append(INDENT);
sb.append(res.getString("DistributionPointNameRelativeToCrlIssuer"));
sb.append(NEWLINE);
RDN rdn = RDN.getInstance(distributionPointName.getName());
for (AttributeTypeAndValue attributeTypeAndValue : rdn.getTypesAndValues()) {
ASN1ObjectIdentifier attributeType = attributeTypeAndValue.getType();
ASN1Encodable attributeValue = attributeTypeAndValue.getValue();
String attributeTypeStr = getAttributeTypeString(attributeType);
String attributeValueStr = getAttributeValueString(attributeType, attributeValue);
sb.append(baseIndent);
sb.append(INDENT);
sb.append(INDENT);
sb.append(MessageFormat.format("{0}={1}", attributeTypeStr, attributeValueStr));
sb.append(NEWLINE);
}
}
return sb.toString();
}
use of sun.security.x509.GeneralNames in project keystore-explorer by kaikramer.
the class X509Ext method getIssuerAlternativeNameStringValue.
private String getIssuerAlternativeNameStringValue(byte[] value) throws IOException {
// @formatter:off
/*
* IssuerAltName ::= GeneralNames
*
* GeneralNames ::= ASN1Sequence SIZE (1..MAX) OF GeneralName
*/
// @formatter:on
StringBuilder sb = new StringBuilder();
GeneralNames issuerAltName = GeneralNames.getInstance(value);
for (GeneralName generalName : issuerAltName.getNames()) {
sb.append(GeneralNameUtil.toString(generalName));
sb.append(NEWLINE);
}
return sb.toString();
}
Aggregations