Java Code Examples for com.sun.xml.internal.ws.policy.spi.AssertionCreationException

The following examples show how to use com.sun.xml.internal.ws.policy.spi.AssertionCreationException. These examples are extracted from open source projects. 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
/**
 * Create a new ManagementAssertion instance.
 *
 * @param name The fully qualified name of the server or client assertion. Must
 *   not be null.
 * @param data The assertion data. Must not be null.
 * @param assertionParameters Parameters of the assertion. May be null.
 * @throws AssertionCreationException Thrown if the creation of the assertion failed.
 */
protected ManagementAssertion(final QName name, AssertionData data, Collection<PolicyAssertion> assertionParameters)
        throws AssertionCreationException {
    super(data, assertionParameters);
    if (!name.equals(data.getName())) {
        throw LOGGER.logSevereException(new AssertionCreationException(data,
                ManagementMessages.WSM_1002_EXPECTED_MANAGEMENT_ASSERTION(name)));
    }
    if (isManagementEnabled() && !data.containsAttribute(ID_ATTRIBUTE_QNAME)) {
        throw LOGGER.logSevereException(new AssertionCreationException(data,
                ManagementMessages.WSM_1003_MANAGEMENT_ASSERTION_MISSING_ID(name)));
    }
}
 
Example 2
private List<AssertionSet> normalizeRawAlternative(final RawAlternative alternative) throws AssertionCreationException, PolicyException {
    final List<PolicyAssertion> normalizedContentBase = new LinkedList<PolicyAssertion>();
    final Collection<List<PolicyAssertion>> normalizedContentOptions = new LinkedList<List<PolicyAssertion>>();
    if (!alternative.nestedAssertions.isEmpty()) {
        final Queue<RawAssertion> nestedAssertionsQueue = new LinkedList<RawAssertion>(alternative.nestedAssertions);
        RawAssertion rawAssertion;
        while((rawAssertion = nestedAssertionsQueue.poll()) != null) {
            final List<PolicyAssertion> normalized = normalizeRawAssertion(rawAssertion);
            // if there is only a single result, we can add it direclty to the content base collection
            // more elements in the result indicate that we will have to create combinations
            if (normalized.size() == 1) {
                normalizedContentBase.addAll(normalized);
            } else {
                normalizedContentOptions.add(normalized);
            }
        }
    }

    final List<AssertionSet> options = new LinkedList<AssertionSet>();
    if (normalizedContentOptions.isEmpty()) {
        // we do not have any options to combine => returning this assertion
        options.add(AssertionSet.createAssertionSet(normalizedContentBase));
    } else {
        // we have some options to combine => creating assertion options based on content combinations
        final Collection<Collection<PolicyAssertion>> contentCombinations = PolicyUtils.Collections.combine(normalizedContentBase, normalizedContentOptions, true);
        for (Collection<PolicyAssertion> contentOption : contentCombinations) {
            options.add(AssertionSet.createAssertionSet(contentOption));
        }
    }
    return options;
}
 
Example 3
private List<PolicyAssertion> normalizeRawAssertion(final RawAssertion assertion) throws AssertionCreationException, PolicyException {
    List<PolicyAssertion> parameters;
    if (assertion.parameters.isEmpty()) {
        parameters = null;
    } else {
        parameters = new ArrayList<PolicyAssertion>(assertion.parameters.size());
        for (ModelNode parameterNode : assertion.parameters) {
            parameters.add(createPolicyAssertionParameter(parameterNode));
        }
    }

    final List<AssertionSet> nestedAlternatives = new LinkedList<AssertionSet>();
    if (assertion.nestedAlternatives != null && !assertion.nestedAlternatives.isEmpty()) {
        final Queue<RawAlternative> nestedAlternativeQueue = new LinkedList<RawAlternative>(assertion.nestedAlternatives);
        RawAlternative rawAlternative;
        while((rawAlternative = nestedAlternativeQueue.poll()) != null) {
            nestedAlternatives.addAll(normalizeRawAlternative(rawAlternative));
        }
        // if there is only a single result, we can add it direclty to the content base collection
        // more elements in the result indicate that we will have to create combinations
    }

    final List<PolicyAssertion> assertionOptions = new LinkedList<PolicyAssertion>();
    final boolean nestedAlternativesAvailable = !nestedAlternatives.isEmpty();
    if (nestedAlternativesAvailable) {
        for (AssertionSet nestedAlternative : nestedAlternatives) {
            assertionOptions.add(createPolicyAssertion(assertion.originalNode.getNodeData(), parameters, nestedAlternative));
        }
    } else {
        assertionOptions.add(createPolicyAssertion(assertion.originalNode.getNodeData(), parameters, null));
    }
    return assertionOptions;
}
 
