eu.xtreemos.xosd.security.vops.xacml.policy
Class Policy

java.lang.Object
  extended by eu.xtreemos.xosd.security.vops.xacml.policy.Policy

public class Policy
extends java.lang.Object

The purpose of this class is to hold info about policies. It has to generate policy in XACML format from registered TARGETS and RULES which applies policies over these targets.

Author:
ales.cernivec@xlab.si

Field Summary
private  com.sun.xacml.combine.RuleCombiningAlgorithm combiningAlg
           
private  java.lang.String description
           
private  java.net.URI policyId
           
private  java.util.ArrayList<PolicyRule> rules
          List of all policy rules.
private  PolicyTarget target
          Holds info about policy targets
static java.lang.String XACML_ACTION_ACTION_ID
          Actions
static java.lang.String XACML_ATTRIBUTEID_CURRENTTIME
          Attribute ids
static java.lang.String XACML_ATTRIBUTEID_ENV_CURRENT_TIME
          Environment
static java.lang.String XACML_DATATYPE_BOOLEAN
           
static java.lang.String XACML_DATATYPE_DOUBLE
           
static java.lang.String XACML_DATATYPE_INTEGER
           
static java.lang.String XACML_DATATYPE_STRING
           
static java.lang.String XACML_DATATYPE_TIME
          DataTypes definitions
static java.lang.String XACML_FUNCTIONID_BOOLEAN_AND
           
static java.lang.String XACML_FUNCTIONID_BOOLEAN_OR
           
static java.lang.String XACML_FUNCTIONID_DOUBLE_EQUAL
           
static java.lang.String XACML_FUNCTIONID_DOUBLE_GREATER_OR_EQ
           
static java.lang.String XACML_FUNCTIONID_DOUBLE_LESS_OR_EQ
           
static java.lang.String XACML_FUNCTIONID_DOUBLE_ONE_ONLY
           
static java.lang.String XACML_FUNCTIONID_STRING_EQUAL
           
static java.lang.String XACML_FUNCTIONID_STRING_ONE_ONLY
           
static java.lang.String XACML_FUNCTIONID_TIME_GREATER_OR_EQ
          Function id definitions
static java.lang.String XACML_FUNCTIONID_TIME_LESS_OR_EQ
           
static java.lang.String XACML_FUNCTIONID_TIME_ONE_AND_ONLY
           
static java.lang.String XACML_RESOURCE_RESOURCE_ID
           
static java.lang.String XACML_URI_RESOURCE_DN
           
static java.lang.String XACML_URI_SUBJECT_DN
           
static java.lang.String XACML_URI_SUBJECT_EXTENSION
          Constants used for parsing policies.
 
Constructor Summary
Policy()
           
Policy(java.net.URI policyId, java.lang.String description)
          Creates policy object.
 
Method Summary
 void addRule(PolicyRule pr)
          Adds Rule into rule list
 void addRules(java.util.ArrayList<PolicyRule> alRules)
          Adds range of rules from ArrayList.
 java.net.URI getId()
          Return policyId.
 com.sun.xacml.Policy getPolicy()
          Generates xacml Policy.
 PolicyRule getRule(java.lang.String ruleId)
           
 java.util.ArrayList<PolicyRule> getRules(com.sun.xacml.ctx.RequestCtx context, boolean matchResources)
          Gets array list of all rules in the policy.
 PolicyTarget getTarget()
           
 void parse(java.util.Hashtable<java.lang.String,java.lang.Object> context, XMLSearchEngine xse)
          Parses root Policy Node.
 void parsePolicy(com.sun.xacml.Policy xacmlpolicy)
          Parses xacml policy into new structure.
 Policy parsePolicy(java.lang.String xmlPolicy)
          Parses xml document and returns Policy.
 boolean removeRule(java.net.URI ruleId)
          Removes rule with specified ruleId from this policy.
 void setTarget(PolicyTarget target)
           
 java.lang.String toString()
          Returns policy as String instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

XACML_ACTION_ACTION_ID

public static final java.lang.String XACML_ACTION_ACTION_ID
Actions

See Also:
Constant Field Values

XACML_RESOURCE_RESOURCE_ID

public static final java.lang.String XACML_RESOURCE_RESOURCE_ID
See Also:
Constant Field Values

XACML_FUNCTIONID_TIME_GREATER_OR_EQ

public static final java.lang.String XACML_FUNCTIONID_TIME_GREATER_OR_EQ
Function id definitions

See Also:
Constant Field Values

XACML_FUNCTIONID_TIME_LESS_OR_EQ

public static final java.lang.String XACML_FUNCTIONID_TIME_LESS_OR_EQ
See Also:
Constant Field Values

XACML_FUNCTIONID_TIME_ONE_AND_ONLY

public static final java.lang.String XACML_FUNCTIONID_TIME_ONE_AND_ONLY
See Also:
Constant Field Values

XACML_FUNCTIONID_STRING_EQUAL

public static final java.lang.String XACML_FUNCTIONID_STRING_EQUAL
See Also:
Constant Field Values

XACML_FUNCTIONID_DOUBLE_EQUAL

public static final java.lang.String XACML_FUNCTIONID_DOUBLE_EQUAL
See Also:
Constant Field Values

XACML_FUNCTIONID_STRING_ONE_ONLY

public static final java.lang.String XACML_FUNCTIONID_STRING_ONE_ONLY
See Also:
Constant Field Values

XACML_FUNCTIONID_DOUBLE_ONE_ONLY

