本文整理汇总了Java中org.bouncycastle.asn1.x500.X500Name.getRDNs方法的典型用法代码示例。如果您正苦于以下问题:Java X500Name.getRDNs方法的具体用法?Java X500Name.getRDNs怎么用?Java X500Name.getRDNs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bouncycastle.asn1.x500.X500Name
的用法示例。
在下文中一共展示了X500Name.getRDNs方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: areEqual
import org.bouncycastle.asn1.x500.X500Name; //导入方法依赖的package包/类
public boolean areEqual(X500Name name1, X500Name name2)
{
RDN[] rdns1 = name1.getRDNs();
RDN[] rdns2 = name2.getRDNs();
if (rdns1.length != rdns2.length)
{
return false;
}
for (int i = 0; i != rdns1.length; i++)
{
if (!rdnAreEqual(rdns1[i], rdns2[i]))
{
return false;
}
}
return true;
}
示例2: toString
import org.bouncycastle.asn1.x500.X500Name; //导入方法依赖的package包/类
public String toString(X500Name name)
{
StringBuffer buf = new StringBuffer();
boolean first = true;
RDN[] rdns = name.getRDNs();
for (int i = rdns.length - 1; i >= 0; i--)
{
if (first)
{
first = false;
}
else
{
buf.append(',');
}
IETFUtils.appendRDN(buf, rdns[i], DefaultSymbols);
}
return buf.toString();
}
示例3: toString
import org.bouncycastle.asn1.x500.X500Name; //导入方法依赖的package包/类
public String toString(X500Name name)
{
StringBuffer buf = new StringBuffer();
boolean first = true;
RDN[] rdns = name.getRDNs();
for (int i = 0; i < rdns.length; i++)
{
if (first)
{
first = false;
}
else
{
buf.append(',');
}
IETFUtils.appendRDN(buf, rdns[i], DefaultSymbols);
}
return buf.toString();
}
示例4: getCommonName
import org.bouncycastle.asn1.x500.X500Name; //导入方法依赖的package包/类
public static String getCommonName(X500Name name) {
ParamUtil.requireNonNull("name", name);
RDN[] rdns = name.getRDNs(ObjectIdentifiers.DN_CN);
if (rdns != null && rdns.length > 0) {
RDN rdn = rdns[0];
AttributeTypeAndValue atv = null;
if (rdn.isMultiValued()) {
for (AttributeTypeAndValue m : rdn.getTypesAndValues()) {
if (m.getType().equals(ObjectIdentifiers.DN_CN)) {
atv = m;
break;
}
}
} else {
atv = rdn.getFirst();
}
return (atv == null) ? null : rdnValueToString(atv.getValue());
}
return null;
}
示例5: areEqual
import org.bouncycastle.asn1.x500.X500Name; //导入方法依赖的package包/类
public boolean areEqual(X500Name name1, X500Name name2)
{
RDN[] rdns1 = name1.getRDNs();
RDN[] rdns2 = name2.getRDNs();
if (rdns1.length != rdns2.length)
{
return false;
}
boolean reverse = false;
if (rdns1[0].getFirst() != null && rdns2[0].getFirst() != null)
{
reverse = !rdns1[0].getFirst().getType().equals(rdns2[0].getFirst().getType()); // guess forward
}
for (int i = 0; i != rdns1.length; i++)
{
if (!foundMatch(reverse, rdns1[i], rdns2))
{
return false;
}
}
return true;
}
示例6: calculateHashCode
import org.bouncycastle.asn1.x500.X500Name; //导入方法依赖的package包/类
public int calculateHashCode(X500Name name)
{
int hashCodeValue = 0;
RDN[] rdns = name.getRDNs();
// this needs to be order independent, like equals
for (int i = 0; i != rdns.length; i++)
{
if (rdns[i].isMultiValued())
{
AttributeTypeAndValue[] atv = rdns[i].getTypesAndValues();
for (int j = 0; j != atv.length; j++)
{
hashCodeValue ^= atv[j].getType().hashCode();
hashCodeValue ^= calcHashCode(atv[j].getValue());
}
}
else
{
hashCodeValue ^= rdns[i].getFirst().getType().hashCode();
hashCodeValue ^= calcHashCode(rdns[i].getFirst().getValue());
}
}
return hashCodeValue;
}
示例7: reverse
import org.bouncycastle.asn1.x500.X500Name; //导入方法依赖的package包/类
public static X500Name reverse(X500Name name) {
ParamUtil.requireNonNull("name", name);
RDN[] orig = name.getRDNs();
final int n = orig.length;
RDN[] newRdn = new RDN[n];
for (int i = 0; i < n; i++) {
newRdn[i] = orig[n - 1 - i];
}
return new X500Name(newRdn);
}
示例8: getSubjectCNFromCertificate
import org.bouncycastle.asn1.x500.X500Name; //导入方法依赖的package包/类
public static String getSubjectCNFromCertificate(X509Certificate certificate) {
try {
X500Name x500name = new JcaX509CertificateHolder(certificate).getIssuer();
RDN cn = x500name.getRDNs(BCStyle.CN)[0];
return IETFUtils.valueToString(cn.getFirst().getValue());
} catch (CertificateEncodingException e) {
log.error("Unable to get issuer CN", e);
return null;
}
}