Example 4
private PolicyAssertion createPolicyAssertionParameter(final ModelNode parameterNode) throws AssertionCreationException, PolicyException {
    if (parameterNode.getType() != ModelNode.Type.ASSERTION_PARAMETER_NODE) {
        throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0065_INCONSISTENCY_IN_POLICY_SOURCE_MODEL(parameterNode.getType())));
    }

    List<PolicyAssertion> childParameters = null;
    if (parameterNode.hasChildren()) {
        childParameters = new ArrayList<PolicyAssertion>(parameterNode.childrenSize());
        for (ModelNode childParameterNode : parameterNode) {
            childParameters.add(createPolicyAssertionParameter(childParameterNode));
        }
    }

    return createPolicyAssertion(parameterNode.getNodeData(), childParameters, null /* parameters do not have any nested alternatives */);
}
 
Example 5
private PolicyAssertion createPolicyAssertion(final AssertionData data, final Collection<PolicyAssertion> assertionParameters, final AssertionSet nestedAlternative) throws AssertionCreationException {
    final String assertionNamespace = data.getName().getNamespaceURI();
    final PolicyAssertionCreator domainSpecificPAC = assertionCreators.get(assertionNamespace);


    if (domainSpecificPAC == null) {
        return defaultCreator.createAssertion(data, assertionParameters, nestedAlternative, null);
    } else {
        return domainSpecificPAC.createAssertion(data, assertionParameters, nestedAlternative, defaultCreator);
    }
}
 
Example 6
public PolicyAssertion createAssertion(AssertionData data, Collection<PolicyAssertion> assertionParameters,
        AssertionSet nestedAlternative, PolicyAssertionCreator defaultCreator) throws AssertionCreationException {
    final QName name = data.getName();
    if (ManagedServiceAssertion.MANAGED_SERVICE_QNAME.equals(name)) {
        return new ManagedServiceAssertion(data, assertionParameters);
    }
    else if (ManagedClientAssertion.MANAGED_CLIENT_QNAME.equals(name)) {
        return new ManagedClientAssertion(data, assertionParameters);
    }
    else {
        return defaultCreator.createAssertion(data, assertionParameters, nestedAlternative, null);
    }
}
 
Example 7
Source Project: jdk8u60   Source File: ManagementAssertion.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a new ManagementAssertion instance.
 *
 * @param name The fully qualified name of the server or client assertion. Must
 *   not be null.
 * @param data The assertion data. Must not be null.
 * @param assertionParameters Parameters of the assertion. May be null.
 * @throws AssertionCreationException Thrown if the creation of the assertion failed.
 */
protected ManagementAssertion(final QName name, AssertionData data, Collection<PolicyAssertion> assertionParameters)
        throws AssertionCreationException {
    super(data, assertionParameters);
    if (!name.equals(data.getName())) {
        throw LOGGER.logSevereException(new AssertionCreationException(data,
                ManagementMessages.WSM_1002_EXPECTED_MANAGEMENT_ASSERTION(name)));
    }
    if (isManagementEnabled() && !data.containsAttribute(ID_ATTRIBUTE_QNAME)) {
        throw LOGGER.logSevereException(new AssertionCreationException(data,
                ManagementMessages.WSM_1003_MANAGEMENT_ASSERTION_MISSING_ID(name)));
    }
}
 
