本文整理汇总了Java中org.bouncycastle.asn1.x509.SubjectDirectoryAttributes类的典型用法代码示例。如果您正苦于以下问题:Java SubjectDirectoryAttributes类的具体用法?Java SubjectDirectoryAttributes怎么用?Java SubjectDirectoryAttributes使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SubjectDirectoryAttributes类属于org.bouncycastle.asn1.x509包,在下文中一共展示了SubjectDirectoryAttributes类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSubjectDirectoryAttributesStringValue
import org.bouncycastle.asn1.x509.SubjectDirectoryAttributes; //导入依赖的package包/类
private String getSubjectDirectoryAttributesStringValue(byte[] value) throws IOException {
// @formatter:off
/*
* SubjectDirectoryAttributes ::= ASN1Sequence SIZE (1..MAX) OF Attribute
*
* Attribute ::= ASN1Sequence
* {
* type AttributeType,
* values SET OF AttributeValue
* }
*/
// @formatter:on
StringBuilder sb = new StringBuilder();
SubjectDirectoryAttributes subjectDirectoryAttributes = SubjectDirectoryAttributes.getInstance(value);
for (Object attribute : subjectDirectoryAttributes.getAttributes()) {
ASN1ObjectIdentifier attributeType = ((Attribute) attribute).getAttrType();
String attributeTypeStr = attributeType.getId();
ASN1Encodable[] attributeValues = ((Attribute) attribute).getAttributeValues();
for (ASN1Encodable attributeValue : attributeValues) {
String attributeValueStr = getAttributeValueString(attributeType, attributeValue);
sb.append(MessageFormat.format("{0}={1}", attributeTypeStr, attributeValueStr));
sb.append(NEWLINE);
}
}
return sb.toString();
}