com.sun.xml.internal.ws.policy.PolicyException Java Examples
The following examples show how to use
com.sun.xml.internal.ws.policy.PolicyException.
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: DefaultPolicyResolver.java From jdk8u60 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 #2
Source File: MtomFeatureConfigurator.java From jdk8u60 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 #3
Source File: PolicyUtil.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Returns the list of features that correspond to the policies in the policy * map for a give port * * @param policyMap The service policies * @param serviceName The service name * @param portName The service port name * @return List of features for the given port corresponding to the policies in the map */ public static Collection<WebServiceFeature> getPortScopedFeatures(PolicyMap policyMap, QName serviceName, QName portName) { LOGGER.entering(policyMap, serviceName, portName); Collection<WebServiceFeature> features = new ArrayList<WebServiceFeature>(); try { final PolicyMapKey key = PolicyMap.createWsdlEndpointScopeKey(serviceName, portName); for (PolicyFeatureConfigurator configurator : CONFIGURATORS) { Collection<WebServiceFeature> additionalFeatures = configurator.getFeatures(key, policyMap); if (additionalFeatures != null) { features.addAll(additionalFeatures); } } } catch (PolicyException e) { throw new WebServiceException(e); } LOGGER.exiting(features); return features; }
Example #4
Source File: PolicyWSDLGeneratorExtension.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Adds a PolicyReference element that points to the policy of the element, * if the policy does not have any id or name. Writes policy inside the element otherwise. * * @param subject * PolicySubject to be referenced or marshalled * @param writer * A TXW on to which we shall add the PolicyReference */ private void writePolicyOrReferenceIt(final PolicySubject subject, final TypedXmlWriter writer) { final Policy policy; try { policy = subject.getEffectivePolicy(merger); } catch (PolicyException e) { throw LOGGER.logSevereException(new WebServiceException(PolicyMessages.WSP_1011_FAILED_TO_RETRIEVE_EFFECTIVE_POLICY_FOR_SUBJECT(subject.toString()), e)); } if (policy != null) { if (null == policy.getIdOrName()) { final PolicyModelGenerator generator = ModelGenerator.getGenerator(); try { final PolicySourceModel policyInfoset = generator.translate(policy); marshaller.marshal(policyInfoset, writer); } catch (PolicyException pe) { throw LOGGER.logSevereException(new WebServiceException(PolicyMessages.WSP_1002_UNABLE_TO_MARSHALL_POLICY_OR_POLICY_REFERENCE(), pe)); } } else { final TypedXmlWriter policyReference = writer._element(policy.getNamespaceVersion().asQName(XmlToken.PolicyReference), TypedXmlWriter.class); policyReference._attribute(XmlToken.Uri.toString(), '#' + policy.getIdOrName()); } } }
Example #5
Source File: BuilderHandler.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
final Collection<Policy> getPolicies() throws PolicyException { if (null == policyURIs) { throw LOGGER.logSevereException(new PolicyException(PolicyMessages.WSP_1004_POLICY_URIS_CAN_NOT_BE_NULL())); } if (null == policyStore) { throw LOGGER.logSevereException(new PolicyException(PolicyMessages.WSP_1010_NO_POLICIES_DEFINED())); } final Collection<Policy> result = new ArrayList<Policy>(policyURIs.size()); for (String policyURI : policyURIs) { final PolicySourceModel sourceModel = policyStore.get(policyURI); if (sourceModel == null) { throw LOGGER.logSevereException(new PolicyException(PolicyMessages.WSP_1005_POLICY_REFERENCE_DOES_NOT_EXIST(policyURI))); } else { result.add(ModelTranslator.getTranslator().translate(sourceModel)); } } return result; }
Example #6
Source File: PolicySourceModel.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Expands current policy model. This means, that if this model contains any (unexpanded) policy references, then the method expands those * references by placing the content of the referenced policy source models under the policy reference nodes. This operation merely creates * a link between this and referenced policy source models. Thus any change in the referenced models will be visible wihtin this model as well. * <p/> * Please, notice that the method does not check if the referenced models are already expanded nor does the method try to expand unexpanded * referenced models. This must be preformed manually within client's code. Consecutive calls of this method will have no effect. * <p/> * Every source model that references other policies must be expanded before it can be translated into a Policy object. See * {@link #isExpanded()} and {@link #containsPolicyReferences()} for more details. * * @param context a policy source model context holding the set of unmarshalled policy source models within the same context. * @throws PolicyException Thrown if a referenced policy could not be resolved */ public synchronized void expand(final PolicySourceModelContext context) throws PolicyException { if (!isExpanded()) { for (ModelNode reference : references) { final PolicyReferenceData refData = reference.getPolicyReferenceData(); final String digest = refData.getDigest(); PolicySourceModel referencedModel; if (digest == null) { referencedModel = context.retrieveModel(refData.getReferencedModelUri()); } else { referencedModel = context.retrieveModel(refData.getReferencedModelUri(), refData.getDigestAlgorithmUri(), digest); } reference.setReferencedModel(referencedModel); } expanded = true; } }
Example #7
Source File: PolicySourceModel.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Expands current policy model. This means, that if this model contains any (unexpanded) policy references, then the method expands those * references by placing the content of the referenced policy source models under the policy reference nodes. This operation merely creates * a link between this and referenced policy source models. Thus any change in the referenced models will be visible wihtin this model as well. * <p/> * Please, notice that the method does not check if the referenced models are already expanded nor does the method try to expand unexpanded * referenced models. This must be preformed manually within client's code. Consecutive calls of this method will have no effect. * <p/> * Every source model that references other policies must be expanded before it can be translated into a Policy object. See * {@link #isExpanded()} and {@link #containsPolicyReferences()} for more details. * * @param context a policy source model context holding the set of unmarshalled policy source models within the same context. * @throws PolicyException Thrown if a referenced policy could not be resolved */ public synchronized void expand(final PolicySourceModelContext context) throws PolicyException { if (!isExpanded()) { for (ModelNode reference : references) { final PolicyReferenceData refData = reference.getPolicyReferenceData(); final String digest = refData.getDigest(); PolicySourceModel referencedModel; if (digest == null) { referencedModel = context.retrieveModel(refData.getReferencedModelUri()); } else { referencedModel = context.retrieveModel(refData.getReferencedModelUri(), refData.getDigestAlgorithmUri(), digest); } reference.setReferencedModel(referencedModel); } expanded = true; } }
Example #8
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 #9
Source File: PolicyWSDLGeneratorExtension.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * Adds a PolicyReference element that points to the policy of the element, * if the policy does not have any id or name. Writes policy inside the element otherwise. * * @param subject * PolicySubject to be referenced or marshalled * @param writer * A TXW on to which we shall add the PolicyReference */ private void writePolicyOrReferenceIt(final PolicySubject subject, final TypedXmlWriter writer) { final Policy policy; try { policy = subject.getEffectivePolicy(merger); } catch (PolicyException e) { throw LOGGER.logSevereException(new WebServiceException(PolicyMessages.WSP_1011_FAILED_TO_RETRIEVE_EFFECTIVE_POLICY_FOR_SUBJECT(subject.toString()), e)); } if (policy != null) { if (null == policy.getIdOrName()) { final PolicyModelGenerator generator = ModelGenerator.getGenerator(); try { final PolicySourceModel policyInfoset = generator.translate(policy); marshaller.marshal(policyInfoset, writer); } catch (PolicyException pe) { throw LOGGER.logSevereException(new WebServiceException(PolicyMessages.WSP_1002_UNABLE_TO_MARSHALL_POLICY_OR_POLICY_REFERENCE(), pe)); } } else { final TypedXmlWriter policyReference = writer._element(policy.getNamespaceVersion().asQName(XmlToken.PolicyReference), TypedXmlWriter.class); policyReference._attribute(XmlToken.Uri.toString(), '#' + policy.getIdOrName()); } } }
Example #10
Source File: PolicyUtil.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Returns the list of features that correspond to the policies in the policy * map for a give port * * @param policyMap The service policies * @param serviceName The service name * @param portName The service port name * @return List of features for the given port corresponding to the policies in the map */ public static Collection<WebServiceFeature> getPortScopedFeatures(PolicyMap policyMap, QName serviceName, QName portName) { LOGGER.entering(policyMap, serviceName, portName); Collection<WebServiceFeature> features = new ArrayList<WebServiceFeature>(); try { final PolicyMapKey key = PolicyMap.createWsdlEndpointScopeKey(serviceName, portName); for (PolicyFeatureConfigurator configurator : CONFIGURATORS) { Collection<WebServiceFeature> additionalFeatures = configurator.getFeatures(key, policyMap); if (additionalFeatures != null) { features.addAll(additionalFeatures); } } } catch (PolicyException e) { throw new WebServiceException(e); } LOGGER.exiting(features); return features; }
Example #11
Source File: MtomPolicyMapConfigurator.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Generates an MTOM policy if MTOM is enabled. * * <ol> * <li>If MTOM is enabled * <ol> * <li>If MTOM policy does not already exist, generate * <li>Otherwise do nothing * </ol> * <li>Otherwise, do nothing (that implies that we do not remove any MTOM policies if MTOM is disabled) * </ol> * */ public Collection<PolicySubject> update(PolicyMap policyMap, SEIModel model, WSBinding wsBinding) throws PolicyException { LOGGER.entering(policyMap, model, wsBinding); Collection<PolicySubject> subjects = new ArrayList<PolicySubject>(); if (policyMap != null) { final MTOMFeature mtomFeature = wsBinding.getFeature(MTOMFeature.class); if (LOGGER.isLoggable(Level.FINEST)) { LOGGER.finest("mtomFeature = " + mtomFeature); } if ((mtomFeature != null) && mtomFeature.isEnabled()) { final QName bindingName = model.getBoundPortTypeName(); final WsdlBindingSubject wsdlSubject = WsdlBindingSubject.createBindingSubject(bindingName); final Policy mtomPolicy = createMtomPolicy(bindingName); final PolicySubject mtomPolicySubject = new PolicySubject(wsdlSubject, mtomPolicy); subjects.add(mtomPolicySubject); if (LOGGER.isLoggable(Level.FINEST)) { LOGGER.fine("Added MTOM policy with ID \"" + mtomPolicy.getIdOrName() + "\" to binding element \"" + bindingName + "\""); } } } // endif policy map not null LOGGER.exiting(subjects); return subjects; }
Example #12
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 #13
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 #14
Source File: PolicyModelTranslator.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
RawAlternative(Collection<ModelNode> assertionNodes) throws PolicyException { this.nestedAssertions = new LinkedList<RawAssertion>(); for (ModelNode node : assertionNodes) { RawAssertion assertion = new RawAssertion(node, new LinkedList<ModelNode>()); nestedAssertions.add(assertion); for (ModelNode assertionNodeChild : assertion.originalNode.getChildren()) { switch (assertionNodeChild.getType()) { case ASSERTION_PARAMETER_NODE: assertion.parameters.add(assertionNodeChild); break; case POLICY: case POLICY_REFERENCE: if (assertion.nestedAlternatives == null) { assertion.nestedAlternatives = new LinkedList<RawAlternative>(); RawPolicy nestedPolicy; if (assertionNodeChild.getType() == ModelNode.Type.POLICY) { nestedPolicy = new RawPolicy(assertionNodeChild, assertion.nestedAlternatives); } else { nestedPolicy = new RawPolicy(getReferencedModelRootNode(assertionNodeChild), assertion.nestedAlternatives); } this.allNestedPolicies.add(nestedPolicy); } else { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0006_UNEXPECTED_MULTIPLE_POLICY_NODES())); } break; default: throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0008_UNEXPECTED_CHILD_MODEL_TYPE(assertionNodeChild.getType()))); } } } }
Example #15
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 #16
Source File: XmlPolicyModelUnmarshaller.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * See {@link PolicyModelUnmarshaller#unmarshalModel(Object) base method documentation}. */ public PolicySourceModel unmarshalModel(final Object storage) throws PolicyException { final XMLEventReader reader = createXMLEventReader(storage); PolicySourceModel model = null; loop: while (reader.hasNext()) { try { final XMLEvent event = reader.peek(); switch (event.getEventType()) { case XMLStreamConstants.START_DOCUMENT: case XMLStreamConstants.COMMENT: reader.nextEvent(); break; // skipping the comments and start document events case XMLStreamConstants.CHARACTERS: processCharacters(ModelNode.Type.POLICY, event.asCharacters(), null); // we advance the reader only if there is no exception thrown from // the processCharacters(...) call. Otherwise we don't modify the stream reader.nextEvent(); break; case XMLStreamConstants.START_ELEMENT: if (NamespaceVersion.resolveAsToken(event.asStartElement().getName()) == XmlToken.Policy) { StartElement rootElement = reader.nextEvent().asStartElement(); model = initializeNewModel(rootElement); unmarshalNodeContent(model.getNamespaceVersion(), model.getRootNode(), rootElement.getName(), reader); break loop; } else { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0048_POLICY_ELEMENT_EXPECTED_FIRST())); } default: throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0048_POLICY_ELEMENT_EXPECTED_FIRST())); } } catch (XMLStreamException e) { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0068_FAILED_TO_UNMARSHALL_POLICY_EXPRESSION(), e)); } } return model; }
Example #17
Source File: XmlPolicyModelMarshaller.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Marshal a policy onto the given TypedXmlWriter. * * @param model A policy source model. * @param writer A typed XML writer. * @throws PolicyException If marshalling failed. */ private void marshal(final PolicySourceModel model, final TypedXmlWriter writer) throws PolicyException { final TypedXmlWriter policy = writer._element(model.getNamespaceVersion().asQName(XmlToken.Policy), TypedXmlWriter.class); marshalDefaultPrefixes(model, policy); marshalPolicyAttributes(model, policy); marshal(model.getNamespaceVersion(), model.getRootNode(), policy); }
Example #18
Source File: PolicyModelTranslator.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Method creates policy alternatives according to provided model. The model structure is modified in the process. * * @return created policy alternatives resulting from policy source model. */ private Collection<AssertionSet> createPolicyAlternatives(final PolicySourceModel model) throws PolicyException { // creating global method variables final ContentDecomposition decomposition = new ContentDecomposition(); // creating processing queue and starting the processing iterations final Queue<RawPolicy> policyQueue = new LinkedList<RawPolicy>(); final Queue<Collection<ModelNode>> contentQueue = new LinkedList<Collection<ModelNode>>(); final RawPolicy rootPolicy = new RawPolicy(model.getRootNode(), new LinkedList<RawAlternative>()); RawPolicy processedPolicy = rootPolicy; do { Collection<ModelNode> processedContent = processedPolicy.originalContent; do { decompose(processedContent, decomposition); if (decomposition.exactlyOneContents.isEmpty()) { final RawAlternative alternative = new RawAlternative(decomposition.assertions); processedPolicy.alternatives.add(alternative); if (!alternative.allNestedPolicies.isEmpty()) { policyQueue.addAll(alternative.allNestedPolicies); } } else { // we have a non-empty collection of exactly ones final Collection<Collection<ModelNode>> combinations = PolicyUtils.Collections.combine(decomposition.assertions, decomposition.exactlyOneContents, false); if (combinations != null && !combinations.isEmpty()) { // processed alternative was split into some new alternatives, which we need to process contentQueue.addAll(combinations); } } } while ((processedContent = contentQueue.poll()) != null); } while ((processedPolicy = policyQueue.poll()) != null); // normalize nested policies to contain single alternative only final Collection<AssertionSet> assertionSets = new LinkedList<AssertionSet>(); for (RawAlternative rootAlternative : rootPolicy.alternatives) { final Collection<AssertionSet> normalizedAlternatives = normalizeRawAlternative(rootAlternative); assertionSets.addAll(normalizedAlternatives); } return assertionSets; }
Example #19
Source File: BuilderHandler.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
final void populate(final PolicyMapExtender policyMapExtender) throws PolicyException { if (null == policyMapExtender) { throw LOGGER.logSevereException(new PolicyException(PolicyMessages.WSP_1006_POLICY_MAP_EXTENDER_CAN_NOT_BE_NULL())); } doPopulate(policyMapExtender); }
Example #20
Source File: PolicyWSDLGeneratorExtension.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Override public void start(final WSDLGenExtnContext context) { LOGGER.entering(); try { this.seiModel = context.getModel(); final PolicyMapConfigurator[] policyMapConfigurators = loadConfigurators(); final PolicyMapExtender[] extenders = new PolicyMapExtender[policyMapConfigurators.length]; for (int i = 0; i < policyMapConfigurators.length; i++) { extenders[i] = PolicyMapExtender.createPolicyMapExtender(); } // Read policy config file policyMap = PolicyResolverFactory.create().resolve( new PolicyResolver.ServerContext(policyMap, context.getContainer(), context.getEndpointClass(), false, extenders)); if (policyMap == null) { LOGGER.fine(PolicyMessages.WSP_1019_CREATE_EMPTY_POLICY_MAP()); policyMap = PolicyMap.createPolicyMap(Arrays.asList(extenders)); } final WSBinding binding = context.getBinding(); try { final Collection<PolicySubject> policySubjects = new LinkedList<PolicySubject>(); for (int i = 0; i < policyMapConfigurators.length; i++) { policySubjects.addAll(policyMapConfigurators[i].update(policyMap, seiModel, binding)); extenders[i].disconnect(); } PolicyMapUtil.insertPolicies(policyMap, policySubjects, this.seiModel.getServiceQName(), this.seiModel.getPortName()); } catch (PolicyException e) { throw LOGGER.logSevereException(new WebServiceException(PolicyMessages.WSP_1017_MAP_UPDATE_FAILED(), e)); } final TypedXmlWriter root = context.getRoot(); root._namespace(NamespaceVersion.v1_2.toString(), NamespaceVersion.v1_2.getDefaultNamespacePrefix()); root._namespace(NamespaceVersion.v1_5.toString(), NamespaceVersion.v1_5.getDefaultNamespacePrefix()); root._namespace(PolicyConstants.WSU_NAMESPACE_URI, PolicyConstants.WSU_NAMESPACE_PREFIX); } finally { LOGGER.exiting(); } }
Example #21
Source File: DefaultPolicyResolver.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Selects a best alternative if there are multiple policy alternatives. * * @param policyMap * @return */ private PolicyMap doAlternativeSelection(PolicyMap policyMap) { final EffectivePolicyModifier modifier = EffectivePolicyModifier.createEffectivePolicyModifier(); modifier.connect(policyMap); try { AlternativeSelector.doSelection(modifier); } catch (PolicyException e) { throw new WebServiceException(e); } return policyMap; }
Example #22
Source File: NormalizedModelGenerator.java From jdk8u60 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 #23
Source File: NormalizedModelGenerator.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); 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: ExternalAttachmentsUnmarshaller.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private void processStartTag(final StartElement element, final StartElement parent, final XMLEventReader reader, final Map<URI, Policy> map) throws PolicyException { try { final QName name = element.getName(); if (parent == null) { if (!name.equals(POLICIES)) { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0089_EXPECTED_ELEMENT("<Policies>", name, element.getLocation()))); } } else { final QName parentName = parent.getName(); if (parentName.equals(POLICIES)) { if (!name.equals(POLICY_ATTACHMENT)) { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0089_EXPECTED_ELEMENT("<PolicyAttachment>", name, element.getLocation()))); } } else if (parentName.equals(POLICY_ATTACHMENT)) { if (name.equals(POLICY)) { readPolicy(reader); return; } else if (!name.equals(APPLIES_TO)) { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0089_EXPECTED_ELEMENT("<AppliesTo> or <Policy>", name, element.getLocation()))); } } else if (parentName.equals(APPLIES_TO)) { if (!name.equals(URI)) { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0089_EXPECTED_ELEMENT("<URI>", name, element.getLocation()))); } } else { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0090_UNEXPECTED_ELEMENT(name, element.getLocation()))); } } reader.nextEvent(); this.unmarshal(reader, element); } catch (XMLStreamException e) { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0088_FAILED_PARSE(element.getLocation()), e)); } }
Example #25
Source File: XmlPolicyModelUnmarshaller.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private String unmarshalNodeContent(final NamespaceVersion nsVersion, final ModelNode node, final QName nodeElementName, final XMLEventReader reader) throws PolicyException { StringBuilder valueBuffer = null; loop: while (reader.hasNext()) { try { final XMLEvent xmlParserEvent = reader.nextEvent(); switch (xmlParserEvent.getEventType()) { case XMLStreamConstants.COMMENT: break; // skipping the comments case XMLStreamConstants.CHARACTERS: valueBuffer = processCharacters(node.getType(), xmlParserEvent.asCharacters(), valueBuffer); break; case XMLStreamConstants.END_ELEMENT: checkEndTagName(nodeElementName, xmlParserEvent.asEndElement()); break loop; // data exctraction for currently processed policy node is done case XMLStreamConstants.START_ELEMENT: final StartElement childElement = xmlParserEvent.asStartElement(); ModelNode childNode = addNewChildNode(nsVersion, node, childElement); String value = unmarshalNodeContent(nsVersion, childNode, childElement.getName(), reader); if (childNode.isDomainSpecific()) { parseAssertionData(nsVersion, value, childNode, childElement); } break; default: throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0011_UNABLE_TO_UNMARSHALL_POLICY_XML_ELEM_EXPECTED())); } } catch (XMLStreamException e) { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0068_FAILED_TO_UNMARSHALL_POLICY_EXPRESSION(), e)); } } return (valueBuffer == null) ? null : valueBuffer.toString().trim(); }
Example #26
Source File: PolicyUtil.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Iterates through the ports in the WSDL model, for each policy in the policy * map that is attached at endpoint scope computes a list of corresponding * WebServiceFeatures and sets them on the port. * * @param model The WSDL model * @param policyMap The policy map * @throws PolicyException If the list of WebServiceFeatures could not be computed */ public static void configureModel(final WSDLModel model, PolicyMap policyMap) throws PolicyException { LOGGER.entering(model, policyMap); for (WSDLService service : model.getServices().values()) { for (WSDLPort port : service.getPorts()) { final Collection<WebServiceFeature> features = getPortScopedFeatures(policyMap, service.getName(), port.getName()); for (WebServiceFeature feature : features) { port.addFeature(feature); port.getBinding().addFeature(feature); } } } LOGGER.exiting(); }
Example #27
Source File: XmlPolicyModelUnmarshaller.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * See {@link PolicyModelUnmarshaller#unmarshalModel(Object) base method documentation}. */ public PolicySourceModel unmarshalModel(final Object storage) throws PolicyException { final XMLEventReader reader = createXMLEventReader(storage); PolicySourceModel model = null; loop: while (reader.hasNext()) { try { final XMLEvent event = reader.peek(); switch (event.getEventType()) { case XMLStreamConstants.START_DOCUMENT: case XMLStreamConstants.COMMENT: reader.nextEvent(); break; // skipping the comments and start document events case XMLStreamConstants.CHARACTERS: processCharacters(ModelNode.Type.POLICY, event.asCharacters(), null); // we advance the reader only if there is no exception thrown from // the processCharacters(...) call. Otherwise we don't modify the stream reader.nextEvent(); break; case XMLStreamConstants.START_ELEMENT: if (NamespaceVersion.resolveAsToken(event.asStartElement().getName()) == XmlToken.Policy) { StartElement rootElement = reader.nextEvent().asStartElement(); model = initializeNewModel(rootElement); unmarshalNodeContent(model.getNamespaceVersion(), model.getRootNode(), rootElement.getName(), reader); break loop; } else { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0048_POLICY_ELEMENT_EXPECTED_FIRST())); } default: throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0048_POLICY_ELEMENT_EXPECTED_FIRST())); } } catch (XMLStreamException e) { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0068_FAILED_TO_UNMARSHALL_POLICY_EXPRESSION(), e)); } } return model; }
Example #28
Source File: PolicyMapBuilder.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Iterates all the registered PolicyBuilders and lets them populate * their changes into PolicyMap. Registers mutators from collection given as a parameter * with the newly created map. */ private PolicyMap getNewPolicyMap(final PolicyMapMutator... externalMutators) throws PolicyException{ final HashSet<PolicyMapMutator> mutators = new HashSet<PolicyMapMutator>(); final PolicyMapExtender myExtender = PolicyMapExtender.createPolicyMapExtender(); mutators.add(myExtender); if (null != externalMutators) { mutators.addAll(Arrays.asList(externalMutators)); } final PolicyMap policyMap = PolicyMap.createPolicyMap(mutators); for(BuilderHandler builder : policyBuilders){ builder.populate(myExtender); } return policyMap; }
Example #29
Source File: PolicyModelTranslator.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Decomposes the unprocessed alternative content into two different collections: * <p/> * Content of 'EXACTLY_ONE' child nodes is expanded and placed in one list and * 'ASSERTION' nodes are placed into other list. Direct 'ALL' and 'POLICY' child nodes are 'dissolved' in the process. * * Method reuses precreated ContentDecomposition object, which is reset before reuse. */ private void decompose(final Collection<ModelNode> content, final ContentDecomposition decomposition) throws PolicyException { decomposition.reset(); final Queue<ModelNode> allContentQueue = new LinkedList<ModelNode>(content); ModelNode node; while ((node = allContentQueue.poll()) != null) { // dissolving direct 'POLICY', 'POLICY_REFERENCE' and 'ALL' child nodes switch (node.getType()) { case POLICY : case ALL : allContentQueue.addAll(node.getChildren()); break; case POLICY_REFERENCE : allContentQueue.addAll(getReferencedModelRootNode(node).getChildren()); break; case EXACTLY_ONE : decomposition.exactlyOneContents.add(expandsExactlyOneContent(node.getChildren())); break; case ASSERTION : decomposition.assertions.add(node); break; default : throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0007_UNEXPECTED_MODEL_NODE_TYPE_FOUND(node.getType()))); } } }
Example #30
Source File: BuilderHandler.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
final Collection<PolicySubject> getPolicySubjects() throws PolicyException { final Collection<Policy> policies = getPolicies(); final Collection<PolicySubject> result = new ArrayList<PolicySubject>(policies.size()); for (Policy policy : policies) { result.add(new PolicySubject(policySubject, policy)); } return result; }