public UsernameToken(Element element) throws WSSecurityException
{
this.doc = element.getOwnerDocument();
String id = element.getAttributeNS(Constants.WSU_NS, Constants.ID);
if (id == null || id.length() == 0)
throw new WSSecurityException("Invalid message, UsernameToken is missing an id");
setId(id);
Element child = Util.getFirstChildElement(element);
if (child == null || ! Constants.WSSE_NS.equals(child.getNamespaceURI()) || ! "Username".equals(child.getLocalName()))
throw new WSSecurityException("Username child expected in UsernameToken element");
this.username = XMLUtils.getFullTextChildrenFromElement(child);
child = Util.getNextSiblingElement(child);
if (child == null || ! Constants.WSSE_NS.equals(child.getNamespaceURI()) || ! "Password".equals(child.getLocalName()))
throw new WSSecurityException("Password child expected in UsernameToken element");
this.password = XMLUtils.getFullTextChildrenFromElement(child);
String passwordType = child.getAttribute("Type");
this.digest = Constants.PASSWORD_DIGEST_TYPE.equals(passwordType);
Iterator<Element> itNonce = DOMUtils.getChildElements(element, new QName(Constants.WSSE_NS, "Nonce"));
if (itNonce != null && itNonce.hasNext())
{
Element elem = itNonce.next();
String encodingType = elem.getAttribute("EncodingType");
if (encodingType != null && !Constants.BASE64_ENCODING_TYPE.equalsIgnoreCase(encodingType))
throw new WSSecurityException("Unsupported nonce encoding type: " + encodingType);
this.nonce = XMLUtils.getFullTextChildrenFromElement(elem);
}
Iterator<Element> itCreated = DOMUtils.getChildElements(element, new QName(Constants.WSSE_NS, "Created"));
if (itCreated != null && itCreated.hasNext())