Example 8
private List<AssertionSet> normalizeRawAlternative(final RawAlternative alternative) throws AssertionCreationException, PolicyException {
    final List<PolicyAssertion> normalizedContentBase = new LinkedList<PolicyAssertion>();
    final Collection<List<PolicyAssertion>> normalizedContentOptions = new LinkedList<List<PolicyAssertion>>();
    if (!alternative.nestedAssertions.isEmpty()) {
        final Queue<RawAssertion> nestedAssertionsQueue = new LinkedList<RawAssertion>(alternative.nestedAssertions);
        RawAssertion rawAssertion;
        while((rawAssertion = nestedAssertionsQueue.poll()) != null) {
            final List<PolicyAssertion> normalized = normalizeRawAssertion(rawAssertion);
            // if there is only a single result, we can add it direclty to the content base collection
            // more elements in the result indicate that we will have to create combinations
            if (normalized.size() == 1) {
                normalizedContentBase.addAll(normalized);
            } else {
                normalizedContentOptions.add(normalized);
            }
        }
    }

    final List<AssertionSet> options = new LinkedList<AssertionSet>();
    if (normalizedContentOptions.isEmpty()) {
        // we do not have any options to combine => returning this assertion
        options.add(AssertionSet.createAssertionSet(normalizedContentBase));
    } else {
        // we have some options to combine => creating assertion options based on content combinations
        final Collection<Collection<PolicyAssertion>> contentCombinations = PolicyUtils.Collections.combine(normalizedContentBase, normalizedContentOptions, true);
        for (Collection<PolicyAssertion> contentOption : contentCombinations) {
            options.add(AssertionSet.createAssertionSet(contentOption));
        }
    }
    return options;
}
 
Example 9
private List<PolicyAssertion> normalizeRawAssertion(final RawAssertion assertion) throws AssertionCreationException, PolicyException {
    List<PolicyAssertion> parameters;
    if (assertion.parameters.isEmpty()) {
        parameters = null;
    } else {
        parameters = new ArrayList<PolicyAssertion>(assertion.parameters.size());
        for (ModelNode parameterNode : assertion.parameters) {
            parameters.add(createPolicyAssertionParameter(parameterNode));
        }
    }

    final List<AssertionSet> nestedAlternatives = new LinkedList<AssertionSet>();
    if (assertion.nestedAlternatives != null && !assertion.nestedAlternatives.isEmpty()) {
        final Queue<RawAlternative> nestedAlternativeQueue = new LinkedList<RawAlternative>(assertion.nestedAlternatives);
        RawAlternative rawAlternative;
        while((rawAlternative = nestedAlternativeQueue.poll()) != null) {
            nestedAlternatives.addAll(normalizeRawAlternative(rawAlternative));
        }
        // if there is only a single result, we can add it direclty to the content base collection
        // more elements in the result indicate that we will have to create combinations
    }

    final List<PolicyAssertion> assertionOptions = new LinkedList<PolicyAssertion>();
    final boolean nestedAlternativesAvailable = !nestedAlternatives.isEmpty();
    if (nestedAlternativesAvailable) {
        for (AssertionSet nestedAlternative : nestedAlternatives) {
            assertionOptions.add(createPolicyAssertion(assertion.originalNode.getNodeData(), parameters, nestedAlternative));
        }
    } else {
        assertionOptions.add(createPolicyAssertion(assertion.originalNode.getNodeData(), parameters, null));
    }
    return assertionOptions;
}
 
Example 10
private PolicyAssertion createPolicyAssertionParameter(final ModelNode parameterNode) throws AssertionCreationException, PolicyException {
    if (parameterNode.getType() != ModelNode.Type.ASSERTION_PARAMETER_NODE) {
        throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0065_INCONSISTENCY_IN_POLICY_SOURCE_MODEL(parameterNode.getType())));
    }

    List<PolicyAssertion> childParameters = null;
    if (parameterNode.hasChildren()) {
        childParameters = new ArrayList<PolicyAssertion>(parameterNode.childrenSize());
        for (ModelNode childParameterNode : parameterNode) {
            childParameters.add(createPolicyAssertionParameter(childParameterNode));
        }
    }

    return createPolicyAssertion(parameterNode.getNodeData(), childParameters, null /* parameters do not have any nested alternatives */);
}
 
Example 11
private PolicyAssertion createPolicyAssertion(final AssertionData data, final Collection<PolicyAssertion> assertionParameters, final AssertionSet nestedAlternative) throws AssertionCreationException {
    final String assertionNamespace = data.getName().getNamespaceURI();
    final PolicyAssertionCreator domainSpecificPAC = assertionCreators.get(assertionNamespace);


    if (domainSpecificPAC == null) {
        return defaultCreator.createAssertion(data, assertionParameters, nestedAlternative, null);
    } else {
        return domainSpecificPAC.createAssertion(data, assertionParameters, nestedAlternative, defaultCreator);
    }
}
 
