se.kmr.scam.rdf.util
Class ACLUtil

java.lang.Object
  extended byse.kmr.scam.rdf.util.ACLUtil

public class ACLUtil
extends Object

Access Control List helper.

Title:

Description:

Copyright: Copyright (c) 2002

Company:

Version:
$Revision $
Author:
jand

Field Summary
protected static org.apache.log4j.Category LOG
          Log4j-logger
 
Constructor Summary
ACLUtil()
           
 
Method Summary
static void addPermission(Model m, Resource res, RDFNode principal, Property perm)
          Add a permission for a principal.
static void copyACL(Model sourceModel, Resource source, Model destModel, Resource dest)
          Copy the ACL-entries from one component to another.
static Resource createACL(Model m, Resource res)
          Create a new ACL.acl of res or reuse existing one.
static Resource getACL(Model m, Resource res)
          Get the ACL.acl resource of res.
static boolean hasACL(Model m, Resource res)
          Check if res has an ACL.acl resource.
static boolean hasOwner(Model m, Resource res)
          Check if resource has an ACL.owner.
static boolean hasPermission(Model m, Resource res, Collection principals, Property perm)
          Check permission for a collection of principals.
static boolean hasPermission(Model m, Resource res, RDFNode principal, Property perm)
          Check permission for principal on a resource.
static boolean isOwner(Model m, Resource res, RDFNode principal)
          Check if principal is the ACL.owner.
static List listPermissions(Model m, Resource res)
          List all permissions.
static List listPermissions(Model m, Resource res, RDFNode principal)
          List all permissions for a specific principal.
static List listPrincipals(Model m, Resource res)
          List all principals.
static List listPrincipals(Model m, Resource res, Property perm)
          List all principals with a specific permission.
static void main(String[] args)
           
static void removePermission(Model m, Resource res)
          Remove all permissions for all principals.
static void removePermission(Model m, Resource res, RDFNode principal)
          Remove all permissions for a specific principal.
static void removePermission(Model m, Resource res, RDFNode principal, Property perm)
          Remove permission for a specific principal.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

protected static org.apache.log4j.Category LOG
Log4j-logger

Constructor Detail

ACLUtil

public ACLUtil()
Method Detail

createACL

public static Resource createACL(Model m,
                                 Resource res)
                          throws RDFException
Create a new ACL.acl of res or reuse existing one.

Parameters:
m - Model
res - Resource
Returns:
the ACL.acl resource
Throws:
RDFException

getACL

public static Resource getACL(Model m,
                              Resource res)
                       throws RDFException
Get the ACL.acl resource of res.

Parameters:
m - Model
res - Resource
Returns:
the ACL.acl resource or null if not found.
Throws:
RDFException

hasACL

public static boolean hasACL(Model m,
                             Resource res)
                      throws RDFException
Check if res has an ACL.acl resource.

Parameters:
m - Model
res - Resource
Returns:
true if exists
Throws:
RDFException

hasPermission

public static boolean hasPermission(Model m,
                                    Resource res,
                                    RDFNode principal,
                                    Property perm)
                             throws RDFException
Check permission for principal on a resource. A principal has all permissions if she is the ACL.owner.

Parameters:
m - Model
res - Resource
principal - Principal
perm - Permission
Returns:
true if principal has this permission
Throws:
RDFException

hasPermission

public static boolean hasPermission(Model m,
                                    Resource res,
                                    Collection principals,
                                    Property perm)
                             throws RDFException
Check permission for a collection of principals. A principal has all permissions if she is the ACL.owner.

Parameters:
m - Model
res - Resource
principals - Collection of principals (RDFNodes)
perm - Permission
Returns:
true if ANY principal has this permission
Throws:
RDFException
To do:
Unnecessary lookup of ACL.acl resource!

hasOwner

public static boolean hasOwner(Model m,
                               Resource res)
                        throws RDFException
Check if resource has an ACL.owner.

Parameters:
m - Model
res - Resource
Returns:
true if principal is owner
Throws:
RDFException

isOwner

public static boolean isOwner(Model m,
                              Resource res,
                              RDFNode principal)
                       throws RDFException
Check if principal is the ACL.owner.

Parameters:
m - Model
res - Resource
principal - Principal
Returns:
true if principal is owner
Throws:
RDFException

listPermissions

public static List listPermissions(Model m,
                                   Resource res)
                            throws RDFException
List all permissions. Statement predicate is the permission, object is the principal.

Parameters:
m - Model
res - Resource
Returns:
Collection of Statements
Throws:
RDFException

listPermissions

public static List listPermissions(Model m,
                                   Resource res,
                                   RDFNode principal)
                            throws RDFException
List all permissions for a specific principal.

Parameters:
m - Model
res - Resource
principal - Principal
Returns:
Collection of Property
Throws:
RDFException

listPrincipals

public static List listPrincipals(Model m,
                                  Resource res)
                           throws RDFException
List all principals.

Parameters:
m - Model
res - Resource
Returns:
Collection of RDFNodes
Throws:
RDFException

listPrincipals

public static List listPrincipals(Model m,
                                  Resource res,
                                  Property perm)
                           throws RDFException
List all principals with a specific permission.

Parameters:
m - Model
res - Resource
perm - Permission
Returns:
Collection of RDFNodes
Throws:
RDFException

addPermission

public static void addPermission(Model m,
                                 Resource res,
                                 RDFNode principal,
                                 Property perm)
                          throws RDFException
Add a permission for a principal. Creates a new ACL.acl resource if necessary.

Parameters:
m - Model
res - Resource
principal - Principal
perm - Permission
Throws:
RDFException

removePermission

public static void removePermission(Model m,
                                    Resource res)
                             throws RDFException
Remove all permissions for all principals.

Parameters:
m - Model
res - Resource
Throws:
RDFException

removePermission

public static void removePermission(Model m,
                                    Resource res,
                                    RDFNode principal)
                             throws RDFException
Remove all permissions for a specific principal.

Parameters:
m - Model
res - Resource
principal - Principal
Throws:
RDFException

removePermission

public static void removePermission(Model m,
                                    Resource res,
                                    RDFNode principal,
                                    Property perm)
                             throws RDFException
Remove permission for a specific principal.

Parameters:
m - Model
res - Resource
principal - Principal
perm - Premission
Throws:
RDFException

copyACL

public static void copyACL(Model sourceModel,
                           Resource source,
                           Model destModel,
                           Resource dest)
                    throws RDFException
Copy the ACL-entries from one component to another.

Parameters:
sourceModel - Source Model
source - Source Component
destModel - Destination Model
dest - Destination Model
Throws:
RDFException

main

public static void main(String[] args)


Copyright © 2003 SCAM. All Rights Reserved.