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

x33g5p2x  于11个月前 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(49)

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

ASN1OctetString.getOctets介绍

[英]Return the content of the OCTET STRING as a byte array.
[中]以字节数组的形式返回八位字节字符串的内容。

代码示例

代码示例来源: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: org.apache.poi/poi-ooxml

if (2 == derTaggedObject.getTagNo()) {
  ASN1OctetString keyHashOctetString = (ASN1OctetString)derTaggedObject.getObject();
  byte key[] = keyHashOctetString.getOctets();
  responderId.setByKey(key);
} else {

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

private AuthorityKeyIdentifier getAKI() throws HFCACertificateException {
    if (x509Cert == null) {
      throw new HFCACertificateException("Certificate is null");
    }
    byte[] fullExtValue = x509Cert.getExtensionValue(Extension.authorityKeyIdentifier.getId());
    byte[] extValue = ASN1OctetString.getInstance(fullExtValue).getOctets();
    return AuthorityKeyIdentifier.getInstance(extValue);
  }
}

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

String aki = DatatypeConverter.printHexBinary(AuthorityKeyIdentifier.getInstance(akiOc.getOctets()).getKeyIdentifier());

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

public byte[] getKeyIdentifier()
{
  if (keyidentifier != null)
  {
    return keyidentifier.getOctets();
  }
  return null;
}

代码示例来源:origin: com.itextpdf/itextpdf

/**
 * Gets a String from an ASN1Primitive
 * @param names    the ASN1Primitive
 * @return    a human-readable String
 * @throws IOException
 */
private static String getStringFromGeneralName(ASN1Primitive names) throws IOException {
  ASN1TaggedObject taggedObject = (ASN1TaggedObject) names ;
  return new String(ASN1OctetString.getInstance(taggedObject, false).getOctets(), "ISO-8859-1");
}

代码示例来源:origin: com.github.librepdf/openpdf

private static String getStringFromGeneralName(ASN1Primitive names)
  throws IOException {
 DERTaggedObject taggedObject = (DERTaggedObject) names;
 return new String(ASN1OctetString.getInstance(taggedObject, false)
   .getOctets(), StandardCharsets.ISO_8859_1);
}

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

/**
 * @deprecated Will be removed
 */
public X9FieldElement(int m, int k1, int k2, int k3, ASN1OctetString s)
{
  this(new ECFieldElement.F2m(m, k1, k2, k3, new BigInteger(1, s.getOctets())));
}

代码示例来源:origin: com.itextpdf/sign

/**
 * Gets a String from an ASN1Primitive
 * @param names    the ASN1Primitive
 * @return    a human-readable String
 * @throws IOException
 */
private static String getStringFromGeneralName(ASN1Primitive names) throws IOException {
  ASN1TaggedObject taggedObject = (ASN1TaggedObject) names ;
  return new String(ASN1OctetString.getInstance(taggedObject, false).getOctets(), "ISO-8859-1");
}

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

public static byte[] getOctetStringBytes(final ASN1Encodable object)
    throws BadAsn1ObjectException {
  try {
    return DEROctetString.getInstance(object).getOctets();
  } catch (IllegalArgumentException ex) {
    throw new BadAsn1ObjectException("invalid object OctetString: " + ex.getMessage(), ex);
  }
}

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

private McEliecePublicKey(ASN1Sequence seq)
{
  BigInteger bigN = ((ASN1Integer)seq.getObjectAt(0)).getValue();
  n = bigN.intValue();
  BigInteger bigT = ((ASN1Integer)seq.getObjectAt(1)).getValue();
  t = bigT.intValue();
  g = new GF2Matrix(((ASN1OctetString)seq.getObjectAt(2)).getOctets());
}

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

private ASN1Encodable getExtensionValue(X509Extension extensions, String oid) throws CryptoException {
    byte[] octets = ASN1OctetString.getInstance(extensions.getExtensionValue(oid)).getOctets();
    try (ASN1InputStream ais = new ASN1InputStream(octets)) {
      return ais.readObject();
    } catch (IOException ex) {
      throw new CryptoException(res.getString("CertificateGenFailed.exception.message"), ex);
    }
  }
}

代码示例来源:origin: be.fedict.eid-applet/eid-applet-service-signer

