+ // write roles in profile for easy access
+// if (!(authen instanceof SystemAuthentication)) {
+// Node userProfile = JcrUtils.getUserProfile(getSystemSession(),
+// userId);
+// boolean writeRoles = false;
+// if (userProfile.hasProperty(ArgeoNames.ARGEO_REMOTE_ROLES)) {
+// Value[] roles = userProfile.getProperty(ArgeoNames.ARGEO_REMOTE_ROLES)
+// .getValues();
+// if (roles.length != userGroupIds.size())
+// writeRoles = true;
+// else
+// for (int i = 0; i < roles.length; i++)
+// if (!roles[i].getString().equals(userGroupIds.get(i)))
+// writeRoles = true;
+// } else
+// writeRoles = true;
+//
+// if (writeRoles) {
+// userProfile.getSession().getWorkspace().getVersionManager()
+// .checkout(userProfile.getPath());
+// String[] roleIds = userGroupIds.toArray(new String[userGroupIds
+// .size()]);
+// userProfile.setProperty(ArgeoNames.ARGEO_REMOTE_ROLES, roleIds);
+// JcrUtils.updateLastModified(userProfile);
+// userProfile.getSession().save();
+// userProfile.getSession().getWorkspace().getVersionManager()
+// .checkin(userProfile.getPath());
+// }
+// }
+