/** * Sets the X509Certificate. * This functions takes the X509 certificate, gets the data from it as * encoded bytes, and sets the data as base 64 encoded data in the text * node of the element * * @param cert the X509 certificate to store in the element * @throws WSSecurityException */ public void setX509Certificate(X509Certificate cert) throws WSSecurityException { if (cert == null) { throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "noCert"); } cachedCert = cert; try { setToken(cert.getEncoded()); } catch (CertificateEncodingException e) { throw new WSSecurityException( WSSecurityException.ErrorCode.SECURITY_TOKEN_UNAVAILABLE, e, "encodeError" ); } } }