Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

5.3 Add new UserManager methods

...

Here are the new methods to be added to UserManager:

Code Block

// Provide a way for the Roller front-end to check any type of permission for a user.

...

Code Block
public boolean checkPermission(RollerPermission perm, User user);

For example, if you want to check to see if a user has can post a weblog entry, you would do this:

Code Block

WeblogPermssion desiredPerm = new WeblogPermission(weblog, "post");
boolean allowed = userManager.checkPermssion(desiredPerm, user);

Roller will look up the WeblogPermission object for the specified user and weblog and will return true if the "post" action is in the permission's action list.

Next, we need to provide a way for the Roller front-end to grant and revoke roles because roles imply global permissions.

Code Block

public void grantRole(String roleName, User user);
public void revokeRole(String roleName, User user);

The Roller front-end also needs to be able to grant and revoke weblog permissions:

Code Block

public void grantWeblogPermission(WeblogPermission perm, 
// A way for the Roller front-end to grant and revoke roles because roles imply global permissions
public void grantRole(String roleName, User user);
public void revokeRole(String roleName, User user);

// The Roller front-end also needs to be able to grant and revoke weblog permissions
public void grantWeblogPermission(WeblogPermission perm, User user);
public void revokeWeblogPermission(WeblogPermssion perm, User user);

// and to display the roles and permissions associated with each user:
public List<String> getRoles(User user);
public List<WeblogPermission> getWeblogPermssions(User user);
public void revokeWeblogPermission(WeblogPermssion perm, User userList<WeblogPermission> getWeblogPermssions(Weblog weblog);

And finally, the front-end needs to be able to display the roles and permissions associated with each userFor example, if you want to check to see if a user has can post a weblog entry, you would do this:

Code Block
publicWeblogPermssion List<String>desiredPerm getRoles(User user);
public List<WeblogPermission> getWeblogPermssions(User user);
public List<WeblogPermission> getWeblogPermssions(Weblog weblog);
= new WeblogPermission(weblog, "post");
boolean allowed = userManager.checkPermssion(desiredPerm, user);

Roller will look up the WeblogPermission object for the specified user and weblog and will return true if the "post" action is in the permission's action list.

5.4 Implementation of new UserManagement permissions methods

...