org.bouncycastle.asn1.ASN1InputStream.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(161)

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

ASN1InputStream.<init>介绍

[英]Create an ASN1InputStream where no DER object will be longer than limit.
[中]创建一个ASN1InputStream,其中DER对象的长度不会超过限制。

代码示例

代码示例来源:origin: jamesdbloom/mockserver

private static SubjectKeyIdentifier createSubjectKeyIdentifier(Key key) throws IOException {
  try (ASN1InputStream is = new ASN1InputStream(new ByteArrayInputStream(key.getEncoded()))) {
    ASN1Sequence seq = (ASN1Sequence) is.readObject();
    SubjectPublicKeyInfo info = SubjectPublicKeyInfo.getInstance(seq);
    return new BcX509ExtensionUtils().createSubjectKeyIdentifier(info);
  }
}

代码示例来源:origin: igniterealtime/Openfire

@Override
public int doEndTag() throws JspException {
  try {
    final ASN1InputStream decoder = new ASN1InputStream(value);
    ASN1Primitive primitive = decoder.readObject();
    while (primitive != null && !(primitive instanceof ASN1Null)) {
      pageContext.getOut().write(doPrimitive(primitive));
      primitive = decoder.readObject();
    }
  } catch (Exception ex) {
    throw new JspException(ex.getMessage());
  }
  return super.doEndTag();
}

代码示例来源:origin: JZ-Darkal/AndroidHttpCapture

private static SubjectKeyIdentifier createSubjectKeyIdentifier(Key key)
    throws IOException {
  ByteArrayInputStream bIn = new ByteArrayInputStream(key.getEncoded());
  ASN1InputStream is = null;
  try {
    is = new ASN1InputStream(bIn);
    ASN1Sequence seq = (ASN1Sequence) is.readObject();
    SubjectPublicKeyInfo info = new SubjectPublicKeyInfo(seq);
    return new BcX509ExtensionUtils().createSubjectKeyIdentifier(info);
  } finally {
    IOUtils.closeQuietly(is);
  }
}

代码示例来源:origin: org.apache.poi/poi-ooxml

private BigInteger getCrlNumber(X509CRL crl) {
  byte[] crlNumberExtensionValue = crl.getExtensionValue(Extension.cRLNumber.getId());
  if (null == crlNumberExtensionValue) {
    return null;
  }
  try {
    ASN1InputStream asn1IS1 = null, asn1IS2 = null;
    try {
      asn1IS1 = new ASN1InputStream(crlNumberExtensionValue);
      ASN1OctetString octetString = (ASN1OctetString)asn1IS1.readObject();
      byte[] octets = octetString.getOctets();
      asn1IS2 = new ASN1InputStream(octets);
      ASN1Integer integer = (ASN1Integer)asn1IS2.readObject();
      return integer.getPositiveValue();
    } finally {
      IOUtils.closeQuietly(asn1IS2);
      IOUtils.closeQuietly(asn1IS1);
    }
  } catch (IOException e) {
    throw new RuntimeException("I/O error: " + e.getMessage(), e);
  }
}

代码示例来源:origin: igniterealtime/Openfire

try ( final ASN1InputStream decoder = new ASN1InputStream( item ) )
  final ASN1Primitive object = decoder.readObject();
  final ASN1Sequence otherNameSeq = (ASN1Sequence) object;

代码示例来源:origin: Meituan-Dianping/walle

