@Override
@SuppressWarnings("unchecked")
public User read(ObjectDataInput in) throws IOException {
Object[] entity = super.readEntity(in);
String login = in.readUTF();
String password = in.readUTF();
boolean active = in.readBoolean();
List<Permission> perms = (List<Permission>) in.readObject();
Set<String> roles = (Set<String>) in.readObject();
Map<String, Permission> mPerms = new HashMap<String, Permission>(perms.size());
for (Permission xpm: perms) {
mPerms.put(xpm.getResource(), xpm);
}
User xUser = new User(
(int) entity[0],
(Date) entity[1],
(String) entity[2],
mPerms,
roles,
login,
password,
active);
return xUser;
}