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);
}