/** * Gets the X509Certificate certificate. * * @return the X509 certificate converted from the base 64 encoded element data * @throws WSSecurityException */ public X509Certificate getX509Certificate(Crypto crypto) throws WSSecurityException { if (cachedCert != null) { return cachedCert; } Crypto certCrypto = crypto; if (certCrypto == null) { certCrypto = new Merlin(); } byte[] data = getToken(); if (data == null) { throw new WSSecurityException( WSSecurityException.ErrorCode.FAILURE, "invalidCertData", new Object[] {"0"}); } try (InputStream in = new ByteArrayInputStream(data)) { cachedCert = certCrypto.loadCertificate(in); return cachedCert; } catch (IOException e) { throw new WSSecurityException( WSSecurityException.ErrorCode.SECURITY_TOKEN_UNAVAILABLE, e, "parseError" ); } }