* @see ResponseContext#getResult()
*/
@SuppressWarnings("unchecked")
public ResultType getResult()
{
ObjectFactory objectFactory = new ObjectFactory();
ResultType resultType = objectFactory.createResultType();
ResponseCtx response = (ResponseCtx) map.get(XACMLConstants.RESPONSE_CTX);
if (response != null)
{
//Resource ID
Result result = (Result) response.getResults().iterator().next();
resultType.setResourceId(result.getResource());
//Decision
int decision = result.getDecision();
switch(decision)
{
case 0:
resultType.setDecision(DecisionType.PERMIT);
break;
case 1:
resultType.setDecision(DecisionType.DENY);
break;
case 2:
resultType.setDecision(DecisionType.INDETERMINATE);
break;
case 3:
resultType.setDecision(DecisionType.NOT_APPLICABLE);
break;
default:
throw new IllegalStateException("Unknown code");
}
//Status
Status status = result.getStatus();
StatusType statusType = objectFactory.createStatusType();
StatusCodeType statusCodeType = objectFactory.createStatusCodeType();
List statusList = status.getCode();
if(statusList != null && statusList.size() > 0)
{
statusCodeType.setValue((String) statusList.get(0));
}