org.opensaml.xacml.profile.saml.XACMLAuthzDecisionQueryType Java Examples

The following examples show how to use org.opensaml.xacml.profile.saml.XACMLAuthzDecisionQueryType. 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: XACMLAuthzDecisionQueryTypeUnmarshaller.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/** {@inheritDoc} */
protected void processChildElement(XMLObject parentObject, XMLObject childObject) throws UnmarshallingException {
    XACMLAuthzDecisionQueryType xacmlauthzdecisionquery = (XACMLAuthzDecisionQueryType) parentObject;

    if (childObject instanceof RequestType) {
        xacmlauthzdecisionquery.setRequest((RequestType) childObject);
    } else if (childObject instanceof PolicyType) {
        xacmlauthzdecisionquery.getPolicies().add((PolicyType) childObject);
    } else if (childObject instanceof PolicySetType) {
        xacmlauthzdecisionquery.getPolicySets().add((PolicySetType) childObject);
    } else if (childObject instanceof ReferencedPoliciesType) {
        xacmlauthzdecisionquery.setReferencedPolicies((ReferencedPoliciesType) childObject);
    } else {
        super.processChildElement(parentObject, childObject);
    }
}
 
Example #2
Source File: XACMLAuthzDecisionQueryTypeUnmarshaller.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/** {@inheritDoc} */
protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException {
    XACMLAuthzDecisionQueryType authzDS = (XACMLAuthzDecisionQueryType) samlObject;

    if (attribute.getLocalName().equals(XACMLAuthzDecisionQueryType.INPUTCONTEXTONLY_ATTRIB_NAME)) {
        authzDS.setInputContextOnly(XSBooleanValue.valueOf(attribute.getValue()));
    }

    if (attribute.getLocalName().equals(XACMLAuthzDecisionQueryType.RETURNCONTEXT_ATTRIB_NAME)) {
        authzDS.setReturnContext(XSBooleanValue.valueOf(attribute.getValue()));
    }

    if (attribute.getLocalName().equals(XACMLAuthzDecisionQueryType.COMBINEPOLICIES_ATTRIB_NAME)) {
        authzDS.setCombinePolicies(XSBooleanValue.valueOf(attribute.getValue()));
    }

    super.processAttribute(samlObject, attribute);
}
 
Example #3
Source File: XACMLAuthzDecisionQueryTypeMarshaller.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/** {@inheritDoc} */
protected void marshallAttributes(XMLObject samlObject, Element domElement) throws MarshallingException {
    XACMLAuthzDecisionQueryType query = (XACMLAuthzDecisionQueryType) samlObject;

    if (query.getInputContextOnlyXSBooleanValue() != null) {
        domElement.setAttributeNS(null, XACMLAuthzDecisionQueryType.INPUTCONTEXTONLY_ATTRIB_NAME, query
                .getInputContextOnlyXSBooleanValue().toString());
    }

    if (query.getReturnContextXSBooleanValue() != null) {
        domElement.setAttributeNS(null, XACMLAuthzDecisionQueryType.RETURNCONTEXT_ATTRIB_NAME, query
                .getReturnContextXSBooleanValue().toString());
    }

    if (query.getCombinePoliciesXSBooleanValue() != null) {
        domElement.setAttributeNS(null, XACMLAuthzDecisionQueryType.COMBINEPOLICIES_ATTRIB_NAME, query
                .getCombinePoliciesXSBooleanValue().toString());
    }

    super.marshallAttributes(samlObject, domElement);
}
 
Example #4
Source File: SamlRequestComponentBuilder.java    From cxf with Apache License 2.0 5 votes vote down vote up
/**
 * Create an AuthzDecisionQuery using the defaults
 */
public static XACMLAuthzDecisionQueryType createAuthzDecisionQuery(
    String issuerValue,
    RequestType request,
    String namespace
) {
    return createAuthzDecisionQuery(false, false, issuerValue, request, namespace);
}
 