try (ASN1InputStream asn1 = new ASN1InputStream(sigData.getEncoded())) {
  DEROutputStream dos = new DEROutputStream(out);
  dos.writeObject(asn1.readObject());

代码示例来源:origin: igniterealtime/Openfire

try ( final ASN1InputStream decoder = new ASN1InputStream( (byte[]) value ) )
  final ASN1Primitive object = decoder.readObject();
  final ASN1Sequence otherNameSeq = (ASN1Sequence) object;

代码示例来源:origin: stackoverflow.com

ASN1InputStream bIn = new ASN1InputStream(new ByteArrayInputStream(data));
ASN1Primitive obj = bIn.readObject();
System.out.println(ASN1Dump.dumpAsString(obj));

代码示例来源:origin: linkedin/flashback

/**
 * Create subjectKeyIdentifier
 * The Subject Key Identifier extension identifies the public key certified by this certificate.
 * This extension provides a way of distinguishing public keys if more than one is available for
 * a given subject name.
 * i.e.
 *     Identifier: Subject Key Identifier - 2.5.29.14
 *       Critical: no
 *        Key Identifier:
 *          3B:46:83:85:27:BC:F5:9D:8E:63:E3:BE:79:EF:AF:79:
 *          9C:37:85:84
 *
 * */
protected SubjectKeyIdentifier createSubjectKeyIdentifier(PublicKey publicKey)
  throws IOException {
 try (ByteArrayInputStream bais = new ByteArrayInputStream(publicKey.getEncoded());
   ASN1InputStream ais = new ASN1InputStream(bais)) {
  ASN1Sequence asn1Sequence = (ASN1Sequence) ais.readObject();
  SubjectPublicKeyInfo subjectPublicKeyInfo = new SubjectPublicKeyInfo(asn1Sequence);
  return new BcX509ExtensionUtils().createSubjectKeyIdentifier(subjectPublicKeyInfo);
 }
}

代码示例来源:origin: hyperledger/fabric-sdk-java

ASN1InputStream asnInputStream = new ASN1InputStream(inStream);
ASN1Primitive asn1 = asnInputStream.readObject();

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

ASN1InputStream oAsnInStream = new ASN1InputStream(new ByteArrayInputStream(crldpExt));
ASN1Primitive derObjCrlDP = oAsnInStream.readObject();
DEROctetString dosCrlDP = (DEROctetString) derObjCrlDP;
byte[] crldpExtOctets = dosCrlDP.getOctets();
ASN1InputStream oAsnInStream2 = new ASN1InputStream(new ByteArrayInputStream(crldpExtOctets));
ASN1Primitive derObj2 = oAsnInStream2.readObject();
CRLDistPoint distPoint = CRLDistPoint.getInstance(derObj2);
List<String> crlUrls = new ArrayList<>();

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

private KeyTransRecipientInfo computeRecipientInfo(X509Certificate x509certificate, byte[] abyte0)
  throws IOException, CertificateEncodingException, InvalidKeyException,
    BadPaddingException, IllegalBlockSizeException
{
  TBSCertificate certificate;
  try (ASN1InputStream input = new ASN1InputStream(x509certificate.getTBSCertificate()))
  {
    certificate = TBSCertificate.getInstance(input.readObject());
  }
  AlgorithmIdentifier algorithmId = certificate.getSubjectPublicKeyInfo().getAlgorithm();
  IssuerAndSerialNumber serial = new IssuerAndSerialNumber(
      certificate.getIssuer(),
      certificate.getSerialNumber().getValue());
  Cipher cipher;
  try
  {
    cipher = Cipher.getInstance(algorithmId.getAlgorithm().getId(),
        SecurityProvider.getProvider());
  }
  catch (NoSuchAlgorithmException | NoSuchPaddingException e)
  {
    // should never happen, if this happens throw IOException instead
    throw new RuntimeException("Could not find a suitable javax.crypto provider", e);
  }
  cipher.init(1, x509certificate.getPublicKey());
  DEROctetString octets = new DEROctetString(cipher.doFinal(abyte0));
  RecipientIdentifier recipientId = new RecipientIdentifier(serial);
  return new KeyTransRecipientInfo(recipientId, algorithmId, octets);
}

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

try (ASN1InputStream input = new ASN1InputStream(parameters.getEncoded("ASN.1")))
  object = input.readObject();

代码示例来源:origin: stackoverflow.com

Static public DERObject toDERObject(byte[] data) throws IOException
{
  ByteArrayInputStream inStream = new ByteArrayInputStream(data);
  ASN1InputStream DIS = new ASN1InputStream(inStream);
  return DIS.readObject();
}

代码示例来源:origin: CryptoKass/dilithium

public static ASN1Primitive toAsn1Object(byte[] data) throws IOException
{
  ByteArrayInputStream inStream = new ByteArrayInputStream(data);
  ASN1InputStream asnInputStream = new ASN1InputStream(inStream);
  return asnInputStream.readObject();
}

代码示例来源:origin: fr.opensagres.xdocreport.itext-gae/itext-gae

private static DERObject getExtensionValue(X509Certificate cert, String oid) throws IOException {
  byte[] bytes = cert.getExtensionValue(oid);
  if (bytes == null) {
    return null;
  }
  ASN1InputStream aIn = new ASN1InputStream(new ByteArrayInputStream(bytes));
  ASN1OctetString octs = (ASN1OctetString) aIn.readObject();
  aIn = new ASN1InputStream(new ByteArrayInputStream(octs.getOctets()));
  return aIn.readObject();
}

代码示例来源:origin: esig/dss

private static ASN1Sequence getASN1Sequence(byte[] bytes) {
  try (ASN1InputStream input = new ASN1InputStream(bytes)) {
    return (ASN1Sequence) input.readObject();
  } catch (IOException e) {
    throw new DSSException("Unable to retrieve the ASN1Sequence", e);
  }
}

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

private static ASN1Sequence getReq(
  byte[]  r)
  throws IOException
{
  ASN1InputStream aIn = new ASN1InputStream(new ByteArrayInputStream(r));
  return ASN1Sequence.getInstance(aIn.readObject());
}

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

private SubjectPublicKeyInfo getPublicKeyInfo() throws IOException {
  final ByteArrayInputStream bIn = new ByteArrayInputStream(keyPair.getPublic().getEncoded());
  final ASN1InputStream dIn = new ASN1InputStream(bIn);
  
  return new SubjectPublicKeyInfo((ASN1Sequence) dIn.readObject());
}

代码示例来源:origin: stackoverflow.com

import javax.xml.bind.DatatypeConverter;    

byte[] data = DatatypeConverter.parseHexBinary(yourHexString);    
ASN1InputStream s = new ASN1InputStream(new ByteArrayInputStream(data));
ASN1String str = (ASN1String) s.readObject();
System.out.println(str.getString());

相关文章