blackboard.platform.security
Class PermissionParser

java.lang.Object
  extended by blackboard.platform.security.PermissionParser

public class PermissionParser
extends java.lang.Object

Utility class to parse and serialize permission sets for system extension manifests.

Since:
Blackboard 6.0.0
Version:
$Revision: #1 $ $Date: 2005/06/27 $

Constructor Summary
PermissionParser()
           
 
Method Summary
static java.security.Permission buildPermissionObject(java.lang.String type, java.lang.String name, java.lang.String actions)
          Creates a permission object given type, name, and actions.
static java.lang.Class getPermissionClass(java.lang.String type)
          Returns the implementation class for a permission identifed by the type string.
static java.lang.String getPermissionType(java.security.Permission perm)
          Returns the type string for a permission, given its XML type identifier.
static boolean isRestricted(java.security.Permission perm)
          Simple check to see if the permission being created is "restricted" and thus not allowed for assignment to a system extension.
static java.security.Permissions parsePermissions(org.w3c.dom.Element elem)
          Fills a permissions collection from the XML element passed in.
static java.security.Permissions parsePermissions(java.lang.String permDef)
          Returns a Permissions collection parsed from the string.
static java.lang.String serializePermissions(java.security.Permissions permList)
          Streams the specified Permissions object into an XML format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PermissionParser

public PermissionParser()
Method Detail

getPermissionType

public static java.lang.String getPermissionType(java.security.Permission perm)
Returns the type string for a permission, given its XML type identifier.

Parameters:
perm - Permission to query.
Returns:
Type string used to identify the permission in XML. Null if there is no mapping.

getPermissionClass

public static java.lang.Class getPermissionClass(java.lang.String type)
Returns the implementation class for a permission identifed by the type string.

Parameters:
type - String used to identify the permission in its XML form. Examples include: "runtime", "persist", "socket", and "attribute".
Returns:
Class for the permission. Null if the name does not match any known permission types.

parsePermissions

public static java.security.Permissions parsePermissions(java.lang.String permDef)
Returns a Permissions collection parsed from the string. The permDef is expected to be an XML fragment conforming to the XML spec in the System Extension framework.

Example:

 <permissions>
   <permission type="attribute" name="user.givenname" actions="get,set">
 </permissions>
 

Parameters:
permDef - String containing permission definitions. The string must use the XML format described in the System Extensions framework specification.
Returns:
Initialized permissions collection. If no valid permissions were defined in permDef, the collection will be empty.

parsePermissions

public static java.security.Permissions parsePermissions(org.w3c.dom.Element elem)
Fills a permissions collection from the XML element passed in.

Parameters:
elem - Element containing the permission definitions. The permissions are expected to be the first level elements, conforming to the manifest declaration.
Returns:
Initialized Permissions collection

serializePermissions

public static java.lang.String serializePermissions(java.security.Permissions permList)
Streams the specified Permissions object into an XML format. Only permission types supported for plugins are encoded (Runtime permissions and Attribute permissions).

Parameters:
perm - Permissions collection to encode
Returns:
String containing a valid XML document (including prolog).

buildPermissionObject

public static java.security.Permission buildPermissionObject(java.lang.String type,
                                                             java.lang.String name,
                                                             java.lang.String actions)
Creates a permission object given type, name, and actions.

Parameters:
type - type string. This should correspond to one of the types defined in this class
name - name to give the permission
actions - actions to give the permission
Returns:
initialized permission object. null if the type attribute does not match an entry in the type map, or if the permission is not "legal" for assignment to a system extension.

isRestricted

public static boolean isRestricted(java.security.Permission perm)
Simple check to see if the permission being created is "restricted" and thus not allowed for assignment to a system extension.

Parameters:
perm - permission to check.
Returns:
true if the permission is restricted for extensions.


Copyright © 2003 Blackboard, Inc. All Rights Reserved.