Example #5
Source File: SamlRequestComponentBuilder.java    From cxf with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public static XACMLAuthzDecisionQueryType createAuthzDecisionQuery(
    boolean inputContextOnly,
    boolean returnContext,
    String issuerValue,
    RequestType request,
    String namespace
) {
    if (xacmlAuthzDecisionQueryTypeBuilder == null) {
        xacmlAuthzDecisionQueryTypeBuilder = (XACMLObjectBuilder<XACMLAuthzDecisionQueryType>)
            builderFactory.getBuilder(XACMLAuthzDecisionQueryType.DEFAULT_ELEMENT_NAME_XACML20);
    }
    XACMLAuthzDecisionQueryType authzQuery =
        xacmlAuthzDecisionQueryTypeBuilder.buildObject(
            namespace,
            XACMLAuthzDecisionQueryType.DEFAULT_ELEMENT_LOCAL_NAME,
            SAMLProfileConstants.SAML20XACMLPROTOCOL_PREFIX
        );
    authzQuery.setID("_" + UUID.randomUUID().toString());
    authzQuery.setVersion(SAMLVersion.VERSION_20);
    authzQuery.setIssueInstant(new DateTime());
    authzQuery.setInputContextOnly(Boolean.valueOf(inputContextOnly));
    authzQuery.setReturnContext(Boolean.valueOf(returnContext));

    if (issuerValue != null) {
        Issuer issuer = createIssuer(issuerValue);
        authzQuery.setIssuer(issuer);
    }

    authzQuery.setRequest(request);

    return authzQuery;
}
 
Example #6
Source File: XACMLAuthzDecisionQueryTypeImplBuilder.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public XACMLAuthzDecisionQueryType buildObject() {
    return null;
}
 
Example #7
Source File: XACMLAuthzDecisionQueryTypeImplBuilder.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/** {@inheritDoc} */
public XACMLAuthzDecisionQueryType buildObject(String namespaceURI, String localName, String namespacePrefix) {
    return new XACMLAuthzDecisionQueryTypeImpl(namespaceURI, localName, namespacePrefix);
}
 
Example #8
Source File: SamlRequestComponentBuilderTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
@org.junit.Test
public void testCreateXACMLSamlAuthzQueryRequest() throws Exception {
    Document doc = docBuilder.newDocument();

    //
    // Create XACML request
    //

    // Subject
    AttributeValueType subjectIdAttributeValue =
        RequestComponentBuilder.createAttributeValueType(
                "[email protected]"
        );
    AttributeType subjectIdAttribute =
        RequestComponentBuilder.createAttributeType(
                XACMLConstants.SUBJECT_ID,
                XACMLConstants.RFC_822_NAME,
                null,
                Collections.singletonList(subjectIdAttributeValue)
        );

    AttributeValueType subjectGroupAttributeValue =
        RequestComponentBuilder.createAttributeValueType(
                "manager"
        );
    AttributeType subjectGroupAttribute =
        RequestComponentBuilder.createAttributeType(
                XACMLConstants.SUBJECT_ROLE,
                XACMLConstants.XS_ANY_URI,
                "[email protected]",
                Collections.singletonList(subjectGroupAttributeValue)
        );
    List<AttributeType> attributes = new ArrayList<>();
    attributes.add(subjectIdAttribute);
    attributes.add(subjectGroupAttribute);
    SubjectType subject = RequestComponentBuilder.createSubjectType(attributes, null);

    // Resource
    AttributeValueType resourceAttributeValue =
        RequestComponentBuilder.createAttributeValueType(
                "{http://www.example.org/contract/DoubleIt}DoubleIt"
        );
    AttributeType resourceAttribute =
        RequestComponentBuilder.createAttributeType(
                XACMLConstants.RESOURCE_ID,
                XACMLConstants.XS_STRING,
                null,
                Collections.singletonList(resourceAttributeValue)
        );
    attributes.clear();
    attributes.add(resourceAttribute);
    ResourceType resource = RequestComponentBuilder.createResourceType(attributes, null);

    // Action
    AttributeValueType actionAttributeValue =
        RequestComponentBuilder.createAttributeValueType(
                "execute"
        );
    AttributeType actionAttribute =
        RequestComponentBuilder.createAttributeType(
                XACMLConstants.ACTION_ID,
                XACMLConstants.XS_STRING,
                null,
                Collections.singletonList(actionAttributeValue)
        );
    attributes.clear();
    attributes.add(actionAttribute);
    ActionType action = RequestComponentBuilder.createActionType(attributes);

    // Request
    RequestType request =
        RequestComponentBuilder.createRequestType(
                Collections.singletonList(subject),
                Collections.singletonList(resource),
                action,
                null
        );

    //
    // Create SAML wrapper
    //

    XACMLAuthzDecisionQueryType authzQuery =
        SamlRequestComponentBuilder.createAuthzDecisionQuery(
                "Issuer", request, SAMLProfileConstants.SAML20XACML20P_NS
        );

    Element policyElement = OpenSAMLUtil.toDom(authzQuery, doc);
    // String outputString = DOM2Writer.nodeToString(policyElement);
    assertNotNull(policyElement);
}