Skip to content

Creating your own security access manager

The security access manager is used by OpenKM to check a user’s security access level for nodes.

Conditions:

  • The new Principal Adapter class must implement the “DbAccessManager” interface.
  • The new Principal Adapter class must be declared under the package “com.openkm.plugin.access”.
  • The new Principal Adapter class must be annotated with@PluginImplementation”.
  • The new Principal Adapter class must extend “BasePlugin”.

Security access manager interface:

package com.openkm.plugin.access;
import com.openkm.core.AccessDeniedException;
import com.openkm.core.DatabaseException;
import com.openkm.core.PathNotFoundException;
import com.openkm.db.bean.NodeBase;
import com.openkm.principal.AuthException;
import net.xeoh.plugins.base.Plugin;
import java.util.Set;
/**
* Check user permissions on documents and folders.
*
* @author pavila
*/
public interface DbAccessManager extends Plugin {
void checkPermission(NodeBase node, int permissions) throws AccessDeniedException, PathNotFoundException, DatabaseException;
boolean isGranted(NodeBase node, int permissions) throws DatabaseException, PathNotFoundException;
boolean isGranted(NodeBase node, String user, int permissions) throws AuthException, DatabaseException, PathNotFoundException;
boolean isGranted(NodeBase node, String user, Set<String> roles, int permissions) throws AuthException, DatabaseException, PathNotFoundException;
boolean isGranted(NodeBase node, long nodeClass, int permissions) throws DatabaseException;
}

The new class must be loaded into the package com.openkm.plugin.access because the application plugin system will try to load it from there.