@Override public int compare(RDN o1, RDN o2) { AttributeTypeAndValue o1First = o1.getFirst(); AttributeTypeAndValue o2First = o2.getFirst(); ASN1ObjectIdentifier o1Type = o1First.getType(); ASN1ObjectIdentifier o2Type = o2First.getType(); Integer o1Rank = dnOrderMap.get(o1Type); Integer o2Rank = dnOrderMap.get(o2Type); if (o1Rank == null) { if (o2Rank == null) { int idComparison = o1Type.getId().compareTo(o2Type.getId()); if (idComparison != 0) { return idComparison; } return String.valueOf(o1Type).compareTo(String.valueOf(o2Type)); } return 1; } else if (o2Rank == null) { return -1; } return o1Rank - o2Rank; } });
private String asString(ASN1Primitive primitive) { if (primitive == null || primitive instanceof ASN1Null) { return ""; } if (primitive instanceof ASN1String) { return ((ASN1String) primitive).getString(); } if (primitive instanceof DERUTCTime) { return ((DERUTCTime) primitive).getAdjustedTime(); } if (primitive instanceof DERGeneralizedTime) { return ((DERGeneralizedTime) primitive).getTime(); } if (primitive instanceof ASN1ObjectIdentifier) { switch (((ASN1ObjectIdentifier) primitive).getId()) { case "1.3.6.1.5.5.7.8.5": return "xmppAddr"; default: return primitive.toString(); } } return primitive.toString(); } }
ecParam = ECNamedCurveTable.getByOID(ecOID); if (ecParam == null) { throw new PEMException("Unable to find EC Parameter for the given curve oid: " + ecOID.getId());
if (ecParam == null) { throw new PEMException("Unable to find EC Parameter for the given curve oid: " + ((ASN1ObjectIdentifier) pemObj).getId());
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); } }
CMSProcessableInputStream(InputStream is) { this(new ASN1ObjectIdentifier(CMSObjectIdentifiers.data.getId()), is); }
private ASN1ObjectIdentifier getHashObjectIdentifier(String algorithm) { switch (algorithm) { case "MD2": return new ASN1ObjectIdentifier(PKCSObjectIdentifiers.md2.getId()); case "MD5": return new ASN1ObjectIdentifier(PKCSObjectIdentifiers.md5.getId()); case "SHA-1": return new ASN1ObjectIdentifier(OIWObjectIdentifiers.idSHA1.getId()); case "SHA-224": return new ASN1ObjectIdentifier(NISTObjectIdentifiers.id_sha224.getId()); case "SHA-256": return new ASN1ObjectIdentifier(NISTObjectIdentifiers.id_sha256.getId()); case "SHA-384": return new ASN1ObjectIdentifier(NISTObjectIdentifiers.id_sha384.getId()); case "SHA-512": return new ASN1ObjectIdentifier(NISTObjectIdentifiers.id_sha512.getId()); default: return new ASN1ObjectIdentifier(algorithm); } } }
byte[] authorityExtensionValue = ext.getExtensionValue(Extension.authorityInfoAccess.getId()); if (authorityExtensionValue == null)
private List<TSDMetas> extractMetas(InputStream stream) { List<TSDMetas> tsdMetasList = new ArrayList<>(); try { CMSTimeStampedData cmsTimeStampedData = new CMSTimeStampedData(stream); TimeStampToken[] tokens = cmsTimeStampedData.getTimeStampTokens(); for (int i = 0; i < tokens.length; i++) { TSDMetas tsdMetas = new TSDMetas(true, tokens[i].getTimeStampInfo().getGenTime(), tokens[i].getTimeStampInfo().getPolicy().getId(), tokens[i].getTimeStampInfo().getSerialNumber(), tokens[i].getTimeStampInfo().getTsa(), tokens[i].getTimeStampInfo().getHashAlgorithm().getAlgorithm().getId()); tsdMetasList.add(tsdMetas); } } catch (Exception ex) { LOG.error("Error in TSDParser.buildMetas {}", ex.getMessage()); tsdMetasList.clear(); } return tsdMetasList; }
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); } }
if (ocspResponderCertificate.getExtensionValue(OCSPObjectIdentifiers.id_pkix_ocsp_nocheck.getId()) != null)
byte[] authorityExtensionValue = cert.getExtensionValue(Extension.authorityInfoAccess.getId()); if (authorityExtensionValue != null)
byte[] extensionValue = certificate.getExtensionValue(Extension.authorityKeyIdentifier.getId()); ASN1OctetString akiOc = ASN1OctetString.getInstance(extensionValue); String aki = DatatypeConverter.printHexBinary(AuthorityKeyIdentifier.getInstance(akiOc.getOctets()).getKeyIdentifier());
System.out.println("certs=" + certs); String hashAlgorithm = timeStampToken.getTimeStampInfo().getMessageImprintAlgOID().getId();
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); }
throws IOException byte[] crldpExt = cert.getExtensionValue(Extension.cRLDistributionPoints.getId()); if (crldpExt == null)
private ASN1Primitive createDERForRecipient(byte[] in, X509Certificate cert) throws IOException, GeneralSecurityException String algorithm = PKCSObjectIdentifiers.RC2_CBC.getId(); AlgorithmParameterGenerator apg; KeyGenerator keygen;