Search in sources :

Example 1 with DECISION

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);
}
Also used : DECISION(org.opensaml.xacml.ctx.DecisionType.DECISION)

Example 2 with 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;
}
Also used : DECISION(org.opensaml.xacml.ctx.DecisionType.DECISION) StatusType(org.opensaml.xacml.ctx.StatusType) Element(org.w3c.dom.Element) ResultType(org.opensaml.xacml.ctx.ResultType) Document(org.w3c.dom.Document) RequestType(org.opensaml.xacml.ctx.RequestType) ResponseType(org.opensaml.xacml.ctx.ResponseType)

Aggregations

DECISION (org.opensaml.xacml.ctx.DecisionType.DECISION)2 RequestType (org.opensaml.xacml.ctx.RequestType)1 ResponseType (org.opensaml.xacml.ctx.ResponseType)1 ResultType (org.opensaml.xacml.ctx.ResultType)1 StatusType (org.opensaml.xacml.ctx.StatusType)1 Document (org.w3c.dom.Document)1 Element (org.w3c.dom.Element)1