Example 12
public PolicyAssertion createAssertion(AssertionData data, Collection<PolicyAssertion> assertionParameters,
        AssertionSet nestedAlternative, PolicyAssertionCreator defaultCreator) throws AssertionCreationException {
    final QName name = data.getName();
    if (ManagedServiceAssertion.MANAGED_SERVICE_QNAME.equals(name)) {
        return new ManagedServiceAssertion(data, assertionParameters);
    }
    else if (ManagedClientAssertion.MANAGED_CLIENT_QNAME.equals(name)) {
        return new ManagedClientAssertion(data, assertionParameters);
    }
    else {
        return defaultCreator.createAssertion(data, assertionParameters, nestedAlternative, null);
    }
}
 
Example 13
/**
 * Create a new ManagementAssertion instance.
 *
 * @param name The fully qualified name of the server or client assertion. Must
 *   not be null.
 * @param data The assertion data. Must not be null.
 * @param assertionParameters Parameters of the assertion. May be null.
 * @throws AssertionCreationException Thrown if the creation of the assertion failed.
 */
protected ManagementAssertion(final QName name, AssertionData data, Collection<PolicyAssertion> assertionParameters)
        throws AssertionCreationException {
    super(data, assertionParameters);
    if (!name.equals(data.getName())) {
        throw LOGGER.logSevereException(new AssertionCreationException(data,
                ManagementMessages.WSM_1002_EXPECTED_MANAGEMENT_ASSERTION(name)));
    }
    if (isManagementEnabled() && !data.containsAttribute(ID_ATTRIBUTE_QNAME)) {
        throw LOGGER.logSevereException(new AssertionCreationException(data,
                ManagementMessages.WSM_1003_MANAGEMENT_ASSERTION_MISSING_ID(name)));
    }
}
 
Example 14
private List<AssertionSet> normalizeRawAlternative(final RawAlternative alternative) throws AssertionCreationException, PolicyException {
    final List<PolicyAssertion> normalizedContentBase = new LinkedList<PolicyAssertion>();
    final Collection<List<PolicyAssertion>> normalizedContentOptions = new LinkedList<List<PolicyAssertion>>();
    if (!alternative.nestedAssertions.isEmpty()) {
        final Queue<RawAssertion> nestedAssertionsQueue = new LinkedList<RawAssertion>(alternative.nestedAssertions);
        RawAssertion rawAssertion;
        while((rawAssertion = nestedAssertionsQueue.poll()) != null) {
            final List<PolicyAssertion> normalized = normalizeRawAssertion(rawAssertion);
            // if there is only a single result, we can add it direclty to the content base collection
            // more elements in the result indicate that we will have to create combinations
            if (normalized.size() == 1) {
                normalizedContentBase.addAll(normalized);
            } else {
                normalizedContentOptions.add(normalized);
            }
        }
    }

    final List<AssertionSet> options = new LinkedList<AssertionSet>();
    if (normalizedContentOptions.isEmpty()) {
        // we do not have any options to combine => returning this assertion
        options.add(AssertionSet.createAssertionSet(normalizedContentBase));
    } else {
        // we have some options to combine => creating assertion options based on content combinations
        final Collection<Collection<PolicyAssertion>> contentCombinations = PolicyUtils.Collections.combine(normalizedContentBase, normalizedContentOptions, true);
        for (Collection<PolicyAssertion> contentOption : contentCombinations) {
            options.add(AssertionSet.createAssertionSet(contentOption));
        }
    }
    return options;
}
 
