Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

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)
  • No labels