Logger log = getLogger(); if (DIRECTORY_ALT_NAME.equals(nameType) || DNS_ALT_NAME.equals(nameType) || RFC822_ALT_NAME.equals(nameType) || URI_ALT_NAME.equals(nameType) || REGISTERED_ID_ALT_NAME.equals(nameType)) {
Logger log = getLogger(); if (DIRECTORY_ALT_NAME.equals(nameType) || DNS_ALT_NAME.equals(nameType) || RFC822_ALT_NAME.equals(nameType) || URI_ALT_NAME.equals(nameType) || REGISTERED_ID_ALT_NAME.equals(nameType)) {
Logger log = getLogger(); if (certificate == null) { return null;
Logger log = getLogger(); if (certificate == null) { return null;
/** * Get the XML Signature-compliant digest of an X.509 certificate. * * @param certificate an X.509 certificate * @param algorithmURI URI of digest algorithm to apply * @return the raw digest of the certificate * @throws SecurityException is algorithm is unsupported or encoding is not possible */ public static byte[] getX509Digest(X509Certificate certificate, String algorithmURI) throws SecurityException { Logger log = getLogger(); String alg = SecurityHelper.getAlgorithmIDFromURI(algorithmURI); if (alg == null) { log.error("Algorithm {} is unsupported", algorithmURI); throw new SecurityException("Algorithm " + algorithmURI + " is unsupported"); } try { MessageDigest hasher = MessageDigest.getInstance(alg); return hasher.digest(certificate.getEncoded()); } catch (CertificateEncodingException e) { log.error("Unable to encode certificate for digest operation", e); throw new SecurityException("Unable to encode certificate for digest operation", e); } catch (NoSuchAlgorithmException e) { log.error("Algorithm {} is unsupported", alg); throw new SecurityException("Algorithm " + alg + " is unsupported", e); } }
/** * Get the XML Signature-compliant digest of an X.509 certificate. * * @param certificate an X.509 certificate * @param algorithmURI URI of digest algorithm to apply * @return the raw digest of the certificate * @throws SecurityException is algorithm is unsupported or encoding is not possible */ public static byte[] getX509Digest(X509Certificate certificate, String algorithmURI) throws SecurityException { Logger log = getLogger(); String alg = SecurityHelper.getAlgorithmIDFromURI(algorithmURI); if (alg == null) { log.error("Algorithm {} is unsupported", algorithmURI); throw new SecurityException("Algorithm " + algorithmURI + " is unsupported"); } try { MessageDigest hasher = MessageDigest.getInstance(alg); return hasher.digest(certificate.getEncoded()); } catch (CertificateEncodingException e) { log.error("Unable to encode certificate for digest operation", e); throw new SecurityException("Unable to encode certificate for digest operation", e); } catch (NoSuchAlgorithmException e) { log.error("Algorithm {} is unsupported", alg); throw new SecurityException("Algorithm " + alg + " is unsupported", e); } }
/** * Get the plain (non-DER encoded) value of the Subject Key Identifier extension of an X.509 certificate, if * present. * * @param certificate an X.509 certificate possibly containing a subject key identifier * @return the plain (non-DER encoded) value of the Subject Key Identifier extension, or null if the certificate * does not contain the extension * @throws IOException */ public static byte[] getSubjectKeyIdentifier(X509Certificate certificate) { Logger log = getLogger(); byte[] derValue = certificate.getExtensionValue(SKI_OID); if (derValue == null || derValue.length == 0) { return null; } try { final ASN1Primitive ski = X509ExtensionUtil.fromExtensionValue(derValue); return ((DEROctetString) ski).getOctets(); } catch (IOException e) { log.error("Unable to extract subject key identifier from certificate: ASN.1 parsing failed: " + e); return null; } }
/** * Get the plain (non-DER encoded) value of the Subject Key Identifier extension of an X.509 certificate, if * present. * * @param certificate an X.509 certificate possibly containing a subject key identifier * @return the plain (non-DER encoded) value of the Subject Key Identifier extension, or null if the certificate * does not contain the extension * @throws IOException */ public static byte[] getSubjectKeyIdentifier(X509Certificate certificate) { Logger log = getLogger(); byte[] derValue = certificate.getExtensionValue(Extension.subjectKeyIdentifier.getId()); if (derValue == null || derValue.length == 0) { return null; } SubjectKeyIdentifier ski = null; try { ski = new SubjectKeyIdentifierStructure(derValue); return ski.getKeyIdentifier(); } catch (IOException e) { log.error("Unable to extract subject key identifier from certificate: ASN.1 parsing failed: " + e); return null; } }
Logger log = getLogger(); if (dn == null) { return null;
Logger log = getLogger(); if (dn == null) { return null;