Example 15
private List<PolicyAssertion> normalizeRawAssertion(final RawAssertion assertion) throws AssertionCreationException, PolicyException {
    List<PolicyAssertion> parameters;
    if (assertion.parameters.isEmpty()) {
        parameters = null;
    } else {
        parameters = new ArrayList<PolicyAssertion>(assertion.parameters.size());
        for (ModelNode parameterNode : assertion.parameters) {
            parameters.add(createPolicyAssertionParameter(parameterNode));
        }
    }

    final List<AssertionSet> nestedAlternatives = new LinkedList<AssertionSet>();
    if (assertion.nestedAlternatives != null && !assertion.nestedAlternatives.isEmpty()) {
        final Queue<RawAlternative> nestedAlternativeQueue = new LinkedList<RawAlternative>(assertion.nestedAlternatives);
        RawAlternative rawAlternative;
        while((rawAlternative = nestedAlternativeQueue.poll()) != null) {
            nestedAlternatives.addAll(normalizeRawAlternative(rawAlternative));
        }
        // if there is only a single result, we can add it direclty to the content base collection
        // more elements in the result indicate that we will have to create combinations
    }

    final List<PolicyAssertion> assertionOptions = new LinkedList<PolicyAssertion>();
    final boolean nestedAlternativesAvailable = !nestedAlternatives.isEmpty();
    if (nestedAlternativesAvailable) {
        for (AssertionSet nestedAlternative : nestedAlternatives) {
            assertionOptions.add(createPolicyAssertion(assertion.originalNode.getNodeData(), parameters, nestedAlternative));
        }
    } else {
        assertionOptions.add(createPolicyAssertion(assertion.originalNode.getNodeData(), parameters, null));
    }
    return assertionOptions;
}
 
Example 16
private PolicyAssertion createPolicyAssertionParameter(final ModelNode parameterNode) throws AssertionCreationException, PolicyException {
    if (parameterNode.getType() != ModelNode.Type.ASSERTION_PARAMETER_NODE) {
        throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0065_INCONSISTENCY_IN_POLICY_SOURCE_MODEL(parameterNode.getType())));
    }

    List<PolicyAssertion> childParameters = null;
    if (parameterNode.hasChildren()) {
        childParameters = new ArrayList<PolicyAssertion>(parameterNode.childrenSize());
        for (ModelNode childParameterNode : parameterNode) {
            childParameters.add(createPolicyAssertionParameter(childParameterNode));
        }
    }

    return createPolicyAssertion(parameterNode.getNodeData(), childParameters, null /* parameters do not have any nested alternatives */);
}
 
Example 17
private PolicyAssertion createPolicyAssertion(final AssertionData data, final Collection<PolicyAssertion> assertionParameters, final AssertionSet nestedAlternative) throws AssertionCreationException {
    final String assertionNamespace = data.getName().getNamespaceURI();
    final PolicyAssertionCreator domainSpecificPAC = assertionCreators.get(assertionNamespace);


    if (domainSpecificPAC == null) {
        return defaultCreator.createAssertion(data, assertionParameters, nestedAlternative, null);
    } else {
        return domainSpecificPAC.createAssertion(data, assertionParameters, nestedAlternative, defaultCreator);
    }
}
 
Example 18
public PolicyAssertion createAssertion(AssertionData data, Collection<PolicyAssertion> assertionParameters,
        AssertionSet nestedAlternative, PolicyAssertionCreator defaultCreator) throws AssertionCreationException {
    final QName name = data.getName();
    if (ManagedServiceAssertion.MANAGED_SERVICE_QNAME.equals(name)) {
        return new ManagedServiceAssertion(data, assertionParameters);
    }
    else if (ManagedClientAssertion.MANAGED_CLIENT_QNAME.equals(name)) {
        return new ManagedClientAssertion(data, assertionParameters);
    }
    else {
        return defaultCreator.createAssertion(data, assertionParameters, nestedAlternative, null);
    }
}
 
Example 19
/**
 * Create a new ManagementAssertion instance.
 *
 * @param name The fully qualified name of the server or client assertion. Must
 *   not be null.
 * @param data The assertion data. Must not be null.
 * @param assertionParameters Parameters of the assertion. May be null.
 * @throws AssertionCreationException Thrown if the creation of the assertion failed.
 */
protected ManagementAssertion(final QName name, AssertionData data, Collection<PolicyAssertion> assertionParameters)
        throws AssertionCreationException {
    super(data, assertionParameters);
    if (!name.equals(data.getName())) {
        throw LOGGER.logSevereException(new AssertionCreationException(data,
                ManagementMessages.WSM_1002_EXPECTED_MANAGEMENT_ASSERTION(name)));
    }
    if (isManagementEnabled() && !data.containsAttribute(ID_ATTRIBUTE_QNAME)) {
        throw LOGGER.logSevereException(new AssertionCreationException(data,
                ManagementMessages.WSM_1003_MANAGEMENT_ASSERTION_MISSING_ID(name)));
    }
}
 
