com.sun.xml.internal.ws.policy.PolicyAssertion Java Examples
The following examples show how to use
com.sun.xml.internal.ws.policy.PolicyAssertion.
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: FastInfosetFeatureConfigurator.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Process FastInfoset policy assertions. * * @param key Key to identify the endpoint scope. * @param policyMap the policy map. * @throws PolicyException If retrieving the policy triggered an exception. */ public Collection<WebServiceFeature> getFeatures(final PolicyMapKey key, final PolicyMap policyMap) throws PolicyException { final Collection<WebServiceFeature> features = new LinkedList<WebServiceFeature>(); if ((key != null) && (policyMap != null)) { Policy policy = policyMap.getEndpointEffectivePolicy(key); if (null!=policy && policy.contains(OPTIMIZED_FI_SERIALIZATION_ASSERTION)) { Iterator <AssertionSet> assertions = policy.iterator(); while(assertions.hasNext()){ AssertionSet assertionSet = assertions.next(); Iterator<PolicyAssertion> policyAssertion = assertionSet.iterator(); while(policyAssertion.hasNext()){ PolicyAssertion assertion = policyAssertion.next(); if(OPTIMIZED_FI_SERIALIZATION_ASSERTION.equals(assertion.getName())){ String value = assertion.getAttributeValue(enabled); boolean isFastInfosetEnabled = Boolean.valueOf(value.trim()); features.add(new FastInfosetFeature(isFastInfosetEnabled)); } // end-if non optional fast infoset assertion found } // next assertion } // next alternative } // end-if policy contains fast infoset assertion } return features; }
Example #2
Source File: DefaultPolicyResolver.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Checks if the PolicyMap has only single alternative in the scope. * * @param policyMap * PolicyMap that needs to be validated. */ private void validateServerPolicyMap(PolicyMap policyMap) { try { final ValidationProcessor validationProcessor = ValidationProcessor.getInstance(); for (Policy policy : policyMap) { // TODO: here is a good place to check if the actual policy has only one alternative... for (AssertionSet assertionSet : policy) { for (PolicyAssertion assertion : assertionSet) { Fitness validationResult = validationProcessor.validateServerSide(assertion); if (validationResult != Fitness.SUPPORTED) { throw new PolicyException(PolicyMessages.WSP_1015_SERVER_SIDE_ASSERTION_VALIDATION_FAILED( assertion.getName(), validationResult)); } } } } } catch (PolicyException e) { throw new WebServiceException(e); } }
Example #3
Source File: SelectOptimalEncodingFeatureConfigurator.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * Process SelectOptimalEncoding policy assertions. * * @param key Key that identifies the endpoint scope. * @param policyMap The policy map. * @throws PolicyException If retrieving the policy triggered an exception. */ public Collection<WebServiceFeature> getFeatures(PolicyMapKey key, PolicyMap policyMap) throws PolicyException { final Collection<WebServiceFeature> features = new LinkedList<WebServiceFeature>(); if ((key != null) && (policyMap != null)) { Policy policy = policyMap.getEndpointEffectivePolicy(key); if (null!=policy && policy.contains(SELECT_OPTIMAL_ENCODING_ASSERTION)) { Iterator <AssertionSet> assertions = policy.iterator(); while(assertions.hasNext()){ AssertionSet assertionSet = assertions.next(); Iterator<PolicyAssertion> policyAssertion = assertionSet.iterator(); while(policyAssertion.hasNext()){ PolicyAssertion assertion = policyAssertion.next(); if(SELECT_OPTIMAL_ENCODING_ASSERTION.equals(assertion.getName())){ String value = assertion.getAttributeValue(enabled); boolean isSelectOptimalEncodingEnabled = value == null || Boolean.valueOf(value.trim()); features.add(new SelectOptimalEncodingFeature(isSelectOptimalEncodingEnabled)); } } } } } return features; }
Example #4
Source File: SelectOptimalEncodingFeatureConfigurator.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Process SelectOptimalEncoding policy assertions. * * @param key Key that identifies the endpoint scope. * @param policyMap The policy map. * @throws PolicyException If retrieving the policy triggered an exception. */ public Collection<WebServiceFeature> getFeatures(PolicyMapKey key, PolicyMap policyMap) throws PolicyException { final Collection<WebServiceFeature> features = new LinkedList<WebServiceFeature>(); if ((key != null) && (policyMap != null)) { Policy policy = policyMap.getEndpointEffectivePolicy(key); if (null!=policy && policy.contains(SELECT_OPTIMAL_ENCODING_ASSERTION)) { Iterator <AssertionSet> assertions = policy.iterator(); while(assertions.hasNext()){ AssertionSet assertionSet = assertions.next(); Iterator<PolicyAssertion> policyAssertion = assertionSet.iterator(); while(policyAssertion.hasNext()){ PolicyAssertion assertion = policyAssertion.next(); if(SELECT_OPTIMAL_ENCODING_ASSERTION.equals(assertion.getName())){ String value = assertion.getAttributeValue(enabled); boolean isSelectOptimalEncodingEnabled = value == null || Boolean.valueOf(value.trim()); features.add(new SelectOptimalEncodingFeature(isSelectOptimalEncodingEnabled)); } } } } } return features; }
Example #5
Source File: MtomFeatureConfigurator.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * process Mtom policy assertions and if found and is not optional then mtom is enabled on the * {@link WSDLBoundPortType} * * @param key Key that identifies the endpoint scope * @param policyMap Must be non-null * @throws PolicyException If retrieving the policy triggered an exception */ public Collection<WebServiceFeature> getFeatures(PolicyMapKey key, PolicyMap policyMap) throws PolicyException { final Collection<WebServiceFeature> features = new LinkedList<WebServiceFeature>(); if ((key != null) && (policyMap != null)) { Policy policy = policyMap.getEndpointEffectivePolicy(key); if (null!=policy && policy.contains(OPTIMIZED_MIME_SERIALIZATION_ASSERTION)) { Iterator <AssertionSet> assertions = policy.iterator(); while(assertions.hasNext()){ AssertionSet assertionSet = assertions.next(); Iterator<PolicyAssertion> policyAssertion = assertionSet.iterator(); while(policyAssertion.hasNext()){ PolicyAssertion assertion = policyAssertion.next(); if(OPTIMIZED_MIME_SERIALIZATION_ASSERTION.equals(assertion.getName())){ features.add(new MTOMFeature(true)); } // end-if non optional mtom assertion found } // next assertion } // next alternative } // end-if policy contains mtom assertion } return features; }
Example #6
Source File: ManagementAssertion.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * Return ManagementAssertion if one can be found in the policy map under * the given service and port name. * * @param <T> The implementation class of the assertion. * @param name The fully qualified name of the server or client assertion. * @param policyMap The policy map. May be null. * @param serviceName The WSDL service name. May not be null. * @param portName The WSDL port name. May not be null. * @param type The implementation class of the assertion. * @return An instance of ManagementAssertion or null. * @throws WebServiceException If computing the effective policy of the endpoint scope failed. */ protected static <T extends ManagementAssertion> T getAssertion(final QName name, final PolicyMap policyMap, QName serviceName, QName portName, Class<T> type) throws WebServiceException { try { PolicyAssertion assertion = null; if (policyMap != null) { final PolicyMapKey key = PolicyMap.createWsdlEndpointScopeKey(serviceName, portName); final Policy policy = policyMap.getEndpointEffectivePolicy(key); if (policy != null) { final Iterator<AssertionSet> assertionSets = policy.iterator(); if (assertionSets.hasNext()) { final AssertionSet assertionSet = assertionSets.next(); final Iterator<PolicyAssertion> assertions = assertionSet.get(name).iterator(); if (assertions.hasNext()) { assertion = assertions.next(); } } } } return assertion == null ? null : assertion.getImplementation(type); } catch (PolicyException ex) { throw LOGGER.logSevereException(new WebServiceException( ManagementMessages.WSM_1001_FAILED_ASSERTION(name), ex)); } }
Example #7
Source File: MtomFeatureConfigurator.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * process Mtom policy assertions and if found and is not optional then mtom is enabled on the * {@link WSDLBoundPortType} * * @param key Key that identifies the endpoint scope * @param policyMap Must be non-null * @throws PolicyException If retrieving the policy triggered an exception */ public Collection<WebServiceFeature> getFeatures(PolicyMapKey key, PolicyMap policyMap) throws PolicyException { final Collection<WebServiceFeature> features = new LinkedList<WebServiceFeature>(); if ((key != null) && (policyMap != null)) { Policy policy = policyMap.getEndpointEffectivePolicy(key); if (null!=policy && policy.contains(OPTIMIZED_MIME_SERIALIZATION_ASSERTION)) { Iterator <AssertionSet> assertions = policy.iterator(); while(assertions.hasNext()){ AssertionSet assertionSet = assertions.next(); Iterator<PolicyAssertion> policyAssertion = assertionSet.iterator(); while(policyAssertion.hasNext()){ PolicyAssertion assertion = policyAssertion.next(); if(OPTIMIZED_MIME_SERIALIZATION_ASSERTION.equals(assertion.getName())){ features.add(new MTOMFeature(true)); } // end-if non optional mtom assertion found } // next assertion } // next alternative } // end-if policy contains mtom assertion } return features; }
Example #8
Source File: SelectOptimalEncodingFeatureConfigurator.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Process SelectOptimalEncoding policy assertions. * * @param key Key that identifies the endpoint scope. * @param policyMap The policy map. * @throws PolicyException If retrieving the policy triggered an exception. */ public Collection<WebServiceFeature> getFeatures(PolicyMapKey key, PolicyMap policyMap) throws PolicyException { final Collection<WebServiceFeature> features = new LinkedList<WebServiceFeature>(); if ((key != null) && (policyMap != null)) { Policy policy = policyMap.getEndpointEffectivePolicy(key); if (null!=policy && policy.contains(SELECT_OPTIMAL_ENCODING_ASSERTION)) { Iterator <AssertionSet> assertions = policy.iterator(); while(assertions.hasNext()){ AssertionSet assertionSet = assertions.next(); Iterator<PolicyAssertion> policyAssertion = assertionSet.iterator(); while(policyAssertion.hasNext()){ PolicyAssertion assertion = policyAssertion.next(); if(SELECT_OPTIMAL_ENCODING_ASSERTION.equals(assertion.getName())){ String value = assertion.getAttributeValue(enabled); boolean isSelectOptimalEncodingEnabled = value == null || Boolean.valueOf(value.trim()); features.add(new SelectOptimalEncodingFeature(isSelectOptimalEncodingEnabled)); } } } } } return features; }
Example #9
Source File: SelectOptimalEncodingFeatureConfigurator.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Process SelectOptimalEncoding policy assertions. * * @param key Key that identifies the endpoint scope. * @param policyMap The policy map. * @throws PolicyException If retrieving the policy triggered an exception. */ public Collection<WebServiceFeature> getFeatures(PolicyMapKey key, PolicyMap policyMap) throws PolicyException { final Collection<WebServiceFeature> features = new LinkedList<WebServiceFeature>(); if ((key != null) && (policyMap != null)) { Policy policy = policyMap.getEndpointEffectivePolicy(key); if (null!=policy && policy.contains(SELECT_OPTIMAL_ENCODING_ASSERTION)) { Iterator <AssertionSet> assertions = policy.iterator(); while(assertions.hasNext()){ AssertionSet assertionSet = assertions.next(); Iterator<PolicyAssertion> policyAssertion = assertionSet.iterator(); while(policyAssertion.hasNext()){ PolicyAssertion assertion = policyAssertion.next(); if(SELECT_OPTIMAL_ENCODING_ASSERTION.equals(assertion.getName())){ String value = assertion.getAttributeValue(enabled); boolean isSelectOptimalEncodingEnabled = value == null || Boolean.valueOf(value.trim()); features.add(new SelectOptimalEncodingFeature(isSelectOptimalEncodingEnabled)); } } } } } return features; }
Example #10
Source File: FastInfosetFeatureConfigurator.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Process FastInfoset policy assertions. * * @param key Key to identify the endpoint scope. * @param policyMap the policy map. * @throws PolicyException If retrieving the policy triggered an exception. */ public Collection<WebServiceFeature> getFeatures(final PolicyMapKey key, final PolicyMap policyMap) throws PolicyException { final Collection<WebServiceFeature> features = new LinkedList<WebServiceFeature>(); if ((key != null) && (policyMap != null)) { Policy policy = policyMap.getEndpointEffectivePolicy(key); if (null!=policy && policy.contains(OPTIMIZED_FI_SERIALIZATION_ASSERTION)) { Iterator <AssertionSet> assertions = policy.iterator(); while(assertions.hasNext()){ AssertionSet assertionSet = assertions.next(); Iterator<PolicyAssertion> policyAssertion = assertionSet.iterator(); while(policyAssertion.hasNext()){ PolicyAssertion assertion = policyAssertion.next(); if(OPTIMIZED_FI_SERIALIZATION_ASSERTION.equals(assertion.getName())){ String value = assertion.getAttributeValue(enabled); boolean isFastInfosetEnabled = Boolean.valueOf(value.trim()); features.add(new FastInfosetFeature(isFastInfosetEnabled)); } // end-if non optional fast infoset assertion found } // next assertion } // next alternative } // end-if policy contains fast infoset assertion } return features; }
Example #11
Source File: SelectOptimalEncodingFeatureConfigurator.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Process SelectOptimalEncoding policy assertions. * * @param key Key that identifies the endpoint scope. * @param policyMap The policy map. * @throws PolicyException If retrieving the policy triggered an exception. */ public Collection<WebServiceFeature> getFeatures(PolicyMapKey key, PolicyMap policyMap) throws PolicyException { final Collection<WebServiceFeature> features = new LinkedList<WebServiceFeature>(); if ((key != null) && (policyMap != null)) { Policy policy = policyMap.getEndpointEffectivePolicy(key); if (null!=policy && policy.contains(SELECT_OPTIMAL_ENCODING_ASSERTION)) { Iterator <AssertionSet> assertions = policy.iterator(); while(assertions.hasNext()){ AssertionSet assertionSet = assertions.next(); Iterator<PolicyAssertion> policyAssertion = assertionSet.iterator(); while(policyAssertion.hasNext()){ PolicyAssertion assertion = policyAssertion.next(); if(SELECT_OPTIMAL_ENCODING_ASSERTION.equals(assertion.getName())){ String value = assertion.getAttributeValue(enabled); boolean isSelectOptimalEncodingEnabled = value == null || Boolean.valueOf(value.trim()); features.add(new SelectOptimalEncodingFeature(isSelectOptimalEncodingEnabled)); } } } } } return features; }
Example #12
Source File: DefaultPolicyResolver.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Checks if the PolicyMap has only single alternative in the scope. * * @param policyMap * PolicyMap that needs to be validated. */ private void validateServerPolicyMap(PolicyMap policyMap) { try { final ValidationProcessor validationProcessor = ValidationProcessor.getInstance(); for (Policy policy : policyMap) { // TODO: here is a good place to check if the actual policy has only one alternative... for (AssertionSet assertionSet : policy) { for (PolicyAssertion assertion : assertionSet) { Fitness validationResult = validationProcessor.validateServerSide(assertion); if (validationResult != Fitness.SUPPORTED) { throw new PolicyException(PolicyMessages.WSP_1015_SERVER_SIDE_ASSERTION_VALIDATION_FAILED( assertion.getName(), validationResult)); } } } } } catch (PolicyException e) { throw new WebServiceException(e); } }
Example #13
Source File: AddressingPolicyValidator.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public Fitness validateServerSide(PolicyAssertion assertion) { if (!supportedAssertions.contains(assertion.getName())) return Fitness.UNKNOWN; //Make sure wsam:Addressing contains only one of the allowed nested assertions. if (assertion.getName().equals(W3CAddressingMetadataConstants.WSAM_ADDRESSING_ASSERTION)) { NestedPolicy nestedPolicy = assertion.getNestedPolicy(); if (nestedPolicy != null) { boolean requiresAnonymousResponses = false; boolean requiresNonAnonymousResponses = false; for (PolicyAssertion nestedAsser : nestedPolicy.getAssertionSet()) { if (nestedAsser.getName().equals(W3CAddressingMetadataConstants.WSAM_ANONYMOUS_NESTED_ASSERTION)) { requiresAnonymousResponses = true; } else if (nestedAsser.getName().equals(W3CAddressingMetadataConstants.WSAM_NONANONYMOUS_NESTED_ASSERTION)) { requiresNonAnonymousResponses = true; } else { LOGGER.warning("Found unsupported assertion:\n" + nestedAsser + "\nnested into assertion:\n" + assertion); return Fitness.UNSUPPORTED; } } if (requiresAnonymousResponses && requiresNonAnonymousResponses) { LOGGER.warning("Only one among AnonymousResponses and NonAnonymousResponses can be nested in an Addressing assertion"); return Fitness.INVALID; } } } return Fitness.SUPPORTED; }
Example #14
Source File: PolicyModelTranslator.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
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 #15
Source File: PolicyModelGenerator.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Add the contents of the assertion set as child node to the given model node. * * @param node The content of this assertion set are added as child nodes to this node. * May not be null. * @param assertions The assertions that are to be added to the node. May not be null. */ protected void translate(final ModelNode node, final AssertionSet assertions) { for (PolicyAssertion assertion : assertions) { final AssertionData data = AssertionData.createAssertionData(assertion.getName(), assertion.getValue(), assertion.getAttributes(), assertion.isOptional(), assertion.isIgnorable()); final ModelNode assertionNode = node.createChildAssertionNode(data); if (assertion.hasNestedPolicy()) { translate(assertionNode, assertion.getNestedPolicy()); } if (assertion.hasParameters()) { translate(assertionNode, assertion.getParametersIterator()); } } }
Example #16
Source File: PolicyModelTranslator.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
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
Source File: CompactModelGenerator.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override public PolicySourceModel translate(final Policy policy) throws PolicyException { LOGGER.entering(policy); PolicySourceModel model = null; if (policy == null) { LOGGER.fine(LocalizationMessages.WSP_0047_POLICY_IS_NULL_RETURNING()); } else { model = this.sourceModelCreator.create(policy); ModelNode rootNode = model.getRootNode(); final int numberOfAssertionSets = policy.getNumberOfAssertionSets(); if (numberOfAssertionSets > 1) { rootNode = rootNode.createChildExactlyOneNode(); } ModelNode alternativeNode = rootNode; for (AssertionSet set : policy) { if (numberOfAssertionSets > 1) { alternativeNode = rootNode.createChildAllNode(); } for (PolicyAssertion assertion : set) { final AssertionData data = AssertionData.createAssertionData(assertion.getName(), assertion.getValue(), assertion.getAttributes(), assertion.isOptional(), assertion.isIgnorable()); final ModelNode assertionNode = alternativeNode.createChildAssertionNode(data); if (assertion.hasNestedPolicy()) { translate(assertionNode, assertion.getNestedPolicy()); } if (assertion.hasParameters()) { translate(assertionNode, assertion.getParametersIterator()); } } } } LOGGER.exiting(model); return model; }
Example #18
Source File: CompactModelGenerator.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Override public PolicySourceModel translate(final Policy policy) throws PolicyException { LOGGER.entering(policy); PolicySourceModel model = null; if (policy == null) { LOGGER.fine(LocalizationMessages.WSP_0047_POLICY_IS_NULL_RETURNING()); } else { model = this.sourceModelCreator.create(policy); ModelNode rootNode = model.getRootNode(); final int numberOfAssertionSets = policy.getNumberOfAssertionSets(); if (numberOfAssertionSets > 1) { rootNode = rootNode.createChildExactlyOneNode(); } ModelNode alternativeNode = rootNode; for (AssertionSet set : policy) { if (numberOfAssertionSets > 1) { alternativeNode = rootNode.createChildAllNode(); } for (PolicyAssertion assertion : set) { final AssertionData data = AssertionData.createAssertionData(assertion.getName(), assertion.getValue(), assertion.getAttributes(), assertion.isOptional(), assertion.isIgnorable()); final ModelNode assertionNode = alternativeNode.createChildAssertionNode(data); if (assertion.hasNestedPolicy()) { translate(assertionNode, assertion.getNestedPolicy()); } if (assertion.hasParameters()) { translate(assertionNode, assertion.getParametersIterator()); } } } } LOGGER.exiting(model); return model; }
Example #19
Source File: PolicyModelTranslator.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
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 #20
Source File: PolicyModelTranslator.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
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
Source File: ManagementPolicyValidator.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public Fitness validateClientSide(PolicyAssertion assertion) { final QName assertionName = assertion.getName(); if (ManagedClientAssertion.MANAGED_CLIENT_QNAME.equals(assertionName)) { return Fitness.SUPPORTED; } else if (ManagedServiceAssertion.MANAGED_SERVICE_QNAME.equals(assertionName)) { return Fitness.UNSUPPORTED; } else { return Fitness.UNKNOWN; } }
Example #22
Source File: AbstractQNameValidator.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private Fitness validateAssertion(PolicyAssertion assertion, Collection<QName> thisSideAssertions, Collection<QName> otherSideAssertions) { QName assertionName = assertion.getName(); if (thisSideAssertions.contains(assertionName)) { return Fitness.SUPPORTED; } else if (otherSideAssertions.contains(assertionName)) { return Fitness.UNSUPPORTED; } else { return Fitness.UNKNOWN; } }
Example #23
Source File: NormalizedModelGenerator.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
@Override public PolicySourceModel translate(final Policy policy) throws PolicyException { LOGGER.entering(policy); PolicySourceModel model = null; if (policy == null) { LOGGER.fine(LocalizationMessages.WSP_0047_POLICY_IS_NULL_RETURNING()); } else { model = this.sourceModelCreator.create(policy); final ModelNode rootNode = model.getRootNode(); final ModelNode exactlyOneNode = rootNode.createChildExactlyOneNode(); for (AssertionSet set : policy) { final ModelNode alternativeNode = exactlyOneNode.createChildAllNode(); for (PolicyAssertion assertion : set) { final AssertionData data = AssertionData.createAssertionData(assertion.getName(), assertion.getValue(), assertion.getAttributes(), assertion.isOptional(), assertion.isIgnorable()); final ModelNode assertionNode = alternativeNode.createChildAssertionNode(data); if (assertion.hasNestedPolicy()) { translate(assertionNode, assertion.getNestedPolicy()); } if (assertion.hasParameters()) { translate(assertionNode, assertion.getParametersIterator()); } } } } LOGGER.exiting(model); return model; }
Example #24
Source File: ManagementPolicyValidator.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public Fitness validateServerSide(PolicyAssertion assertion) { final QName assertionName = assertion.getName(); if (ManagedServiceAssertion.MANAGED_SERVICE_QNAME.equals(assertionName)) { return Fitness.SUPPORTED; } else if (ManagedClientAssertion.MANAGED_CLIENT_QNAME.equals(assertionName)) { return Fitness.UNSUPPORTED; } else { return Fitness.UNKNOWN; } }
Example #25
Source File: PolicyModelTranslator.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
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 #26
Source File: PolicyModelGenerator.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Add the contents of the assertion set as child node to the given model node. * * @param node The content of this assertion set are added as child nodes to this node. * May not be null. * @param assertions The assertions that are to be added to the node. May not be null. */ protected void translate(final ModelNode node, final AssertionSet assertions) { for (PolicyAssertion assertion : assertions) { final AssertionData data = AssertionData.createAssertionData(assertion.getName(), assertion.getValue(), assertion.getAttributes(), assertion.isOptional(), assertion.isIgnorable()); final ModelNode assertionNode = node.createChildAssertionNode(data); if (assertion.hasNestedPolicy()) { translate(assertionNode, assertion.getNestedPolicy()); } if (assertion.hasParameters()) { translate(assertionNode, assertion.getParametersIterator()); } } }
Example #27
Source File: AddressingPolicyValidator.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public Fitness validateServerSide(PolicyAssertion assertion) { if (!supportedAssertions.contains(assertion.getName())) return Fitness.UNKNOWN; //Make sure wsam:Addressing contains only one of the allowed nested assertions. if (assertion.getName().equals(W3CAddressingMetadataConstants.WSAM_ADDRESSING_ASSERTION)) { NestedPolicy nestedPolicy = assertion.getNestedPolicy(); if (nestedPolicy != null) { boolean requiresAnonymousResponses = false; boolean requiresNonAnonymousResponses = false; for (PolicyAssertion nestedAsser : nestedPolicy.getAssertionSet()) { if (nestedAsser.getName().equals(W3CAddressingMetadataConstants.WSAM_ANONYMOUS_NESTED_ASSERTION)) { requiresAnonymousResponses = true; } else if (nestedAsser.getName().equals(W3CAddressingMetadataConstants.WSAM_NONANONYMOUS_NESTED_ASSERTION)) { requiresNonAnonymousResponses = true; } else { LOGGER.warning("Found unsupported assertion:\n" + nestedAsser + "\nnested into assertion:\n" + assertion); return Fitness.UNSUPPORTED; } } if (requiresAnonymousResponses && requiresNonAnonymousResponses) { LOGGER.warning("Only one among AnonymousResponses and NonAnonymousResponses can be nested in an Addressing assertion"); return Fitness.INVALID; } } } return Fitness.SUPPORTED; }
Example #28
Source File: PolicyModelTranslator.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
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 #29
Source File: ManagementAssertionCreator.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
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 #30
Source File: AddressingPolicyValidator.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public Fitness validateServerSide(PolicyAssertion assertion) { if (!supportedAssertions.contains(assertion.getName())) return Fitness.UNKNOWN; //Make sure wsam:Addressing contains only one of the allowed nested assertions. if (assertion.getName().equals(W3CAddressingMetadataConstants.WSAM_ADDRESSING_ASSERTION)) { NestedPolicy nestedPolicy = assertion.getNestedPolicy(); if (nestedPolicy != null) { boolean requiresAnonymousResponses = false; boolean requiresNonAnonymousResponses = false; for (PolicyAssertion nestedAsser : nestedPolicy.getAssertionSet()) { if (nestedAsser.getName().equals(W3CAddressingMetadataConstants.WSAM_ANONYMOUS_NESTED_ASSERTION)) { requiresAnonymousResponses = true; } else if (nestedAsser.getName().equals(W3CAddressingMetadataConstants.WSAM_NONANONYMOUS_NESTED_ASSERTION)) { requiresNonAnonymousResponses = true; } else { LOGGER.warning("Found unsupported assertion:\n" + nestedAsser + "\nnested into assertion:\n" + assertion); return Fitness.UNSUPPORTED; } } if (requiresAnonymousResponses && requiresNonAnonymousResponses) { LOGGER.warning("Only one among AnonymousResponses and NonAnonymousResponses can be nested in an Addressing assertion"); return Fitness.INVALID; } } } return Fitness.SUPPORTED; }