private byte[] getSubjectKeyId(X509Certificate cert) throws IOException {
  byte[] extvalue = cert.getExtensionValue(X509Extensions.SubjectKeyIdentifier.getId());
  if (extvalue == null) {
    return null;
  }
  ASN1OctetString str = ASN1OctetString
      .getInstance(new ASN1InputStream(new ByteArrayInputStream(extvalue)).readObject());
  SubjectKeyIdentifier keyId = SubjectKeyIdentifier
      .getInstance(new ASN1InputStream(new ByteArrayInputStream(str.getOctets())).readObject());
  return keyId.getKeyIdentifier();
}

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

public static byte[] getCoreExtValue(X509AttributeCertificateHolder cert,
  ASN1ObjectIdentifier type) throws CertificateEncodingException {
 Args.notNull(cert, "cert");
 Args.notNull(type, "type");
 Extension ext = cert.getExtension(type);
 if (ext == null) {
  return null;
 }
 return ext.getExtnValue().getOctets();
}

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

public static byte[] getCoreExtValue(final X509AttributeCertificateHolder cert,
    final ASN1ObjectIdentifier type) throws CertificateEncodingException {
  ParamUtil.requireNonNull("cert", cert);
  ParamUtil.requireNonNull("type", type);
  Extension ext = cert.getExtension(type);
  if (ext == null) {
    return null;
  }
  return ext.getExtnValue().getOctets();
}

代码示例来源:origin: org.apache.wss4j/wss4j-ws-security-common

public static byte[] getSubjectKeyIdentifierBytes(X509Certificate cert) {
  byte[] extensionValue = cert.getExtensionValue("2.5.29.14"); //NOPMD
  if (extensionValue != null) {
    byte[] subjectOctets =
      ASN1OctetString.getInstance(extensionValue).getOctets();
    SubjectKeyIdentifier subjectKeyIdentifier =
      SubjectKeyIdentifier.getInstance(subjectOctets);
    return subjectKeyIdentifier.getKeyIdentifier();
  }
  return null;
}

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

private EnvelopedData getEnvelopedData(DEREncodable content) throws IOException {
  // According to PKCS #9, data consists of an octet string.
  final ASN1OctetString octetString = (ASN1OctetString) content;
  final byte[] octets = octetString.getOctets();
  final ContentInfo contentInfo = ContentInfo.getInstance(ASN1Object.fromByteArray(octets));
  final DERObjectIdentifier contentType = contentInfo.getContentType();
  
  if (contentType.equals(CMSObjectIdentifiers.envelopedData) == false) {
    LOGGER.warning("Expected envelopedData ContentInfo, was " + contentType);
  }
  
  return new EnvelopedData((ASN1Sequence) contentInfo.getContent());
}

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

private String getCertificateSKI(String alias, KeyStore keyStore) throws CryptoException, KeyStoreException {
  X509Certificate x509Cert = getCertificate(alias, keyStore);
  try {
    byte[] skiValue = x509Cert.getExtensionValue(Extension.subjectKeyIdentifier.getId());
    byte[] octets = DEROctetString.getInstance(skiValue).getOctets();
    byte[] skiBytes = SubjectKeyIdentifier.getInstance(octets).getKeyIdentifier();
    return HexUtil.getHexString(skiBytes);
  } catch (Exception e) {
    return "-";
  }
}

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

private String getCertificateAKI(String alias, KeyStore keyStore) throws CryptoException, KeyStoreException {
  X509Certificate x509Cert = getCertificate(alias, keyStore);
  try {
    byte[] akiValue = x509Cert.getExtensionValue(Extension.authorityKeyIdentifier.getId());
    byte[] octets = DEROctetString.getInstance(akiValue).getOctets();
    byte[] akiBytes = AuthorityKeyIdentifier.getInstance(octets).getKeyIdentifier();
    return HexUtil.getHexString(akiBytes);
  } catch (Exception e) {
    return "-";
  }
}

代码示例来源:origin: org.xipki.p11proxy/p11proxy-common

private Asn1ImportSecretKeyParams(ASN1Sequence seq) throws BadAsn1ObjectException {
 Asn1Util.requireRange(seq, 4, 4);
 int idx = 0;
 slotId = Asn1P11SlotIdentifier.getInstance(seq.getObjectAt(idx++)).getValue();
 control = Asn1NewKeyControl.getInstance(seq.getObjectAt(idx++)).getControl();
 keyType = Asn1Util.getInteger(seq.getObjectAt(idx++)).longValue();
 keyValue = ASN1OctetString.getInstance(seq.getObjectAt(idx++)).getOctets();
}

相关文章