public void marshall(XMLStreamWriter wrt, UserDetails value) throws Exception { // write out the userdetails element.. wrt.writeStartElement("userdetails"); if (value != null) { // marshall the token using the XMLTokenMarshaller.. Token token = value.getToken(); XMLTokenMarshaller mar = new XMLTokenMarshaller(); mar.marshall(wrt, token); // write each of the roles.. String[] values = value.getRoles(); for (int i = 0; (values != null && i < values.length); i++) { String role = values[i]; wrt.writeStartElement("role"); wrt.writeAttribute("id", role); wrt.writeEndElement(); } // write each of the attributes XMLAttributeMarshaller attrMarshaller = new XMLAttributeMarshaller(); Attribute[] vals = value.getAttributes(); for (int i = 0; (vals != null && i < vals.length); i++) { Attribute attr = vals[i]; attrMarshaller.marshall(wrt, attr); } } // end the userdetails.. wrt.writeEndElement(); }
public void marshall(XMLStreamWriter wrt, IdentityDetails value) throws Exception { // write out the identitydetails element.. wrt.writeStartElement("identitydetails"); if (value != null) { // marshall the name. String name = value.getName(); wrt.writeStartElement("name"); wrt.writeAttribute("value", name); wrt.writeEndElement(); // marshall the identity type String identityType = value.getType(); wrt.writeStartElement("type"); wrt.writeAttribute("value", identityType); wrt.writeEndElement(); // marshall the realm String realm = value.getRealm(); wrt.writeStartElement("realm"); wrt.writeAttribute("value", realm); wrt.writeEndElement(); // write the roles. String[] roles = value.getRoles(); for (int i = 0; (roles != null && i < roles.length); i++) { wrt.writeStartElement("role"); wrt.writeAttribute("id", roles[i]); wrt.writeEndElement(); } // write the groups. String[] groups = value.getGroups(); for (int i = 0; (groups != null && i < groups.length); i++) { wrt.writeStartElement("group"); wrt.writeAttribute("id", groups[i]); wrt.writeEndElement(); } // write the memberships. String[] members = value.getMembers(); for (int i = 0; (members != null && i < members.length); i++) { wrt.writeStartElement("member"); wrt.writeAttribute("id", members[i]); wrt.writeEndElement(); } // write each of the attributes XMLAttributeMarshaller attrMarshaller = new XMLAttributeMarshaller(); Attribute[] vals = value.getAttributes(); for (int i = 0; ((vals != null) && (i < vals.length)); i++) { Attribute attr = vals[i]; attrMarshaller.marshall(wrt, attr); } } // end the identitydetails.. wrt.writeEndElement(); }