public static final java.lang.String XACML_FUNCTIONID_DOUBLE_ONE_ONLY
See Also:
Constant Field Values

XACML_FUNCTIONID_BOOLEAN_AND

public static final java.lang.String XACML_FUNCTIONID_BOOLEAN_AND
See Also:
Constant Field Values

XACML_FUNCTIONID_BOOLEAN_OR

public static final java.lang.String XACML_FUNCTIONID_BOOLEAN_OR
See Also:
Constant Field Values

XACML_FUNCTIONID_DOUBLE_GREATER_OR_EQ

public static final java.lang.String XACML_FUNCTIONID_DOUBLE_GREATER_OR_EQ
See Also:
Constant Field Values

XACML_FUNCTIONID_DOUBLE_LESS_OR_EQ

public static final java.lang.String XACML_FUNCTIONID_DOUBLE_LESS_OR_EQ
See Also:
Constant Field Values

XACML_DATATYPE_TIME

public static final java.lang.String XACML_DATATYPE_TIME
DataTypes definitions

See Also:
Constant Field Values

XACML_DATATYPE_STRING

public static final java.lang.String XACML_DATATYPE_STRING
See Also:
Constant Field Values

XACML_DATATYPE_INTEGER

public static final java.lang.String XACML_DATATYPE_INTEGER
See Also:
Constant Field Values

XACML_DATATYPE_BOOLEAN

public static final java.lang.String XACML_DATATYPE_BOOLEAN
See Also:
Constant Field Values

XACML_DATATYPE_DOUBLE

public static final java.lang.String XACML_DATATYPE_DOUBLE
See Also:
Constant Field Values

XACML_ATTRIBUTEID_CURRENTTIME

public static final java.lang.String XACML_ATTRIBUTEID_CURRENTTIME
Attribute ids

See Also:
Constant Field Values

XACML_ATTRIBUTEID_ENV_CURRENT_TIME

public static final java.lang.String XACML_ATTRIBUTEID_ENV_CURRENT_TIME
Environment

See Also:
Constant Field Values

XACML_URI_SUBJECT_EXTENSION

public static final java.lang.String XACML_URI_SUBJECT_EXTENSION
Constants used for parsing policies.

See Also:
Constant Field Values

XACML_URI_SUBJECT_DN

public static final java.lang.String XACML_URI_SUBJECT_DN
See Also:
Constant Field Values

XACML_URI_RESOURCE_DN

public static final java.lang.String XACML_URI_RESOURCE_DN
See Also:
Constant Field Values

policyId

private java.net.URI policyId

description

private java.lang.String description

combiningAlg

private com.sun.xacml.combine.RuleCombiningAlgorithm combiningAlg

target

private PolicyTarget target
Holds info about policy targets


rules

private java.util.ArrayList<PolicyRule> rules
List of all policy rules. Default fall-through rule is automatically added at the end.

Constructor Detail

Policy

public Policy()

Policy

public Policy(java.net.URI policyId,
              java.lang.String description)
       throws java.lang.Exception
Creates policy object.

Parameters:
policyId -
description -
Throws:
java.lang.Exception
Method Detail

getId

public java.net.URI getId()
Return policyId.

Returns:
URI - policy Id.

addRule

public void addRule(PolicyRule pr)
             throws java.lang.Exception
Adds Rule into rule list

Throws:
java.lang.Exception

addRules

public void addRules(java.util.ArrayList<PolicyRule> alRules)
              throws java.lang.Exception
Adds range of rules from ArrayList.

Parameters:
alRules -
Throws:
java.lang.Exception

getPolicy

public com.sun.xacml.Policy getPolicy()
Generates xacml Policy. From list of PolicyRule creates new list if XACML policies and uses it as a parameter with call to Policy constructor.

Returns:
XACML Policy

parsePolicy

public void parsePolicy(com.sun.xacml.Policy xacmlpolicy)
                 throws java.lang.Exception
Parses xacml policy into new structure.

Parameters:
xacmlpolicy - Sun's XACML implementation.
Throws:
java.lang.Exception

parsePolicy

public Policy parsePolicy(java.lang.String xmlPolicy)
                   throws java.lang.Exception
Parses xml document and returns Policy.

Parameters:
xmlPolicy - is a XML Policy as String instance.
Returns:
Throws:
java.lang.Exception

getRules

public java.util.ArrayList<PolicyRule> getRules(com.sun.xacml.ctx.RequestCtx context,
                                                boolean matchResources)
Gets array list of all rules in the policy. If context is null, all rules are returned as ArrayList. If context is not null, it is used to match rules against it. Rule which matches the query is added into retList.

Parameters:
context - context of the request.
matchResources - set to true if we want to filter rules also by resource.

getRule

public PolicyRule getRule(java.lang.String ruleId)

removeRule

public boolean removeRule(java.net.URI ruleId)
                   throws java.lang.Exception
Removes rule with specified ruleId from this policy.

Parameters:
ruleId - identification of the rule
Returns:
true if success
Throws:
java.lang.Exception

parse

public void parse(java.util.Hashtable<java.lang.String,java.lang.Object> context,
                  XMLSearchEngine xse)
           throws java.lang.Exception
Parses root Policy Node.

Parameters:
context - context returned by the XMLParserAndValidator
xse - search engine for context TODO: clean up hard coded stuff!
Throws:
java.lang.Exception

toString

public java.lang.String toString()
Returns policy as String instance.

Overrides:
toString in class java.lang.Object
Returns:
XACML policy as string.

getTarget

public PolicyTarget getTarget()

setTarget

public void setTarget(PolicyTarget target)