org.bouncycastle.asn1.ASN1Object.getEncoded()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(141)

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

ASN1Object.getEncoded介绍

[英]Return the default BER or DER encoding for this object.
[中]返回此对象的默认BER或DER编码。

代码示例

代码示例来源:origin: apache/pdfbox

private TimeStampToken extractTimeStampTokenFromSignerInformation(SignerInformation signerInformation)
    throws CMSException, IOException, TSPException
{
  if (signerInformation.getUnsignedAttributes() == null)
  {
    return null;
  }
  AttributeTable unsignedAttributes = signerInformation.getUnsignedAttributes();
  // https://stackoverflow.com/questions/1647759/how-to-validate-if-a-signed-jar-contains-a-timestamp
  Attribute attribute = unsignedAttributes.get(
      PKCSObjectIdentifiers.id_aa_signatureTimeStampToken);
  if (attribute == null)
  {
    return null;
  }
  ASN1Object obj = (ASN1Object) attribute.getAttrValues().getObjectAt(0);
  CMSSignedData signedTSTData = new CMSSignedData(obj.getEncoded());
  return new TimeStampToken(signedTSTData);
}

代码示例来源:origin: kaikramer/keystore-explorer

@Override
public boolean equals(Object paramObject) {
  if (paramObject == null) {
    return false;
  }
  try {
    return Arrays.equals(((ASN1Object) paramObject).getEncoded(), getEncoded());
  } catch (Exception e) {
    // ignore
  }
  return false;
}

代码示例来源:origin: eu.eu-emi.security/canl

private byte[] calculateSignature(String sigName, String provider, PrivateKey key,
    SecureRandom random, ASN1Object object)
    throws IOException, NoSuchProviderException,
    NoSuchAlgorithmException, InvalidKeyException,
    SignatureException
{
  Signature sig;
  if (provider != null)
    sig = Signature.getInstance(sigName, provider);
  else
    sig = Signature.getInstance(sigName);
  if (random != null)
    sig.initSign(key, random);
  else
    sig.initSign(key);
  sig.update(object.getEncoded(ASN1Encoding.DER));
  return sig.sign();
}

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

private static byte[] getEncodedVector(ASN1EncodableVector vec)
{
  ByteArrayOutputStream bOut = new ByteArrayOutputStream();
  for (int i = 0; i != vec.size(); i++)
  {
    try
    {
      bOut.write(((ASN1Object)vec.get(i)).getEncoded(ASN1Encoding.DER));
    }
    catch (IOException e)
    {
      throw new ASN1ParsingException("malformed object: " + e, e);
    }
  }
  return bOut.toByteArray();
}

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

private static byte[] getEncodedVector(ASN1EncodableVector vec)
{
  ByteArrayOutputStream bOut = new ByteArrayOutputStream();
  for (int i = 0; i != vec.size(); i++)
  {
    try
    {
      bOut.write(((ASN1Object)vec.get(i)).getEncoded(ASN1Encoding.BER));
    }
    catch (IOException e)
    {
      throw new ASN1ParsingException("malformed object: " + e, e);
    }
  }
  return bOut.toByteArray();
}

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

private static byte[] getEncodedVector(ASN1EncodableVector vec)
{
  ByteArrayOutputStream bOut = new ByteArrayOutputStream();
  for (int i = 0; i != vec.size(); i++)
  {
    try
    {
      bOut.write(((ASN1Object)vec.get(i)).getEncoded(ASN1Encoding.DL));
    }
    catch (IOException e)
    {
      throw new ASN1ParsingException("malformed object: " + e, e);
    }
  }
  return bOut.toByteArray();
}

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

public DERApplicationSpecific(int tagNo, ASN1EncodableVector vec)
{
  this.tag = tagNo;
  this.isConstructed = true;
  ByteArrayOutputStream bOut = new ByteArrayOutputStream();
  for (int i = 0; i != vec.size(); i++)
  {
    try
    {
      bOut.write(((ASN1Object)vec.get(i)).getEncoded(ASN1Encoding.DER));
    }
    catch (IOException e)
    {
      throw new ASN1ParsingException("malformed object: " + e, e);
    }
  }
  this.octets = bOut.toByteArray();
}

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

