eu.semiramis.policyManager.util.opensaml
Class XACMLRequestUtils

java.lang.Object
  extended by eu.semiramis.policyManager.util.opensaml.XACMLRequestUtils

public class XACMLRequestUtils
extends java.lang.Object

Utility methods to deal with openSAML XACML Requests

Author:
Paolo Roccetti

Constructor Summary
XACMLRequestUtils()
           
 
Method Summary
static org.opensaml.xacml.ctx.RequestType deserialize(java.io.InputStream requestStream)
          Deserialize a XACML request from a stream
static java.lang.String getAttributeFromAction(org.opensaml.xacml.ctx.RequestType request, java.lang.String attributeId)
          Get the first value of the attribute id from action attributes
static org.opensaml.xacml.ctx.AttributeType getAttributeFromList(java.util.List<org.opensaml.xacml.ctx.AttributeType> attributes, java.lang.String attributeId)
          Return the AttributeType, if any, with the given attribute id, null otherwise
static java.lang.String getAttributeFromResource(org.opensaml.xacml.ctx.RequestType request, java.lang.String attributeId)
          Get the first value of the attribute id from resource attributes
static java.lang.String getAttributeFromSubject(org.opensaml.xacml.ctx.RequestType request, java.lang.String attributeId, java.lang.String accessCategory)
          Get the first attribute value for the attribute with given id in the access category indicated.
static void setAttributeInAction(org.opensaml.xacml.ctx.RequestType request, java.lang.String attributeId, java.lang.String attributeValue)
          set the attribute (id and value) in action.
static void setAttributeInList(java.util.List<org.opensaml.xacml.ctx.AttributeType> attributes, java.lang.String attributeID, java.lang.String attributeValue)
           
static void setAttributeInResource(org.opensaml.xacml.ctx.RequestType request, java.lang.String attributeId, java.lang.String attributeValue)
          set the attribute (id and value) in resource attributes.
static void setAttributeInSubject(org.opensaml.xacml.ctx.RequestType request, java.lang.String attributeId, java.lang.String attributeValue, java.lang.String subjectCategory)
          Sets the attribute (id and value) in the access category indicated.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XACMLRequestUtils

public XACMLRequestUtils()
Method Detail

deserialize

public static org.opensaml.xacml.ctx.RequestType deserialize(java.io.InputStream requestStream)
                                                      throws org.opensaml.xml.parse.XMLParserException,
                                                             org.opensaml.xml.io.UnmarshallingException
Deserialize a XACML request from a stream

Parameters:
requestStream - the stream containing the XACML request
Throws:
org.opensaml.xml.parse.XMLParserException - if an exception occurs during parsing
org.opensaml.xml.io.UnmarshallingException - if an exception occus during unmarshalling

setAttributeInSubject

public static void setAttributeInSubject(org.opensaml.xacml.ctx.RequestType request,
                                         java.lang.String attributeId,
                                         java.lang.String attributeValue,
                                         java.lang.String subjectCategory)
Sets the attribute (id and value) in the access category indicated. If the access category is not there, it will be created. If an attribute with the same ID is already there it will be replaced.

Parameters:
request - the request
attributeId - the attribute id
attributeValue - the attribute value
subjectCategory - the subject category

getAttributeFromSubject

public static java.lang.String getAttributeFromSubject(org.opensaml.xacml.ctx.RequestType request,
                                                       java.lang.String attributeId,
                                                       java.lang.String accessCategory)
Get the first attribute value for the attribute with given id in the access category indicated.

Parameters:
request - the request
attributeId - the attribute id
accessCategory - the access category
Returns:
the attribute from subject

setAttributeInAction

public static void setAttributeInAction(org.opensaml.xacml.ctx.RequestType request,
                                        java.lang.String attributeId,
                                        java.lang.String attributeValue)
set the attribute (id and value) in action. If an attribute with the same ID is already there it will be replaced.

Parameters:
request - the request
attributeId - the attribute id
attributeValue - the attribute value

getAttributeFromAction

public static java.lang.String getAttributeFromAction(org.opensaml.xacml.ctx.RequestType request,
                                                      java.lang.String attributeId)
Get the first value of the attribute id from action attributes

Parameters:
request - the request
attributeId - the attribute id
Returns:
the from action

setAttributeInResource

public static void setAttributeInResource(org.opensaml.xacml.ctx.RequestType request,
                                          java.lang.String attributeId,
                                          java.lang.String attributeValue)
set the attribute (id and value) in resource attributes. If an attribute with the same ID is already there it will be replaced.

Parameters:
request - the request
attributeId - the attribute id
attributeValue - the attribute value

getAttributeFromResource

public static java.lang.String getAttributeFromResource(org.opensaml.xacml.ctx.RequestType request,
                                                        java.lang.String attributeId)
Get the first value of the attribute id from resource attributes

Parameters:
request - the request
attributeId - the attribute id
Returns:
the from resource

setAttributeInList

public static void setAttributeInList(java.util.List<org.opensaml.xacml.ctx.AttributeType> attributes,
                                      java.lang.String attributeID,
                                      java.lang.String attributeValue)

getAttributeFromList

public static org.opensaml.xacml.ctx.AttributeType getAttributeFromList(java.util.List<org.opensaml.xacml.ctx.AttributeType> attributes,
                                                                        java.lang.String attributeId)
Return the AttributeType, if any, with the given attribute id, null otherwise

Parameters:
attributes - the attributes
attributeId - the attribute id
Returns:
the attribute, or null if the attribute cannot be found