Refine search
@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(); }
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); } }
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); } }
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); } }
try ( final ASN1InputStream decoder = new ASN1InputStream( item ) ) final ASN1Primitive object = decoder.readObject(); final ASN1Sequence otherNameSeq = (ASN1Sequence) object;
try (ASN1InputStream asn1 = new ASN1InputStream(sigData.getEncoded())) { DEROutputStream dos = new DEROutputStream(out); dos.writeObject(asn1.readObject());
try ( final ASN1InputStream decoder = new ASN1InputStream( (byte[]) value ) ) final ASN1Primitive object = decoder.readObject(); final ASN1Sequence otherNameSeq = (ASN1Sequence) object;
ASN1InputStream bIn = new ASN1InputStream(new ByteArrayInputStream(data)); ASN1Primitive obj = bIn.readObject(); System.out.println(ASN1Dump.dumpAsString(obj));
/** * 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); } }
ASN1InputStream asnInputStream = new ASN1InputStream(inStream); ASN1Primitive asn1 = asnInputStream.readObject();
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<>();
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); }
try (ASN1InputStream input = new ASN1InputStream(parameters.getEncoded("ASN.1"))) object = input.readObject();
Static public DERObject toDERObject(byte[] data) throws IOException { ByteArrayInputStream inStream = new ByteArrayInputStream(data); ASN1InputStream DIS = new ASN1InputStream(inStream); return DIS.readObject(); }
public static ASN1Primitive toAsn1Object(byte[] data) throws IOException { ByteArrayInputStream inStream = new ByteArrayInputStream(data); ASN1InputStream asnInputStream = new ASN1InputStream(inStream); return asnInputStream.readObject(); }
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(); }
private static ASN1Sequence getReq( byte[] r) throws IOException { ASN1InputStream aIn = new ASN1InputStream(new ByteArrayInputStream(r)); return ASN1Sequence.getInstance(aIn.readObject()); }
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()); }
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); } }
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());