RequestCtx requestCtx = null;
Principal principal = request.getUserPrincipal();
String username = principal.getName();
//Create the subject set
URI subjectAttrUri = new URI(XACMLConstants.SUBJECT_IDENTIFIER);
Attribute subjectAttr = new Attribute(subjectAttrUri,null,null,
new StringAttribute(username));
Set subjectAttrSet = new HashSet();
subjectAttrSet.add(subjectAttr);
subjectAttrSet.addAll(getXACMLRoleSet(callerRoles));
Set subjectSet = new HashSet();
subjectSet.add(new Subject(subjectAttrSet));
//Create the resource set
URI resourceUri = new URI(XACMLConstants.RESOURCE_IDENTIFIER);
Attribute resourceAttr = new Attribute(resourceUri,null,null,
new AnyURIAttribute(new URI(request.getRequestURI())));
Set resourceSet = new HashSet();
resourceSet.add(resourceAttr);
//Create the action set
Set actionSet = new HashSet();
actionSet.add(new Attribute(new URI(XACMLConstants.ACTION_IDENTIFIER),
null,null, new StringAttribute(action)));
Enumeration<String> enumer = request.getParameterNames();
while(enumer.hasMoreElements())
{
String paramName = enumer.nextElement();
String paramValue = request.getParameter(paramName);
URI actionUri = new URI(actionURIBase + paramName);
Attribute actionAttr = new Attribute(actionUri,null,null,
new StringAttribute(paramValue));
actionSet.add(actionAttr);
}
//Create the Environment set
Set environSet = new HashSet();
//Current time
URI currentTimeUri = new URI(XACMLConstants.CURRENT_TIME_IDENTIFIER);
Attribute currentTimeAttr = new Attribute(currentTimeUri,null,null,
new TimeAttribute());
environSet.add(currentTimeAttr);
//Create the request context
requestCtx = new RequestCtx(subjectSet,resourceSet,actionSet,environSet);