QName wsuIDQName = new QName(WSU_NS, ID, WSU_PREFIX);
StaxUtil.writeNameSpace(writer, WSU_PREFIX, WSU_NS);
StaxUtil.writeAttribute(writer, wsuIDQName, id);
AttributedString userNameAttr = usernameToken.getUsername();
if (userNameAttr == null)
throw logger.nullValueError("User Name is null on the UsernameToken");
StaxUtil.writeStartElement(writer, WSSE_PREFIX, USERNAME, WSSE_NS);
StaxUtil.writeCharacters(writer, userNameAttr.getValue());
StaxUtil.writeEndElement(writer);
StaxUtil.writeEndElement(writer);
StaxUtil.flush(writer);
}