protected SimpleAccount getAccount(String username)
{
log.info("get account: " + username);
// just create a dummy. A real app would construct one based on EIS access.
SimpleAccount account = new SimpleAccount(username, "pass", getName());
// simulate some roles and permissions:
account.addRole("user");
if ("admin".equals(username))
{
account.addRole("admin");
}
// most applications would assign permissions to Roles instead of users directly because
// this is much more
// flexible (it is easier to configure roles and then change role-to-user assignments than
// it is to maintain
// permissions for each user).
// But these next lines assign permissions directly to this trivial account object just for
// simulation's sake:
account.addStringPermission("blogEntry:edit"); // this user is allowed to 'edit' _any_
// blogEntry
// fine-grained instance level permission:
account.addStringPermission("printer:print:laserjet2000"); // allowed to 'print' to the
// 'printer' identified
// by the id 'laserjet2000'
account.addStringPermission("view"); // all users have view permission
return account;
}