org.opensaml.xacml.ctx.ResponseType Java Examples
The following examples show how to use
org.opensaml.xacml.ctx.ResponseType.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XACMLAuthzDecisionStatementTypeUnmarshaller.java From lams with GNU General Public License v2.0 | 5 votes |
/** {@inheritDoc} */ protected void processChildElement(XMLObject parentObject, XMLObject childObject) throws UnmarshallingException { XACMLAuthzDecisionStatementType xacmlauthzdecisionstatement = (XACMLAuthzDecisionStatementType) parentObject; if (childObject instanceof RequestType) { xacmlauthzdecisionstatement.setRequest((RequestType) childObject); } else if (childObject instanceof ResponseType) { xacmlauthzdecisionstatement.setResponse((ResponseType) childObject); } else { super.processChildElement(parentObject, childObject); } }
Example #2
Source File: ResponseTypeUnmarshaller.java From lams with GNU General Public License v2.0 | 5 votes |
/** {@inheritDoc} */ protected void processChildElement(XMLObject parentXMLObject, XMLObject childXMLObject) throws UnmarshallingException { ResponseType response = (ResponseType) parentXMLObject; if (childXMLObject instanceof ResultType) { response.setResult((ResultType) childXMLObject); } else { super.processChildElement(parentXMLObject, childXMLObject); } }
Example #3
Source File: AbstractXACMLAuthorizingInterceptor.java From cxf with Apache License 2.0 | 5 votes |
/** * 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; }
Example #4
Source File: XACMLAuthzDecisionStatementTypeImpl.java From lams with GNU General Public License v2.0 | 4 votes |
/** {@inheritDoc} */ public ResponseType getResponse() { return response; }
Example #5
Source File: XACMLAuthzDecisionStatementTypeImpl.java From lams with GNU General Public License v2.0 | 4 votes |
/** {@inheritDoc} */ public void setResponse(ResponseType response) { this.response = prepareForAssignment(this.response, response); }
Example #6
Source File: ResponseTypeImplBuilder.java From lams with GNU General Public License v2.0 | 4 votes |
/** {@inheritDoc} */ public ResponseType buildObject() { return buildObject(ResponseType.DEFAULT_ELEMENT_NAME); }
Example #7
Source File: ResponseTypeImplBuilder.java From lams with GNU General Public License v2.0 | 4 votes |
/** {@inheritDoc} */ public ResponseType buildObject(String namespaceURI, String localName, String namespacePrefix) { return new ResponseTypeImpl(namespaceURI, localName, XACMLConstants.XACMLCONTEXT_PREFIX); }
Example #8
Source File: PolicyDecisionPointMockImpl.java From cxf with Apache License 2.0 | 4 votes |
@Override public ResponseType evaluate(RequestType requestType) { XMLObjectBuilderFactory builderFactory = XMLObjectProviderRegistrySupport.getBuilderFactory(); @SuppressWarnings("unchecked") XACMLObjectBuilder<ResponseType> responseTypeBuilder = (XACMLObjectBuilder<ResponseType>) builderFactory.getBuilder(ResponseType.DEFAULT_ELEMENT_NAME); @SuppressWarnings("unchecked") XACMLObjectBuilder<ResultType> resultTypeBuilder = (XACMLObjectBuilder<ResultType>) builderFactory.getBuilder(ResultType.DEFAULT_ELEMENT_NAME); @SuppressWarnings("unchecked") XACMLObjectBuilder<DecisionType> decisionTypeBuilder = (XACMLObjectBuilder<DecisionType>) builderFactory.getBuilder(DecisionType.DEFAULT_ELEMENT_NAME); @SuppressWarnings("unchecked") XACMLObjectBuilder<StatusType> statusTypeBuilder = (XACMLObjectBuilder<StatusType>) builderFactory.getBuilder(StatusType.DEFAULT_ELEMENT_NAME); @SuppressWarnings("unchecked") XACMLObjectBuilder<StatusCodeType> statusCodeTypeBuilder = (XACMLObjectBuilder<StatusCodeType>) builderFactory.getBuilder(StatusCodeType.DEFAULT_ELEMENT_NAME); DecisionType decisionType = decisionTypeBuilder.buildObject(); String role = getSubjectRole(requestType); if ("manager".equals(role)) { decisionType.setDecision(DecisionType.DECISION.Permit); } else { decisionType.setDecision(DecisionType.DECISION.Deny); } ResultType result = resultTypeBuilder.buildObject(); result.setDecision(decisionType); StatusType status = statusTypeBuilder.buildObject(); StatusCodeType statusCode = statusCodeTypeBuilder.buildObject(); statusCode.setValue("urn:oasis:names:tc:xacml:1.0:status:ok"); status.setStatusCode(statusCode); result.setStatus(status); ResponseType response = responseTypeBuilder.buildObject(); response.getResults().add(result); return response; }
Example #9
Source File: XACMLAuthorizingInterceptor.java From cxf with Apache License 2.0 | 4 votes |
@Override protected ResponseType performRequest(RequestType request, Message message) throws Exception { return this.pdp.evaluate(request); }
Example #10
Source File: DummyPDP.java From cxf with Apache License 2.0 | 4 votes |
public ResponseType evaluate(RequestType request) { String role = getSubjectRole(request); DECISION decision = "manager".equals(role) ? DecisionType.DECISION.Permit : DecisionType.DECISION.Deny; return createResponse(decision); }
Example #11
Source File: DummyPDP.java From cxf with Apache License 2.0 | 4 votes |
private ResponseType createResponse(DECISION decision) { XMLObjectBuilderFactory builderFactory = XMLObjectProviderRegistrySupport.getBuilderFactory(); @SuppressWarnings("unchecked") XACMLObjectBuilder<ResponseType> responseTypeBuilder = (XACMLObjectBuilder<ResponseType>) builderFactory.getBuilder(ResponseType.DEFAULT_ELEMENT_NAME); @SuppressWarnings("unchecked") XACMLObjectBuilder<ResultType> resultTypeBuilder = (XACMLObjectBuilder<ResultType>) builderFactory.getBuilder(ResultType.DEFAULT_ELEMENT_NAME); @SuppressWarnings("unchecked") XACMLObjectBuilder<DecisionType> decisionTypeBuilder = (XACMLObjectBuilder<DecisionType>) builderFactory.getBuilder(DecisionType.DEFAULT_ELEMENT_NAME); @SuppressWarnings("unchecked") XACMLObjectBuilder<StatusType> statusTypeBuilder = (XACMLObjectBuilder<StatusType>) builderFactory.getBuilder(StatusType.DEFAULT_ELEMENT_NAME); @SuppressWarnings("unchecked") XACMLObjectBuilder<StatusCodeType> statusCodeTypeBuilder = (XACMLObjectBuilder<StatusCodeType>) builderFactory.getBuilder(StatusCodeType.DEFAULT_ELEMENT_NAME); ResultType result = resultTypeBuilder.buildObject(); DecisionType decisionType = decisionTypeBuilder.buildObject(); decisionType.setDecision(decision); result.setDecision(decisionType); StatusType status = statusTypeBuilder.buildObject(); StatusCodeType statusCode = statusCodeTypeBuilder.buildObject(); statusCode.setValue("urn:oasis:names:tc:xacml:1.0:status:ok"); status.setStatusCode(statusCode); result.setStatus(status); ResponseType response = responseTypeBuilder.buildObject(); response.getResults().add(result); return response; }
Example #12
Source File: XACMLAuthzDecisionStatementType.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Get's the {@link ResponseType} from the <code>XACMLAuthzDecisionStatement</code>. * * @return the {@link ResponseType} inside the <code>XACMLAuthzDecisionStatement</code> */ public ResponseType getResponse();
Example #13
Source File: XACMLAuthzDecisionStatementType.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Sets a {@link ResponseType} to the <code>XACMLAuthzDecisionStatement</code>. * * @param response {@link ResponseType} */ public void setResponse(ResponseType response);
Example #14
Source File: PolicyDecisionPoint.java From cxf with Apache License 2.0 | 2 votes |
/** * Evaluate an XACML Request and return a Response * @param request an XACML Request as a RequestType * @return the XACML Response as a ResponseType */ ResponseType evaluate(RequestType request) throws Exception;
Example #15
Source File: AbstractXACMLAuthorizingInterceptor.java From cxf with Apache License 2.0 | votes |
protected abstract ResponseType performRequest(RequestType request, Message message) throws Exception;