org.bouncycastle.asn1.x500.X500NameStyle类的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(365)

本文整理了Java中org.bouncycastle.asn1.x500.X500NameStyle类的一些代码示例,展示了X500NameStyle类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。X500NameStyle类的具体详情如下:
包路径:org.bouncycastle.asn1.x500.X500NameStyle
类名称:X500NameStyle

X500NameStyle介绍

[英]It turns out that the number of standard ways the fields in a DN should be encoded into their ASN.1 counterparts is rapidly approaching the number of machines on the internet. By default the X500Name class will produce UTF8Strings in line with the current recommendations (RFC 3280).
[中]事实证明,DN中字段的标准编码方式的数量应该被编码到它们的ASN中。1.互联网上的机器数量正在迅速增加。默认情况下,X500Name类将根据当前建议(RFC 3280)生成UTF8String。

代码示例

代码示例来源:origin: corda/corda-training-solutions

/** Helpers for filtering the network map cache. */
public String toDisplayString(X500Name name){
  return BCStyle.INSTANCE.toString(name);
}

代码示例来源:origin: org.bouncycastle/bcprov-debug-jdk15on

public X500Name(
  X500NameStyle style,
  String        dirName)
{
  this(style.fromString(dirName));
  this.style = style;
}

代码示例来源:origin: org.bouncycastle/bcprov-debug-jdk15on

public int hashCode()
{
  if (isHashCodeCalculated)
  {
    return hashCodeValue;
  }
  isHashCodeCalculated = true;
  hashCodeValue = style.calculateHashCode(this);
  return hashCodeValue;
}

代码示例来源:origin: org.xipki.tk/security

public static ASN1ObjectIdentifier nameToOid(final String name) {
  ParamUtil.requireNonNull("name", name);
  for (ASN1ObjectIdentifier oid : oidNameMap.keySet()) {
    if (oidNameMap.get(oid).equalsIgnoreCase(name)) {
      return oid;
    }
  }
  try {
    return RFC4519Style.INSTANCE.attrNameToOID(name);
  } catch (IllegalArgumentException ex) {
    return null;
  }
}

代码示例来源:origin: org.metaeffekt.dcc/dcc-commons