Example 20
private List<AssertionSet> normalizeRawAlternative(final RawAlternative alternative) throws AssertionCreationException, PolicyException {
    final List<PolicyAssertion> normalizedContentBase = new LinkedList<PolicyAssertion>();
    final Collection<List<PolicyAssertion>> normalizedContentOptions = new LinkedList<List<PolicyAssertion>>();
    if (!alternative.nestedAssertions.isEmpty()) {
        final Queue<RawAssertion> nestedAssertionsQueue = new LinkedList<RawAssertion>(alternative.nestedAssertions);
        RawAssertion rawAssertion;
        while((rawAssertion = nestedAssertionsQueue.poll()) != null) {
            final List<PolicyAssertion> normalized = normalizeRawAssertion(rawAssertion);
            // if there is only a single result, we can add it direclty to the content base collection
            // more elements in the result indicate that we will have to create combinations
            if (normalized.size() == 1) {
                normalizedContentBase.addAll(normalized);
            } else {
                normalizedContentOptions.add(normalized);
            }
        }
    }

    final List<AssertionSet> options = new LinkedList<AssertionSet>();
    if (normalizedContentOptions.isEmpty()) {
        // we do not have any options to combine => returning this assertion
        options.add(AssertionSet.createAssertionSet(normalizedContentBase));
    } else {
        // we have some options to combine => creating assertion options based on content combinations
        final Collection<Collection<PolicyAssertion>> contentCombinations = PolicyUtils.Collections.combine(normalizedContentBase, normalizedContentOptions, true);
        for (Collection<PolicyAssertion> contentOption : contentCombinations) {
            options.add(AssertionSet.createAssertionSet(contentOption));
        }
    }
    return options;
}
 
Example 21
private List<PolicyAssertion> normalizeRawAssertion(final RawAssertion assertion) throws AssertionCreationException, PolicyException {
    List<PolicyAssertion> parameters;
    if (assertion.parameters.isEmpty()) {
        parameters = null;
    } else {
        parameters = new ArrayList<PolicyAssertion>(assertion.parameters.size());
        for (ModelNode parameterNode : assertion.parameters) {
            parameters.add(createPolicyAssertionParameter(parameterNode));
        }
    }

    final List<AssertionSet> nestedAlternatives = new LinkedList<AssertionSet>();
    if (assertion.nestedAlternatives != null && !assertion.nestedAlternatives.isEmpty()) {
        final Queue<RawAlternative> nestedAlternativeQueue = new LinkedList<RawAlternative>(assertion.nestedAlternatives);
        RawAlternative rawAlternative;
        while((rawAlternative = nestedAlternativeQueue.poll()) != null) {
            nestedAlternatives.addAll(normalizeRawAlternative(rawAlternative));
        }
        // if there is only a single result, we can add it direclty to the content base collection
        // more elements in the result indicate that we will have to create combinations
    }

    final List<PolicyAssertion> assertionOptions = new LinkedList<PolicyAssertion>();
    final boolean nestedAlternativesAvailable = !nestedAlternatives.isEmpty();
    if (nestedAlternativesAvailable) {
        for (AssertionSet nestedAlternative : nestedAlternatives) {
            assertionOptions.add(createPolicyAssertion(assertion.originalNode.getNodeData(), parameters, nestedAlternative));
        }
    } else {
        assertionOptions.add(createPolicyAssertion(assertion.originalNode.getNodeData(), parameters, null));
    }
    return assertionOptions;
}
 
Example 22
private PolicyAssertion createPolicyAssertionParameter(final ModelNode parameterNode) throws AssertionCreationException, PolicyException {
    if (parameterNode.getType() != ModelNode.Type.ASSERTION_PARAMETER_NODE) {
        throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0065_INCONSISTENCY_IN_POLICY_SOURCE_MODEL(parameterNode.getType())));
    }

    List<PolicyAssertion> childParameters = null;
    if (parameterNode.hasChildren()) {
        childParameters = new ArrayList<PolicyAssertion>(parameterNode.childrenSize());
        for (ModelNode childParameterNode : parameterNode) {
            childParameters.add(createPolicyAssertionParameter(childParameterNode));
        }
    }

    return createPolicyAssertion(parameterNode.getNodeData(), childParameters, null /* parameters do not have any nested alternatives */);
}
 
