/** * Adds and optionally creates a Salt element to this UsernameToken. * * If the <code>saltValue</code> is <code>null</code> the the method * generates a new salt. Otherwise it uses the the given value. * * @param doc The Document for the UsernameToken * @param saltValue The salt to add, if null generate a new salt value * @param mac If <code>true</code> then an optionally generated value is * usable for a MAC * @return Returns the added salt */ public byte[] addSalt(Document doc, byte[] saltValue, boolean mac) { if (saltValue == null) { saltValue = generateSalt(mac); } elementSalt = doc.createElementNS( WSConstants.WSSE11_NS, WSConstants.WSSE11_PREFIX + ":" + WSConstants.SALT_LN ); WSSecurityUtil.setNamespace(element, WSConstants.WSSE11_NS, WSConstants.WSSE11_PREFIX); elementSalt.appendChild(doc.createTextNode(Base64.encode(saltValue))); element.appendChild(elementSalt); return saltValue; }
/** * Adds and optionally creates a Salt element to this UsernameToken. * * If the <code>saltValue</code> is <code>null</code> the the method * generates a new salt. Otherwise it uses the the given value. * * @param doc The Document for the UsernameToken * @param saltValue The salt to add, if null generate a new salt value * @param mac If <code>true</code> then an optionally generated value is * usable for a MAC * @return Returns the added salt */ public byte[] addSalt(Document doc, byte[] saltValue, boolean mac) { if (saltValue == null) { saltValue = generateSalt(mac); } elementSalt = doc.createElementNS( WSConstants.WSSE11_NS, WSConstants.WSSE11_PREFIX + ":" + WSConstants.SALT_LN ); WSSecurityUtil.setNamespace(element, WSConstants.WSSE11_NS, WSConstants.WSSE11_PREFIX); elementSalt.appendChild(doc.createTextNode(Base64.encode(saltValue))); element.appendChild(elementSalt); return saltValue; }