public static Identity createIdentity(Representation entity)
throws IOException,XMLException
{
XMLRepresentationParser parser = new XMLRepresentationParser();
Document doc = parser.load(entity);
String session = doc.getDocumentElement().getAttributeValue("id");
String id = doc.getDocumentElement().getAttributeValue("user-id");
String alias = doc.getDocumentElement().getAttributeValue("user-alias");
Element nameE = doc.getDocumentElement().getFirstElementNamed(IdentityFilter.NAME);
Element emailE = doc.getDocumentElement().getFirstElementNamed(IdentityFilter.EMAIL);
Identity identity = new Identity(session,id,alias,nameE==null ? null : nameE.getText(),emailE==null ? null : emailE.getText());
Iterator<Element> roles = doc.getDocumentElement().getElementsByName(IdentityFilter.ROLE);
while (roles.hasNext()) {
Element role = roles.next();
UUID rid = UUID.fromString(role.getAttributeValue("id"));
String name = role.getAttributeValue("name");
if (identity.roles==null) {
identity.roles = new TreeMap<UUID,String>();
}
identity.roles.put(rid,name);
}
Iterator<Element> groups = doc.getDocumentElement().getElementsByName(IdentityFilter.GROUP);
while (groups.hasNext()) {
Element group = groups.next();
UUID gid = UUID.fromString(group.getAttributeValue("id"));
String galias = group.getAttributeValue("alias");
if (identity.groups==null) {