Example 23
private PolicyAssertion createPolicyAssertion(final AssertionData data, final Collection<PolicyAssertion> assertionParameters, final AssertionSet nestedAlternative) throws AssertionCreationException {
    final String assertionNamespace = data.getName().getNamespaceURI();
    final PolicyAssertionCreator domainSpecificPAC = assertionCreators.get(assertionNamespace);


    if (domainSpecificPAC == null) {
        return defaultCreator.createAssertion(data, assertionParameters, nestedAlternative, null);
    } else {
        return domainSpecificPAC.createAssertion(data, assertionParameters, nestedAlternative, defaultCreator);
    }
}
 
Example 24
public PolicyAssertion createAssertion(AssertionData data, Collection<PolicyAssertion> assertionParameters,
        AssertionSet nestedAlternative, PolicyAssertionCreator defaultCreator) throws AssertionCreationException {
    final QName name = data.getName();
    if (ManagedServiceAssertion.MANAGED_SERVICE_QNAME.equals(name)) {
        return new ManagedServiceAssertion(data, assertionParameters);
    }
    else if (ManagedClientAssertion.MANAGED_CLIENT_QNAME.equals(name)) {
        return new ManagedClientAssertion(data, assertionParameters);
    }
    else {
        return defaultCreator.createAssertion(data, assertionParameters, nestedAlternative, null);
    }
}
 
Example 25
/**
 * Create a new ManagementAssertion instance.
 *
 * @param name The fully qualified name of the server or client assertion. Must
 *   not be null.
 * @param data The assertion data. Must not be null.
 * @param assertionParameters Parameters of the assertion. May be null.
 * @throws AssertionCreationException Thrown if the creation of the assertion failed.
 */
protected ManagementAssertion(final QName name, AssertionData data, Collection<PolicyAssertion> assertionParameters)
        throws AssertionCreationException {
    super(data, assertionParameters);
    if (!name.equals(data.getName())) {
        throw LOGGER.logSevereException(new AssertionCreationException(data,
                ManagementMessages.WSM_1002_EXPECTED_MANAGEMENT_ASSERTION(name)));
    }
    if (isManagementEnabled() && !data.containsAttribute(ID_ATTRIBUTE_QNAME)) {
        throw LOGGER.logSevereException(new AssertionCreationException(data,
                ManagementMessages.WSM_1003_MANAGEMENT_ASSERTION_MISSING_ID(name)));
    }
}
 
Example 26
private List<AssertionSet> normalizeRawAlternative(final RawAlternative alternative) throws AssertionCreationException, PolicyException {
    final List<PolicyAssertion> normalizedContentBase = new LinkedList<PolicyAssertion>();
    final Collection<List<PolicyAssertion>> normalizedContentOptions = new LinkedList<List<PolicyAssertion>>();
    if (!alternative.nestedAssertions.isEmpty()) {
        final Queue<RawAssertion> nestedAssertionsQueue = new LinkedList<RawAssertion>(alternative.nestedAssertions);
        RawAssertion rawAssertion;
        while((rawAssertion = nestedAssertionsQueue.poll()) != null) {
            final List<PolicyAssertion> normalized = normalizeRawAssertion(rawAssertion);
            // if there is only a single result, we can add it direclty to the content base collection
            // more elements in the result indicate that we will have to create combinations
            if (normalized.size() == 1) {
                normalizedContentBase.addAll(normalized);
            } else {
                normalizedContentOptions.add(normalized);
            }
        }
    }

    final List<AssertionSet> options = new LinkedList<AssertionSet>();
    if (normalizedContentOptions.isEmpty()) {
        // we do not have any options to combine => returning this assertion
        options.add(AssertionSet.createAssertionSet(normalizedContentBase));
    } else {
        // we have some options to combine => creating assertion options based on content combinations
        final Collection<Collection<PolicyAssertion>> contentCombinations = PolicyUtils.Collections.combine(normalizedContentBase, normalizedContentOptions, true);
        for (Collection<PolicyAssertion> contentOption : contentCombinations) {
            options.add(AssertionSet.createAssertionSet(contentOption));
        }
    }
    return options;
}
 
