use of org.opensaml.xacml.ctx.DecisionType.DECISION in project cxf by apache.
the class DummyPDP method evaluate.
public ResponseType evaluate(RequestType request) {
String role = getSubjectRole(request);
DECISION decision = "manager".equals(role) ? DecisionType.DECISION.Permit : DecisionType.DECISION.Deny;
return createResponse(decision);
}
use of org.opensaml.xacml.ctx.DecisionType.DECISION in project cxf by apache.
the class AbstractXACMLAuthorizingInterceptor method authorize.
/**
* Perform a (remote) authorization decision and return a boolean depending on the result
*/
protected boolean authorize(Principal principal, List<String> roles, Message message) throws Exception {
RequestType request = requestBuilder.createRequest(principal, roles, message);
if (LOG.isLoggable(Level.FINE)) {
Document doc = DOMUtils.createDocument();
Element requestElement = OpenSAMLUtil.toDom(request, doc);
LOG.log(Level.FINE, DOM2Writer.nodeToString(requestElement));
}
ResponseType response = performRequest(request, message);
List<ResultType> results = response.getResults();
if (results == null) {
return false;
}
for (ResultType result : results) {
// Handle any Obligations returned by the PDP
handleObligations(request, principal, message, result);
DECISION decision = result.getDecision() != null ? result.getDecision().getDecision() : DECISION.Deny;
String code = "";
String statusMessage = "";
if (result.getStatus() != null) {
StatusType status = result.getStatus();
code = status.getStatusCode() != null ? status.getStatusCode().getValue() : "";
statusMessage = status.getStatusMessage() != null ? status.getStatusMessage().getValue() : "";
}
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("XACML authorization result: " + decision + ", code: " + code + ", message: " + statusMessage);
}
return decision == DECISION.Permit;
}
return false;
}
Aggregations