private static X509Certificate getCertificate(String filePath) { ClassLoader loader = Thread.currentThread().getContextClassLoader(); try { byte[] bytes = IOUtils.resourceToByteArray(filePath, loader); return X509CertUtils.parse(bytes); } catch (IOException e) { log.debug(e.getMessage()); } return null; }
public static String getCertificateByName(String filename) { ClassLoader loader = Thread.currentThread().getContextClassLoader(); try { byte[] bytes = IOUtils.resourceToByteArray("certificates/" + filename, loader); X509Certificate cert = X509CertUtils.parse(bytes); return X509CertUtils.toPEMString(cert); } catch (IOException e) { log.debug(e.getMessage()); } return null; }
/** * Returns the specified X.509 certificate as PEM-encoded string. * * @param cert The X.509 certificate. Must not be {@code null}. * * @return The PEM-encoded X.509 certificate, {@code null} if encoding * failed. */ public static String toPEMString(final X509Certificate cert) { return toPEMString(cert, true); }
private static X509Certificate getCertificate(String filePath) { ClassLoader loader = Thread.currentThread().getContextClassLoader(); try { byte[] bytes = IOUtils.resourceToByteArray(filePath, loader); return X509CertUtils.parse(bytes); } catch (IOException e) { log.debug(e.getMessage()); } return null; }
public static String getCertificateByName(String filename) { ClassLoader loader = Thread.currentThread().getContextClassLoader(); try { byte[] bytes = IOUtils.resourceToByteArray("certificates/" + filename, loader); X509Certificate cert = X509CertUtils.parse(bytes); return X509CertUtils.toPEMString(cert); } catch (IOException e) { log.debug(e.getMessage()); } return null; }
X509Certificate cert = X509CertUtils.parse(b64List.get(i).decode());
/** * Parses a PEM-encoded X.509 certificate. * * @param pemEncodedCert The PEM-encoded X.509 certificate, as a * string. May be {@code null}. * * @return The X.509 certificate, {@code null} if parsing failed. */ public static X509Certificate parse(final String pemEncodedCert) { if (pemEncodedCert == null || pemEncodedCert.isEmpty()) { return null; } final int markerStart = pemEncodedCert.indexOf(PEM_BEGIN_MARKER); if (markerStart < 0) { return null; } String buf = pemEncodedCert.substring(markerStart + PEM_BEGIN_MARKER.length()); final int markerEnd = buf.indexOf(PEM_END_MARKER); if (markerEnd < 0) { return null; } buf = buf.substring(0, markerEnd); buf = buf.replaceAll("\\s", ""); return parse(new Base64(buf).decode()); }
/** * signature should not be null signature should be conform with psd2 * addition signature should be verifiable by the entry certificate * * @param signature Signature to verify * @return true if signature is correct, false otherwise */ public boolean verifySignature(String signature, String tppEncodedCert, Map<String, String> headers) throws NoSuchAlgorithmException, SignatureException, IOException { if (StringUtils.isBlank(signature)) { throw new IllegalArgumentException("SIGNATURE_MISSING"); } if (StringUtils.isBlank(tppEncodedCert)) { throw new IllegalArgumentException("CERTIFICAT_MISSING"); } Signature signatureData = Signature.fromString(signature); if (!signatureData.getHeaders().containsAll(MANDATORY_HEADERS_PSD2)) { throw new IllegalArgumentException("SIGNATURE_INVALID"); } X509Certificate cert = X509CertUtils.parse(tppEncodedCert); PublicKey key = cert.getPublicKey(); SignatureVerifier verifier = new SignatureVerifier(key, signatureData); return verifier.verify("method", "uri", headers); }
/** * signature should not be null signature should be conform with psd2 * addition signature should be verifiable by the entry certificate * * @param signature Signature to verify * @return true if signature is correct, false otherwise */ public boolean verifySignature(String signature, String tppEncodedCert, Map<String, String> headers) throws NoSuchAlgorithmException, SignatureException, IOException { if (StringUtils.isBlank(signature)) { throw new IllegalArgumentException("SIGNATURE_MISSING"); } if (StringUtils.isBlank(tppEncodedCert)) { throw new IllegalArgumentException("CERTIFICAT_MISSING"); } Signature signatureData = Signature.fromString(signature); if (!signatureData.getHeaders().containsAll(MANDATORY_HEADERS_PSD2)) { throw new IllegalArgumentException("SIGNATURE_INVALID"); } X509Certificate cert = X509CertUtils.parse(tppEncodedCert); PublicKey key = cert.getPublicKey(); SignatureVerifier verifier = new SignatureVerifier(key, signatureData); return verifier.verify("method", "uri", headers); }
throws JOSEException { X509Certificate cert = X509CertUtils.parse(pemEncodedCert);
public boolean validate(String encodedCert) throws CertificateException, CertificateValidationException { if (StringUtils.isBlank(encodedCert)) { throw new FailedCertValidationException(CertificateErrorMsgCode.CERTIFICATE_MISSING.name(), CertificateErrorMsgCode.CERTIFICATE_MISSING.toString()); } X509Certificate cert = X509CertUtils.parse(encodedCert); if(cert == null) { throw new FailedCertValidationException(CertificateErrorMsgCode.CERTIFICATE_MISSING.name(), CertificateErrorMsgCode.CERTIFICATE_MISSING.toString()); } validator.validate(cert); return true; } }
public boolean validate(String encodedCert) throws CertificateException, CertificateValidationException { if (StringUtils.isBlank(encodedCert)) { throw new FailedCertValidationException(CertificateErrorMsgCode.CERTIFICATE_MISSING.name(), CertificateErrorMsgCode.CERTIFICATE_MISSING.toString()); } X509Certificate cert = X509CertUtils.parse(encodedCert); if(cert == null) { throw new FailedCertValidationException(CertificateErrorMsgCode.CERTIFICATE_MISSING.name(), CertificateErrorMsgCode.CERTIFICATE_MISSING.toString()); } validator.validate(cert); return true; } }
public static TppCertificateData extract(String encodedCert) throws CertificateValidationException { X509Certificate cert = X509CertUtils.parse(encodedCert);
public static TppCertificateData extract(String encodedCert) throws CertificateValidationException { X509Certificate cert = X509CertUtils.parse(encodedCert);