org.bouncycastle.asn1.x509.X509Extension类的使用及代码示例

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

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

X509Extension介绍

[英]an object for the elements in the X.509 V3 extension block.
[中]X.509 V3扩展块中元素的对象。

代码示例

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

public ASN1Encodable getParsedValue()
{
  return convertValueToObject(this);
}

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

public boolean equals(
  Object  o)
{
  if (!(o instanceof X509Extension))
  {
    return false;
  }
  X509Extension   other = (X509Extension)o;
  return other.getValue().equals(this.getValue())
    && (other.isCritical() == this.isCritical());
}

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

/**
 * Constructor which will take an extension
 *
 * @param extension a X509Extension object containing an AuthorityKeyIdentifier.
 * @deprecated use constructor that takes Extension
 */
public AuthorityKeyIdentifierStructure(
  X509Extension extension)
{
  super((ASN1Sequence)extension.getParsedValue());
}

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

/**
 * Add an extension with the given oid and the passed in byte array to be wrapped in the
 * OCTET STRING associated with the extension.
 *
 * @param oid OID for the extension.
 * @param critical true if critical, false otherwise.
 * @param value the byte array to be wrapped.
 */
public void addExtension(
  ASN1ObjectIdentifier oid,
  boolean             critical,
  byte[]              value)
{
  if (extensions.containsKey(oid))
  {
    throw new IllegalArgumentException("extension " + oid + " already added");
  }
  extOrdering.addElement(oid);
  extensions.put(oid, new X509Extension(critical, new DEROctetString(value)));
}

代码示例来源:origin: org.codeartisans.qipki/qipki-crypto

DERObjectIdentifier oid = ( DERObjectIdentifier ) e.nextElement();
X509Extension extension = requestedExtensions.getExtension( oid );
extractedExtensions.add( new X509ExtensionHolder( oid, extension.isCritical(), X509Extension.convertValueToObject( extension ) ) );

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

/**
   * Convert the value of the passed in extension to an object
   * @param ext the extension to parse
   * @return the object the value string contains
   * @exception IllegalArgumentException if conversion is not possible
   */
  public static ASN1Primitive convertValueToObject(
    X509Extension ext)
    throws IllegalArgumentException
  {
    try
    {
      return ASN1Primitive.fromByteArray(ext.getValue().getOctets());
    }
    catch (IOException e)
    {
      throw new IllegalArgumentException("can't convert extension: " +  e);
    }
  }
}

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

private ASN1ObjectIdentifier[] getExtensionOIDs(boolean isCritical)
{
  Vector oidVec = new Vector();
  for (int i = 0; i != ordering.size(); i++)
  {
    Object oid = ordering.elementAt(i);
    if (((X509Extension)extensions.get(oid)).isCritical() == isCritical)
    {
      oidVec.addElement(oid);
    }
  }
  return toOidArray(oidVec);
}

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

/**
 * Add an extension with the given oid and the passed in byte array to be wrapped in the
 * OCTET STRING associated with the extension.
 *
 * @param oid OID for the extension.
 * @param critical true if critical, false otherwise.
 * @param value the byte array to be wrapped.
 */
public void addExtension(
  ASN1ObjectIdentifier oid,
  boolean             critical,
  byte[]              value)
{
  if (extensions.containsKey(oid))
  {
    throw new IllegalArgumentException("extension " + oid + " already added");
  }
  extOrdering.addElement(oid);
  extensions.put(oid, new X509Extension(critical, new DEROctetString(value)));
}

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

/**
   * Convert the value of the passed in extension to an object
   * @param ext the extension to parse
   * @return the object the value string contains
   * @exception IllegalArgumentException if conversion is not possible
   */
  public static ASN1Primitive convertValueToObject(
    X509Extension ext)
    throws IllegalArgumentException
  {
    try
    {
      return ASN1Primitive.fromByteArray(ext.getValue().getOctets());
    }
    catch (IOException e)
    {
      throw new IllegalArgumentException("can't convert extension: " +  e);
    }
  }
}

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

private ASN1ObjectIdentifier[] getExtensionOIDs(boolean isCritical)
{
  Vector oidVec = new Vector();
  for (int i = 0; i != ordering.size(); i++)
  {
    Object oid = ordering.elementAt(i);
    if (((X509Extension)extensions.get(oid)).isCritical() == isCritical)
    {
      oidVec.addElement(oid);
    }
  }
  return toOidArray(oidVec);
}

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

public boolean equals(
  Object  o)
{
  if (!(o instanceof X509Extension))
  {
    return false;
  }
  X509Extension   other = (X509Extension)o;
  return other.getValue().equals(this.getValue())
    && (other.isCritical() == this.isCritical());
}