Example 27
private List<PolicyAssertion> normalizeRawAssertion(final RawAssertion assertion) throws AssertionCreationException, PolicyException {
    List<PolicyAssertion> parameters;
    if (assertion.parameters.isEmpty()) {
        parameters = null;
    } else {
        parameters = new ArrayList<PolicyAssertion>(assertion.parameters.size());
        for (ModelNode parameterNode : assertion.parameters) {
            parameters.add(createPolicyAssertionParameter(parameterNode));
        }
    }

    final List<AssertionSet> nestedAlternatives = new LinkedList<AssertionSet>();
    if (assertion.nestedAlternatives != null && !assertion.nestedAlternatives.isEmpty()) {
        final Queue<RawAlternative> nestedAlternativeQueue = new LinkedList<RawAlternative>(assertion.nestedAlternatives);
        RawAlternative rawAlternative;
        while((rawAlternative = nestedAlternativeQueue.poll()) != null) {
            nestedAlternatives.addAll(normalizeRawAlternative(rawAlternative));
        }
        // if there is only a single result, we can add it direclty to the content base collection
        // more elements in the result indicate that we will have to create combinations
    }

    final List<PolicyAssertion> assertionOptions = new LinkedList<PolicyAssertion>();
    final boolean nestedAlternativesAvailable = !nestedAlternatives.isEmpty();
    if (nestedAlternativesAvailable) {
        for (AssertionSet nestedAlternative : nestedAlternatives) {
            assertionOptions.add(createPolicyAssertion(assertion.originalNode.getNodeData(), parameters, nestedAlternative));
        }
    } else {
        assertionOptions.add(createPolicyAssertion(assertion.originalNode.getNodeData(), parameters, null));
    }
    return assertionOptions;
}
 
Example 28
private PolicyAssertion createPolicyAssertionParameter(final ModelNode parameterNode) throws AssertionCreationException, PolicyException {
    if (parameterNode.getType() != ModelNode.Type.ASSERTION_PARAMETER_NODE) {
        throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0065_INCONSISTENCY_IN_POLICY_SOURCE_MODEL(parameterNode.getType())));
    }

    List<PolicyAssertion> childParameters = null;
    if (parameterNode.hasChildren()) {
        childParameters = new ArrayList<PolicyAssertion>(parameterNode.childrenSize());
        for (ModelNode childParameterNode : parameterNode) {
            childParameters.add(createPolicyAssertionParameter(childParameterNode));
        }
    }

    return createPolicyAssertion(parameterNode.getNodeData(), childParameters, null /* parameters do not have any nested alternatives */);
}
 
Example 29
private PolicyAssertion createPolicyAssertion(final AssertionData data, final Collection<PolicyAssertion> assertionParameters, final AssertionSet nestedAlternative) throws AssertionCreationException {
    final String assertionNamespace = data.getName().getNamespaceURI();
    final PolicyAssertionCreator domainSpecificPAC = assertionCreators.get(assertionNamespace);


    if (domainSpecificPAC == null) {
        return defaultCreator.createAssertion(data, assertionParameters, nestedAlternative, null);
    } else {
        return domainSpecificPAC.createAssertion(data, assertionParameters, nestedAlternative, defaultCreator);
    }
}
 
Example 30
public PolicyAssertion createAssertion(AssertionData data, Collection<PolicyAssertion> assertionParameters,
        AssertionSet nestedAlternative, PolicyAssertionCreator defaultCreator) throws AssertionCreationException {
    final QName name = data.getName();
    if (ManagedServiceAssertion.MANAGED_SERVICE_QNAME.equals(name)) {
        return new ManagedServiceAssertion(data, assertionParameters);
    }
    else if (ManagedClientAssertion.MANAGED_CLIENT_QNAME.equals(name)) {
        return new ManagedClientAssertion(data, assertionParameters);
    }
    else {
        return defaultCreator.createAssertion(data, assertionParameters, nestedAlternative, null);
    }
}