/**
 * Return either the default for "BER" or a DER encoding if "DER" is specified.
 *
 * @param encoding name of encoding to use.
 * @return byte encoded object.
 * @throws IOException on encoding error.
 */
public byte[] getEncoded(
  String encoding)
  throws IOException
{
  if (encoding.equals(ASN1Encoding.DER))
  {
    ByteArrayOutputStream   bOut = new ByteArrayOutputStream();
    DEROutputStream         dOut = new DEROutputStream(bOut);
    dOut.writeObject(this);
    return bOut.toByteArray();
  }
  else if (encoding.equals(ASN1Encoding.DL))
  {
    ByteArrayOutputStream   bOut = new ByteArrayOutputStream();
    DLOutputStream          dOut = new DLOutputStream(bOut);
    dOut.writeObject(this);
    return bOut.toByteArray();
  }
  return this.getEncoded();
}

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

/**
 * Return either the default for "BER" or a DER encoding if "DER" is specified.
 *
 * @param encoding name of encoding to use.
 * @return byte encoded object.
 * @throws IOException on encoding error.
 */
public byte[] getEncoded(
  String encoding)
  throws IOException
{
  if (encoding.equals(ASN1Encoding.DER))
  {
    ByteArrayOutputStream   bOut = new ByteArrayOutputStream();
    DEROutputStream         dOut = new DEROutputStream(bOut);
    dOut.writeObject(this);
    return bOut.toByteArray();
  }
  else if (encoding.equals(ASN1Encoding.DL))
  {
    ByteArrayOutputStream   bOut = new ByteArrayOutputStream();
    DLOutputStream          dOut = new DLOutputStream(bOut);
    dOut.writeObject(this);
    return bOut.toByteArray();
  }
  return this.getEncoded();
}

代码示例来源:origin: com.google.code.jscep/jscep-api

algParams.init(params.getEncoded());

代码示例来源:origin: org.apache.pdfbox/pdfbox-examples

private TimeStampToken extractTimeStampTokenFromSignerInformation(SignerInformation signerInformation)
    throws CMSException, IOException, TSPException
{
  if (signerInformation.getUnsignedAttributes() == null)
  {
    return null;
  }
  AttributeTable unsignedAttributes = signerInformation.getUnsignedAttributes();
  // https://stackoverflow.com/questions/1647759/how-to-validate-if-a-signed-jar-contains-a-timestamp
  Attribute attribute = unsignedAttributes.get(
      PKCSObjectIdentifiers.id_aa_signatureTimeStampToken);
  ASN1Object obj = (ASN1Object) attribute.getAttrValues().getObjectAt(0);
  CMSSignedData signedTSTData = new CMSSignedData(obj.getEncoded());
  return new TimeStampToken(signedTSTData);
}

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

private CMSEnvelopedData encodeMessage(final PkiMessage<?> message)
    throws MessageEncodingException {
  Object messageData = message.getMessageData();
  byte[] bytes;
  if (messageData instanceof byte[]) {
    bytes = (byte[]) messageData;
  } else if (messageData instanceof PKCS10CertificationRequest) {
    try {
      bytes = ((PKCS10CertificationRequest) messageData).getEncoded();
    } catch (IOException e) {
      throw new MessageEncodingException(e);
    }
  } else if (messageData instanceof CMSSignedData) {
    try {
      bytes = ((CMSSignedData) messageData).getEncoded();
    } catch (IOException e) {
      throw new MessageEncodingException(e);
    }
  } else {
    try {
      bytes = ((ASN1Object) messageData).getEncoded();
    } catch (IOException e) {
      throw new MessageEncodingException(e);
    }
  }
  return enveloper.encode(bytes);
}

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

} else {
  try {
    encodedContent = content.getEncoded();
  } catch (IOException ex) {
    throw new P11TokenException("could encode the content", ex);

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

} else {
 try {
  encodedContent = content.getEncoded();
 } catch (IOException ex) {
  throw new P11TokenException("could encode the content", ex);

相关文章

微信公众号

最新文章

更多