A Custom AccessController

Contains useful source code for specific use cases.

A Custom AccessController

Postby Development@SIB » Tue May 31, 2011 5:45 pm

Create a custom AccessController implementation, e.g.:

Code: Select all
package com.sibvisions.apps.test;

import ...

public class AppAccessController implements IAccessController
{
   /** the allowed lifecycle objects. */
   private ArrayUtil<String> auAllowedLCO = null;
   
   /**
    * {@inheritDoc}
    */
   public boolean isAllowed(String pLifecycleName)
   {
      //all explicite allowed lifecycle objects are accessible
      if (auAllowedLCO != null)
      {
         return auAllowedLCO.contains(pLifecycleName);
      }
      
      return false;
   }
   
   /**
    * {@inheritDoc}
    */
   public void addAccess(String pLifecycleName)
   {
      if (pLifecycleName == null)
      {
         return;
      }
      
      if (auAllowedLCO == null)
      {
         auAllowedLCO = new ArrayUtil<String>();
      }

      if (!auAllowedLCO.contains(pLifecycleName))
      {
         auAllowedLCO.add(pLifecycleName);
      }
   }
}


Configure the application:

Code: Select all
<?xml version="1.0" encoding="UTF-8"?>

<application>
  <securitymanager>
    <class>com.sibvisions.rad.server.security.DBSecurityManager</class>
    <accesscontroller>com.sibvisions.apps.test.AppAccessController</accesscontroller>
  </securitymanager>

  <datasource>
    <db name="default">
      <driver>org.hsqldb.jdbcDriver</driver>
      <url>jdbc:hsqldb:hsql://localhost/demodb</url>
      <username>sa</username>
      <password></password>
    </db>
  </datasource>
</application>
User avatar
Development@SIB
 
Posts: 311
Joined: Mon Sep 28, 2009 1:54 pm

Return to Code snippets