RDN[] rdns = BCStyle.INSTANCE.fromString(subjectString);
for (RDN rdn : rdns) {
  if (rdn.isMultiValued()) {
  if (attributeName.contains("[")) {
    attributeName = attributeName.substring(0, attributeName.indexOf("["));
    final ASN1ObjectIdentifier oid = BCStyle.INSTANCE.attrNameToOID(attributeName);
    nameBuilder.addRDN(oid, getProperty(attributeKey));

代码示例来源:origin: redfish64/TinyTravelTracker

public X500NameBuilder addRDN(ASN1ObjectIdentifier oid, String value)
{
  this.addRDN(oid, template.stringToValue(oid, value));
  return this;
}

代码示例来源:origin: org.bouncycastle/bcprov-debug-jdk15on

/**
 * test for equality - note: case is ignored.
 */
public boolean equals(Object obj)
{
  if (obj == this)
  {
    return true;
  }
  if (!(obj instanceof X500Name || obj instanceof ASN1Sequence))
  {
    return false;
  }
  
  ASN1Primitive derO = ((ASN1Encodable)obj).toASN1Primitive();
  if (this.toASN1Primitive().equals(derO))
  {
    return true;
  }
  try
  {
    return style.areEqual(this, new X500Name(ASN1Sequence.getInstance(((ASN1Encodable)obj).toASN1Primitive())));
  }
  catch (Exception e)
  {
    return false;
  }
}

代码示例来源:origin: org.xipki/security

public static String getName(ASN1ObjectIdentifier type) {
 Args.notNull(type, "type");
 String name = oidNameMap.get(type);
 if (StringUtil.isBlank(name)) {
  try {
   name = RFC4519Style.INSTANCE.oidToDisplayName(type);
  } catch (IllegalArgumentException ex) { // CHECKSTYLE:SKIP
  }
 }
 return name;
}

代码示例来源:origin: org.xipki/security

public static ASN1ObjectIdentifier nameToOid(String name) {
 Args.notNull(name, "name");
 for (ASN1ObjectIdentifier oid : oidNameMap.keySet()) {
  if (oidNameMap.get(oid).equalsIgnoreCase(name)) {
   return oid;
  }
 }
 try {
  return RFC4519Style.INSTANCE.attrNameToOID(name);
 } catch (IllegalArgumentException ex) {
  return null;
 }
}

代码示例来源:origin: org.bouncycastle/bcprov-debug-jdk15on

/**
 * Add an RDN based on a single OID and a string representation of its value.
 *
 * @param oid the OID for this RDN.
 * @param value the string representation of the value the OID refers to.
 * @return the current builder instance.
 */
public X500NameBuilder addRDN(ASN1ObjectIdentifier oid, String value)
{
  this.addRDN(oid, template.stringToValue(oid, value));
  return this;
}

代码示例来源:origin: redfish64/TinyTravelTracker

/**
 * test for equality - note: case is ignored.
 */
public boolean equals(Object obj)
{
  if (obj == this)
  {
    return true;
  }
  if (!(obj instanceof X500Name || obj instanceof ASN1Sequence))
  {
    return false;
  }
  
  ASN1Primitive derO = ((ASN1Encodable)obj).toASN1Primitive();
  if (this.toASN1Primitive().equals(derO))
  {
    return true;
  }
  try
  {
    return style.areEqual(this, new X500Name(ASN1Sequence.getInstance(((ASN1Encodable)obj).toASN1Primitive())));
  }
  catch (Exception e)
  {
    return false;
  }
}

代码示例来源:origin: org.xipki.tk/security

public static String getName(final ASN1ObjectIdentifier type) {
  ParamUtil.requireNonNull("type", type);
  String name = oidNameMap.get(type);
  if (StringUtil.isBlank(name)) {
    try {
      name = RFC4519Style.INSTANCE.oidToDisplayName(type);
    } catch (IllegalArgumentException ex) { // CHECKSTYLE:SKIP
    }
  }
  return name;
}

代码示例来源:origin: org.bouncycastle/bcprov-debug-jdk15on

public String toString()
{
  return style.toString(this);
}

代码示例来源:origin: puppetlabs/certificate-authority

/**
 * Given a list of attribute names followed by their values, construct an
 * X.500 DN string. For example, if the list ["cn", "common", "o", org"] is
 * passed in then the DN string "CN=common,O=org" is returned.
 *
 * @param rdnPairs A list of attribute and value pairs.
 * @return A X.500 DN string constructed from the given map.
 * @throws IllegalArgumentException If an invalid attribute name is found.
 */
public static String x500Name(List<String> rdnPairs) {
  if ((rdnPairs.size() % 2) != 0) {
    throw new IllegalArgumentException(
        "The RDN pairs list must contain an even number of elements.");
  }
  X500NameBuilder builder = new X500NameBuilder(BCStyle.INSTANCE);
  for (int i=0; i < rdnPairs.size(); i++) {
    String attr = rdnPairs.get(i);
    i++;
    String val = rdnPairs.get(i);
    builder.addRDN(BCStyle.INSTANCE.attrNameToOID(attr), val);
  }
  return builder.build().toString();
}

代码示例来源:origin: redfish64/TinyTravelTracker

public X500NameBuilder addMultiValuedRDN(ASN1ObjectIdentifier[] oids, String[] values)
{
  ASN1Encodable[] vals = new ASN1Encodable[values.length];
  for (int i = 0; i != vals.length; i++)
  {
    vals[i] = template.stringToValue(oids[i], values[i]);
  }
  return addMultiValuedRDN(oids, vals);
}

代码示例来源:origin: redfish64/TinyTravelTracker

public X500Name(
  X500NameStyle style,
  String        dirName)
{
  this(style.fromString(dirName));
  this.style = style;
}

代码示例来源:origin: redfish64/TinyTravelTracker

public int hashCode()
{
  if (isHashCodeCalculated)
  {
    return hashCodeValue;
  }
  isHashCodeCalculated = true;
  hashCodeValue = style.calculateHashCode(this);
  return hashCodeValue;
}

代码示例来源:origin: poreid/poreid

private String getCivilianIdNumber(X509Certificate certificate) throws InvalidNameException {        
  String serialNumber = BCStyle.INSTANCE.oidToDisplayName(BCStyle.SERIALNUMBER);
  Map<String, String> oidMap = new HashMap<>();        
  
  oidMap.put(BCStyle.SERIALNUMBER.getId(), serialNumber);        
  String subjectName = certificate.getSubjectX500Principal().getName(X500Principal.RFC2253, oidMap);
  for (Rdn rdn : new LdapName(subjectName).getRdns()) {
    if (serialNumber.equalsIgnoreCase(rdn.getType())) {
      return rdn.getValue().toString().toLowerCase().replace(BI, "");
    }
  }
  return "";
}

代码示例来源:origin: redfish64/TinyTravelTracker

public String toString()
{
  return style.toString(this);
}

代码示例来源:origin: puppetlabs/ssl-utils

/**
 * Given a list of attribute names followed by their values, construct an
 * X.500 DN string. For example, if the list ["cn", "common", "o", org"] is
 * passed in then the DN string "CN=common,O=org" is returned.
 *
 * @param rdnPairs A list of attribute and value pairs.
 * @return A X.500 DN string constructed from the given map.
 * @throws IllegalArgumentException If an invalid attribute name is found.
 */
public static String x500Name(List<String> rdnPairs) {
  if ((rdnPairs.size() % 2) != 0) {
    throw new IllegalArgumentException(
        "The RDN pairs list must contain an even number of elements.");
  }
  X500NameBuilder builder = new X500NameBuilder(BCStyle.INSTANCE);
  for (int i=0; i < rdnPairs.size(); i++) {
    String attr = rdnPairs.get(i);
    i++;
    String val = rdnPairs.get(i);
    builder.addRDN(BCStyle.INSTANCE.attrNameToOID(attr), val);
  }
  return builder.build().toString();
}

相关文章