Attribute subjectAttr = new Attribute(subjectAttrUri, new URI(StringAttribute.identifier), null, null,
subjectAttributeValues);
Set subjectAttrSet = new HashSet();
subjectAttrSet.add(subjectAttr);
Set subjectSet = new HashSet();
subjectSet.add(new Subject(subjectAttrSet));
//Create the resource set
URI resourceUri = new URI("urn:oasis:names:tc:xacml:1.0:resource:resource-id");
Set resourceAttributeValues = new HashSet();
resourceAttributeValues.add(new StringAttribute("http://jboss.com/developers/payroll/anilsaldhana"));
Attribute resourceAttr = new Attribute(resourceUri, new URI(StringAttribute.identifier), null, null,
resourceAttributeValues);
Set resourceSet = new HashSet();
resourceSet.add(resourceAttr);
//Create the action set
URI actionUri = new URI("urn:oasis:names:tc:xacml:1.0:action:action-id");
Set actionAttributeValues = new HashSet();
actionAttributeValues.add(new StringAttribute("read"));
Attribute actionAttr = new Attribute(actionUri, new URI(StringAttribute.identifier), null, null,
actionAttributeValues);
Set actionSet = new HashSet();
actionSet.add(actionAttr);
//Create the environment set
Set environSet = new HashSet();
RequestCtx request = new RequestCtx(subjectSet, resourceSet, actionSet, environSet);
assertNotNull("XACML Request != null", request);
//Log the request for viewing
if (DEBUG)
XACMLUtil.logRequest(request);
//Test the request contents
Set subjects = request.getSubjects();
assertTrue("We have one subject?", subjects.size() == 1);
Subject subj = (Subject) (subjects.iterator().next());
assertNotNull("Subject != null", subj);
assertEquals("Attributes in subject match", subjectAttr, (Attribute) (subj.getAttributes().iterator().next()));
//Test the resource attributes
Set resources = request.getResource();
assertTrue("# of resources = 1", resources.size() == 1);
assertEquals("Attributes in resources match", resourceAttr, (Attribute) (resources.iterator().next()));