代码示例来源:origin: org.codeartisans.qipki/qipki-crypto

@SuppressWarnings( { "UseOfObsoleteCollectionType", "unchecked" } )
private DERSet generateSANAttribute( GeneralNames subGeneralNames )
{
  if ( subGeneralNames == null ) {
    return new DERSet();
  }
  Vector oids = new Vector();
  Vector values = new Vector();
  oids.add( X509Extensions.SubjectAlternativeName );
  values.add( new X509Extension( false, new DEROctetString( subGeneralNames ) ) );
  X509Extensions extensions = new X509Extensions( oids, values );
  Attribute attribute = new Attribute( PKCSObjectIdentifiers.pkcs_9_at_extensionRequest, new DERSet( extensions ) );
  return new DERSet( attribute );
}

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

public ASN1Encodable getParsedValue()
{
  return convertValueToObject(this);
}

代码示例来源:origin: open-eid/digidoc4j

ASN1ObjectIdentifier oid = (ASN1ObjectIdentifier)o;
X509Extension extVal = ext.getExtension(oid);
ASN1OctetString oct = extVal.getValue();
ASN1InputStream extIn = new ASN1InputStream(new ByteArrayInputStream(oct.getOctets()));

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

public int hashCode()
{
  if (this.isCritical())
  {
    return this.getValue().hashCode();
  }
  return ~this.getValue().hashCode();
}

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

/**
 * Constructor from ASN1Sequence.
 *
 * the extensions are a list of constructed sequences, either with (OID, OctetString) or (OID, Boolean, OctetString)
 */
public X509Extensions(
  ASN1Sequence  seq)
{
  Enumeration e = seq.getObjects();
  while (e.hasMoreElements())
  {
    ASN1Sequence            s = ASN1Sequence.getInstance(e.nextElement());
    if (s.size() == 3)
    {
      extensions.put(s.getObjectAt(0), new X509Extension(ASN1Boolean.getInstance(s.getObjectAt(1)), ASN1OctetString.getInstance(s.getObjectAt(2))));
    }
    else if (s.size() == 2)
    {
      extensions.put(s.getObjectAt(0), new X509Extension(false, ASN1OctetString.getInstance(s.getObjectAt(1))));
    }
    else
    {
      throw new IllegalArgumentException("Bad sequence size: " + s.size());
    }
    ordering.addElement(s.getObjectAt(0));
  }
}

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

public static BasicConstraints getInstance(
  Object  obj)
{
  if (obj instanceof BasicConstraints)
  {
    return (BasicConstraints)obj;
  }
  if (obj instanceof X509Extension)
  {
    return getInstance(X509Extension.convertValueToObject((X509Extension)obj));
  }
  if (obj != null)
  {
    return new BasicConstraints(ASN1Sequence.getInstance(obj));
  }
  return null;
}

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

public int hashCode()
{
  if (this.isCritical())
  {
    return this.getValue().hashCode();
  }
  return ~this.getValue().hashCode();
}

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

/**
 * Constructor from ASN1Sequence.
 *
 * the extensions are a list of constructed sequences, either with (OID, OctetString) or (OID, Boolean, OctetString)
 */
public X509Extensions(
  ASN1Sequence  seq)
{
  Enumeration e = seq.getObjects();
  while (e.hasMoreElements())
  {
    ASN1Sequence            s = ASN1Sequence.getInstance(e.nextElement());
    if (s.size() == 3)
    {
      extensions.put(s.getObjectAt(0), new X509Extension(ASN1Boolean.getInstance(s.getObjectAt(1)), ASN1OctetString.getInstance(s.getObjectAt(2))));
    }
    else if (s.size() == 2)
    {
      extensions.put(s.getObjectAt(0), new X509Extension(false, ASN1OctetString.getInstance(s.getObjectAt(1))));
    }
    else
    {
      throw new IllegalArgumentException("Bad sequence size: " + s.size());
    }
    ordering.addElement(s.getObjectAt(0));
  }
}

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

public static BasicConstraints getInstance(
  Object  obj)
{
  if (obj instanceof BasicConstraints)
  {
    return (BasicConstraints)obj;
  }
  if (obj instanceof X509Extension)
  {
    return getInstance(X509Extension.convertValueToObject((X509Extension)obj));
  }
  if (obj != null)
  {
    return new BasicConstraints(ASN1Sequence.getInstance(obj));
  }
  return null;
}

相关文章

微信公众号

最新文章

更多