Dashboard > WG: Programmer's Cafe > ... > Sakai Framework Tips > Using the FunctionManager Service
  WG: Programmer's Cafe Log In | Signup View a printable version of the current page.  
  Using the FunctionManager Service
Added by Aaron Zeckoski, last edited by Aaron Zeckoski on Nov 06, 2006  (view change)
Labels: 
(None)

Information

This explains basic usage of the Sakai FunctionManager Service. This service is used to register new Authz (permission) groups.

Accessing the FunctionManager

  • You can use Spring Framework to inject the service or use the cover
  1. Using Spring to get the service for your class (e.g. YourAppClass) (recommended)
    1. Add the FunctionManager bean to the bean for YourAppClass
      <bean id="org.sakaiproject.yourapp.logic.YourAppClass"
      		class="org.sakaiproject.yourapp.logic.impl.YourAppClassImpl">
      	<property name="functionManager"
      		ref="org.sakaiproject.authz.api.FunctionManager" />
      </bean>
    2. Add a variable and setter to YourAppClass to use the service in like so:
      private FunctionManager functionManager;
      public void setFunctionManager(FunctionManager functionManager) {
      	this.functionManager = functionManager;
      }
  2. Using the cover to get the service
    • Note: This is not the recommended method, you should be using Spring to inject the service
    1. Setup a variable to hold the instance from the cover
      private FunctionManager functionManager;
    2. Get access to the service using the cover
      functionManager = org.sakaiproject.authz.cover.FunctionManager.getInstance();

Registering a new permission with the Sakai security system

  • Note: This will cause the permission to appear in the list of perms in Realms
  1. Create a static final String to store the name of the permission
    • Note: This is partially so you can access this string from elsewhere in your app (if needed)
      public final static String TOOL_PERM_NAME = "toolname.perm.name";
  2. Use the FunctionManager to register the permission with the security system when your class initializes
    public void init() {
    	functionManager.registerFunction(TOOL_PERM_NAME);
    }
    • Note: Recommend that you place this in the init function of a business logic class (or service)

Site running on a free Atlassian Confluence Open Source Project License granted to Sakai Foundation. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.5 Build:#811 Jul 25, 2007) - Bug/feature request - Contact Administrators