org.fcrepo.server.security.xacml.util
Class ContextUtil

java.lang.Object
  extended by org.fcrepo.server.security.xacml.util.ContextUtil

public class ContextUtil
extends Object

Utility class that provides various methods for creating/converting contexts. This class can convert requests and responses from their string representations to their object representations and vice versa as well as a few utility methods for getting information from the contexts. It also contains methods for constructing requests.

Author:
nishen@melcoe.mq.edu.au

Constructor Summary
ContextUtil()
           
 
Method Summary
 com.sun.xacml.ctx.RequestCtx buildRequest(List<Map<URI,List<com.sun.xacml.attr.AttributeValue>>> subjects, Map<URI,com.sun.xacml.attr.AttributeValue> actions, Map<URI,com.sun.xacml.attr.AttributeValue> resources, Map<URI,com.sun.xacml.attr.AttributeValue> environment, RelationshipResolver relationshipResolver)
          Constructs a RequestCtx object.
 String makeRequestCtx(com.sun.xacml.ctx.RequestCtx reqCtx)
          Converts a RequestCtx object to its string representation.
 com.sun.xacml.ctx.RequestCtx makeRequestCtx(String request)
          Converts a string based request to a RequestCtx obejct.
 String makeResponseCtx(com.sun.xacml.ctx.ResponseCtx resCtx)
          Converst a ResponseCtx object to its string representation.
 com.sun.xacml.ctx.ResponseCtx makeResponseCtx(String response)
          Converts a string based response to a ResponseCtx obejct.
 Map<String,com.sun.xacml.ctx.Result> makeResultMap(com.sun.xacml.ctx.ResponseCtx resCtx)
          Returns a map of resource-id, result based on an XACML response.
 void setActionMap(Map<String,String> actions)
           
 void setActionValueMap(Map<String,String> values)
           
 Set<com.sun.xacml.ctx.Attribute> setupAction(Map<URI,com.sun.xacml.attr.AttributeValue> a)
          Creates an Action specifying the action-id, an optional attribute.
 Set<com.sun.xacml.ctx.Attribute> setupEnvironment(Map<URI,com.sun.xacml.attr.AttributeValue> e)
          Creates the Environment attributes.
 Set<com.sun.xacml.ctx.Attribute> setupResources(Map<URI,com.sun.xacml.attr.AttributeValue> res, RelationshipResolver relationshipResolver)
          Creates a Resource specifying the resource-id, a required attribute.
 Set<com.sun.xacml.ctx.Subject> setupSubjects(List<Map<URI,List<com.sun.xacml.attr.AttributeValue>>> subjs)
          Sets up the Subject section of the request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContextUtil

public ContextUtil()
Method Detail

setActionMap

public void setActionMap(Map<String,String> actions)

setActionValueMap

public void setActionValueMap(Map<String,String> values)

setupSubjects

public Set<com.sun.xacml.ctx.Subject> setupSubjects(List<Map<URI,List<com.sun.xacml.attr.AttributeValue>>> subjs)
Sets up the Subject section of the request. Takes a list of Maps of URI/AttributeValue pairs. Each list element represents one subject which contains a map of URI/AttributeValues.

Returns:
a Set of Subject instances for inclusion in a Request

setupResources

public Set<com.sun.xacml.ctx.Attribute> setupResources(Map<URI,com.sun.xacml.attr.AttributeValue> res,
                                                       RelationshipResolver relationshipResolver)
                                                throws MelcoeXacmlException
Creates a Resource specifying the resource-id, a required attribute.

Returns:
a Set of Attributes for inclusion in a Request
Throws:
MelcoeXacmlException

setupAction

public Set<com.sun.xacml.ctx.Attribute> setupAction(Map<URI,com.sun.xacml.attr.AttributeValue> a)
Creates an Action specifying the action-id, an optional attribute.

Returns:
a Set of Attributes for inclusion in a Request

setupEnvironment

public Set<com.sun.xacml.ctx.Attribute> setupEnvironment(Map<URI,com.sun.xacml.attr.AttributeValue> e)
Creates the Environment attributes.

Returns:
a Set of Attributes for inclusion in a Request

buildRequest

public com.sun.xacml.ctx.RequestCtx buildRequest(List<Map<URI,List<com.sun.xacml.attr.AttributeValue>>> subjects,
                                                 Map<URI,com.sun.xacml.attr.AttributeValue> actions,
                                                 Map<URI,com.sun.xacml.attr.AttributeValue> resources,
                                                 Map<URI,com.sun.xacml.attr.AttributeValue> environment,
                                                 RelationshipResolver relationshipResolver)
                                          throws MelcoeXacmlException
Constructs a RequestCtx object.

Parameters:
subjects - list of Subjects
actions - list of Action attributes
resources - list of resource Attributes
environment - list of environment Attributes
Returns:
the RequestCtx object
Throws:
MelcoeXacmlException

makeResponseCtx

public com.sun.xacml.ctx.ResponseCtx makeResponseCtx(String response)
                                              throws MelcoeXacmlException
Converts a string based response to a ResponseCtx obejct.

Parameters:
response - the string response
Returns:
the ResponseCtx object
Throws:
MelcoeXacmlException

makeRequestCtx

public com.sun.xacml.ctx.RequestCtx makeRequestCtx(String request)
                                            throws MelcoeXacmlException
Converts a string based request to a RequestCtx obejct.

Parameters:
request - the string request
Returns:
the RequestCtx object
Throws:
MelcoeXacmlException

makeRequestCtx

public String makeRequestCtx(com.sun.xacml.ctx.RequestCtx reqCtx)
Converts a RequestCtx object to its string representation.

Parameters:
reqCtx - the RequestCtx object
Returns:
the String representation of the RequestCtx object

makeResponseCtx

public String makeResponseCtx(com.sun.xacml.ctx.ResponseCtx resCtx)
Converst a ResponseCtx object to its string representation.

Parameters:
resCtx - the ResponseCtx object
Returns:
the String representation of the ResponseCtx object

makeResultMap

public Map<String,com.sun.xacml.ctx.Result> makeResultMap(com.sun.xacml.ctx.ResponseCtx resCtx)
Returns a map of resource-id, result based on an XACML response.

Parameters:
resCtx - the XACML response
Returns:
the Map of resource-id and result


Copyright © 2012 DuraSpace. All Rights Reserved.