public <T extends CellComponentServerState> T
getDefaultCellComponentServerState() {
SecurityComponentServerState state = new SecurityComponentServerState();
CellPermissions perms = new CellPermissions();
// add the current user as an owner
ServerSessionManager primarySM = LoginManager.getPrimary();
if (primarySM != null) {
WonderlandSession primarySession = primarySM.getPrimarySession();
if (primarySession != null) {
Principal owner = new Principal(
primarySession.getUserID().getUsername(),
Principal.Type.USER);
perms.getOwners().add(owner);
}
}
// add view permissions for all users
Principal p = new Principal("users", Principal.Type.EVERYBODY);
ActionDTO view = new ActionDTO(new ViewAction());
perms.getPermissions().add(new Permission(
p, view, Permission.Access.GRANT));
ActionDTO modify = new ActionDTO(new ModifyAction());
perms.getPermissions().add(new Permission(
p, modify, Permission.Access.DENY));
state.setPermissions(perms);
return (T) state;
}