public void marshall(PrintWriter wrt, String prefix, IdentityDetails details) throws Exception { String prfx = prefix + "identitydetails."; if (details != null) { // write the name wrt.print(prfx); wrt.print("name="); wrt.println(details.getName()); // write the identity type wrt.print(prfx); wrt.print("type="); wrt.println(details.getType()); // write the realm wrt.print(prfx); wrt.print("realm="); wrt.println(details.getRealm()); // write the roles. String[] roles = details.getRoles(); for (int i = 0; (roles != null && i < roles.length); i++) { // add prefix to denote a parent object.. wrt.print(prfx); wrt.print("role="); wrt.println(roles[i]); } // write the groups. String[] groups = details.getGroups(); for (int i = 0; (groups != null && i < groups.length); i++) { // add prefix to denote a parent object.. wrt.print(prfx); wrt.print("group="); wrt.println(groups[i]); } // write the members. String[] members = details.getMembers(); for (int i = 0; (members != null && i < members.length); i++) { // add prefix to denote a parent object.. wrt.print(prfx); wrt.print("member="); wrt.println(members[i]); } // write the attributes.. PropertiesAttributeMarshaller attrMarshaller = new PropertiesAttributeMarshaller(); Attribute[] atts = details.getAttributes(); for (int i = 0; ((atts != null) && (i < atts.length)); i++) { Attribute attr = atts[i]; wrt.print(prfx); wrt.println("attribute="); attrMarshaller.marshall(wrt, prfx, attr); } } }
public void marshall(PrintWriter wrt, String prefix, UserDetails ud) throws Exception { String prfx = prefix + "userdetails."; if (ud != null) { // write the token.. PropertiesTokenMarshaller tokenMarshaller = new PropertiesTokenMarshaller(); tokenMarshaller.marshall(wrt, prfx, ud.getToken()); // write the roles.. String[] rols = ud.getRoles(); for (int i = 0; (rols != null && i < rols.length); i++) { String v = rols[i]; // add prefix to denote a parent object.. wrt.print(prfx); wrt.print("role="); wrt.println(v); } // write the attributes.. PropertiesAttributeMarshaller attrMarshaller = new PropertiesAttributeMarshaller(); Attribute[] atts = ud.getAttributes(); for (int i = 0; (atts != null && i < atts.length); i++) { Attribute attr = atts[i]; attrMarshaller.marshall(wrt, prfx, attr); } } }