com.sun.xml.internal.ws.policy.sourcemodel.wspolicy.XmlToken Java Examples
The following examples show how to use
com.sun.xml.internal.ws.policy.sourcemodel.wspolicy.XmlToken.
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: PolicyWSDLParserExtension.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
private boolean readExternalFile(final String fileUrl) { InputStream ios = null; XMLStreamReader reader = null; try { final URL xmlURL = new URL(fileUrl); ios = xmlURL.openStream(); reader = XmlUtil.newXMLInputFactory(true).createXMLStreamReader(ios); while (reader.hasNext()) { if (reader.isStartElement() && NamespaceVersion.resolveAsToken(reader.getName()) == XmlToken.Policy) { readSinglePolicy(policyReader.readPolicyElement(reader, fileUrl), false); } reader.next(); } return true; } catch (IOException ioe) { return false; } catch (XMLStreamException xmlse) { return false; } finally { PolicyUtils.IO.closeResource(reader); PolicyUtils.IO.closeResource(ios); } }
Example #2
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 #3
Source File: PolicyWSDLParserExtension.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
private boolean processSubelement( final WSDLObject element, final XMLStreamReader reader, final Map<WSDLObject, Collection<PolicyRecordHandler>> map) { if (NamespaceVersion.resolveAsToken(reader.getName()) == XmlToken.PolicyReference) { // "PolicyReference" element interests us processReferenceUri(policyReader.readPolicyReferenceElement(reader), element, reader, map); return true; } else if (NamespaceVersion.resolveAsToken(reader.getName()) == XmlToken.Policy) { // policy could be defined here final PolicyRecordHandler handler = readSinglePolicy( policyReader.readPolicyElement( reader, (null == reader.getLocation().getSystemId()) ? // baseUrl "" : reader.getLocation().getSystemId()), true); if (null != handler) { // only policies with an Id can work for us addHandlerToMap(map, element, handler); } // endif null != handler return true; // element consumed }//end if Policy element found return false; }
Example #4
Source File: XmlPolicyModelUnmarshaller.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
private PolicySourceModel initializeNewModel(final StartElement element) throws PolicyException, XMLStreamException { PolicySourceModel model; final NamespaceVersion nsVersion = NamespaceVersion.resolveVersion(element.getName().getNamespaceURI()); final Attribute policyName = getAttributeByName(element, nsVersion.asQName(XmlToken.Name)); final Attribute xmlId = getAttributeByName(element, PolicyConstants.XML_ID); Attribute policyId = getAttributeByName(element, PolicyConstants.WSU_ID); if (policyId == null) { policyId = xmlId; } else if (xmlId != null) { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0058_MULTIPLE_POLICY_IDS_NOT_ALLOWED())); } model = createSourceModel(nsVersion, (policyId == null) ? null : policyId.getValue(), (policyName == null) ? null : policyName.getValue()); return model; }
Example #5
Source File: PolicyWSDLGeneratorExtension.java From openjdk-jdk9 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 #6
Source File: SafePolicyReader.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Reads policy reference element <wsp:PolicyReference/> and returns referenced policy URI as String * * @param reader The XMLStreamReader should be in START_ELEMENT state and point to the PolicyReference element. * @return The URI contained in the PolicyReference */ public String readPolicyReferenceElement(final XMLStreamReader reader) { try { if (NamespaceVersion.resolveAsToken(reader.getName()) == XmlToken.PolicyReference) { // "PolicyReference" element interests me for (int i = 0; i < reader.getAttributeCount(); i++) { if (XmlToken.resolveToken(reader.getAttributeName(i).getLocalPart()) == XmlToken.Uri) { final String uriValue = reader.getAttributeValue(i); reader.next(); return uriValue; } } } reader.next(); return null; } catch(XMLStreamException e) { throw LOGGER.logSevereException(new WebServiceException(PolicyMessages.WSP_1001_XML_EXCEPTION_WHEN_PROCESSING_POLICY_REFERENCE(), e)); } }
Example #7
Source File: PolicyWSDLParserExtension.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
private boolean readExternalFile(final String fileUrl) { InputStream ios = null; XMLStreamReader reader = null; try { final URL xmlURL = new URL(fileUrl); ios = xmlURL.openStream(); reader = XmlUtil.newXMLInputFactory(true).createXMLStreamReader(ios); while (reader.hasNext()) { if (reader.isStartElement() && NamespaceVersion.resolveAsToken(reader.getName()) == XmlToken.Policy) { readSinglePolicy(policyReader.readPolicyElement(reader, fileUrl), false); } reader.next(); } return true; } catch (IOException ioe) { return false; } catch (XMLStreamException xmlse) { return false; } finally { PolicyUtils.IO.closeResource(reader); PolicyUtils.IO.closeResource(ios); } }
Example #8
Source File: PolicyWSDLParserExtension.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
private boolean processSubelement( final WSDLObject element, final XMLStreamReader reader, final Map<WSDLObject, Collection<PolicyRecordHandler>> map) { if (NamespaceVersion.resolveAsToken(reader.getName()) == XmlToken.PolicyReference) { // "PolicyReference" element interests us processReferenceUri(policyReader.readPolicyReferenceElement(reader), element, reader, map); return true; } else if (NamespaceVersion.resolveAsToken(reader.getName()) == XmlToken.Policy) { // policy could be defined here final PolicyRecordHandler handler = readSinglePolicy( policyReader.readPolicyElement( reader, (null == reader.getLocation().getSystemId()) ? // baseUrl "" : reader.getLocation().getSystemId()), true); if (null != handler) { // only policies with an Id can work for us addHandlerToMap(map, element, handler); } // endif null != handler return true; // element consumed }//end if Policy element found return false; }
Example #9
Source File: XmlPolicyModelUnmarshaller.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
private PolicySourceModel initializeNewModel(final StartElement element) throws PolicyException, XMLStreamException { PolicySourceModel model; final NamespaceVersion nsVersion = NamespaceVersion.resolveVersion(element.getName().getNamespaceURI()); final Attribute policyName = getAttributeByName(element, nsVersion.asQName(XmlToken.Name)); final Attribute xmlId = getAttributeByName(element, PolicyConstants.XML_ID); Attribute policyId = getAttributeByName(element, PolicyConstants.WSU_ID); if (policyId == null) { policyId = xmlId; } else if (xmlId != null) { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0058_MULTIPLE_POLICY_IDS_NOT_ALLOWED())); } model = createSourceModel(nsVersion, (policyId == null) ? null : policyId.getValue(), (policyName == null) ? null : policyName.getValue()); return model; }
Example #10
Source File: XmlPolicyModelUnmarshaller.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
private PolicySourceModel initializeNewModel(final StartElement element) throws PolicyException, XMLStreamException { PolicySourceModel model; final NamespaceVersion nsVersion = NamespaceVersion.resolveVersion(element.getName().getNamespaceURI()); final Attribute policyName = getAttributeByName(element, nsVersion.asQName(XmlToken.Name)); final Attribute xmlId = getAttributeByName(element, PolicyConstants.XML_ID); Attribute policyId = getAttributeByName(element, PolicyConstants.WSU_ID); if (policyId == null) { policyId = xmlId; } else if (xmlId != null) { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0058_MULTIPLE_POLICY_IDS_NOT_ALLOWED())); } model = createSourceModel(nsVersion, (policyId == null) ? null : policyId.getValue(), (policyName == null) ? null : policyName.getValue()); return model; }
Example #11
Source File: SafePolicyReader.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Reads policy reference element <wsp:PolicyReference/> and returns referenced policy URI as String * * @param reader The XMLStreamReader should be in START_ELEMENT state and point to the PolicyReference element. * @return The URI contained in the PolicyReference */ public String readPolicyReferenceElement(final XMLStreamReader reader) { try { if (NamespaceVersion.resolveAsToken(reader.getName()) == XmlToken.PolicyReference) { // "PolicyReference" element interests me for (int i = 0; i < reader.getAttributeCount(); i++) { if (XmlToken.resolveToken(reader.getAttributeName(i).getLocalPart()) == XmlToken.Uri) { final String uriValue = reader.getAttributeValue(i); reader.next(); return uriValue; } } } reader.next(); return null; } catch(XMLStreamException e) { throw LOGGER.logSevereException(new WebServiceException(PolicyMessages.WSP_1001_XML_EXCEPTION_WHEN_PROCESSING_POLICY_REFERENCE(), e)); } }
Example #12
Source File: PolicyWSDLParserExtension.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
private boolean processSubelement( final WSDLObject element, final XMLStreamReader reader, final Map<WSDLObject, Collection<PolicyRecordHandler>> map) { if (NamespaceVersion.resolveAsToken(reader.getName()) == XmlToken.PolicyReference) { // "PolicyReference" element interests us processReferenceUri(policyReader.readPolicyReferenceElement(reader), element, reader, map); return true; } else if (NamespaceVersion.resolveAsToken(reader.getName()) == XmlToken.Policy) { // policy could be defined here final PolicyRecordHandler handler = readSinglePolicy( policyReader.readPolicyElement( reader, (null == reader.getLocation().getSystemId()) ? // baseUrl "" : reader.getLocation().getSystemId()), true); if (null != handler) { // only policies with an Id can work for us addHandlerToMap(map, element, handler); } // endif null != handler return true; // element consumed }//end if Policy element found return false; }
Example #13
Source File: PolicyWSDLParserExtension.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@Override public boolean definitionsElements(final XMLStreamReader reader){ LOGGER.entering(); if (NamespaceVersion.resolveAsToken(reader.getName()) == XmlToken.Policy) { // Only "Policy" element interests me readSinglePolicy( policyReader.readPolicyElement( reader, (null == reader.getLocation().getSystemId()) ? // baseUrl "" : reader.getLocation().getSystemId()), false); LOGGER.exiting(); return true; } LOGGER.exiting(); return false; }
Example #14
Source File: PolicyWSDLParserExtension.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
private boolean readExternalFile(final String fileUrl) { InputStream ios = null; XMLStreamReader reader = null; try { final URL xmlURL = new URL(fileUrl); ios = xmlURL.openStream(); reader = XmlUtil.newXMLInputFactory(true).createXMLStreamReader(ios); while (reader.hasNext()) { if (reader.isStartElement() && NamespaceVersion.resolveAsToken(reader.getName()) == XmlToken.Policy) { readSinglePolicy(policyReader.readPolicyElement(reader, fileUrl), false); } reader.next(); } return true; } catch (IOException ioe) { return false; } catch (XMLStreamException xmlse) { return false; } finally { PolicyUtils.IO.closeResource(reader); PolicyUtils.IO.closeResource(ios); } }
Example #15
Source File: PolicyWSDLGeneratorExtension.java From TencentKona-8 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 #16
Source File: XmlPolicyModelUnmarshaller.java From hottub with GNU General Public License v2.0 | 6 votes |
private PolicySourceModel initializeNewModel(final StartElement element) throws PolicyException, XMLStreamException { PolicySourceModel model; final NamespaceVersion nsVersion = NamespaceVersion.resolveVersion(element.getName().getNamespaceURI()); final Attribute policyName = getAttributeByName(element, nsVersion.asQName(XmlToken.Name)); final Attribute xmlId = getAttributeByName(element, PolicyConstants.XML_ID); Attribute policyId = getAttributeByName(element, PolicyConstants.WSU_ID); if (policyId == null) { policyId = xmlId; } else if (xmlId != null) { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0058_MULTIPLE_POLICY_IDS_NOT_ALLOWED())); } model = createSourceModel(nsVersion, (policyId == null) ? null : policyId.getValue(), (policyName == null) ? null : policyName.getValue()); return model; }
Example #17
Source File: PolicyWSDLParserExtension.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
@Override public boolean definitionsElements(final XMLStreamReader reader){ LOGGER.entering(); if (NamespaceVersion.resolveAsToken(reader.getName()) == XmlToken.Policy) { // Only "Policy" element interests me readSinglePolicy( policyReader.readPolicyElement( reader, (null == reader.getLocation().getSystemId()) ? // baseUrl "" : reader.getLocation().getSystemId()), false); LOGGER.exiting(); return true; } LOGGER.exiting(); return false; }
Example #18
Source File: PolicyWSDLParserExtension.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@Override public boolean definitionsElements(final XMLStreamReader reader){ LOGGER.entering(); if (NamespaceVersion.resolveAsToken(reader.getName()) == XmlToken.Policy) { // Only "Policy" element interests me readSinglePolicy( policyReader.readPolicyElement( reader, (null == reader.getLocation().getSystemId()) ? // baseUrl "" : reader.getLocation().getSystemId()), false); LOGGER.exiting(); return true; } LOGGER.exiting(); return false; }
Example #19
Source File: PolicyWSDLGeneratorExtension.java From openjdk-8 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 #20
Source File: PolicyWSDLParserExtension.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
private boolean readExternalFile(final String fileUrl) { InputStream ios = null; XMLStreamReader reader = null; try { final URL xmlURL = new URL(fileUrl); ios = xmlURL.openStream(); reader = XmlUtil.newXMLInputFactory(true).createXMLStreamReader(ios); while (reader.hasNext()) { if (reader.isStartElement() && NamespaceVersion.resolveAsToken(reader.getName()) == XmlToken.Policy) { readSinglePolicy(policyReader.readPolicyElement(reader, fileUrl), false); } reader.next(); } return true; } catch (IOException ioe) { return false; } catch (XMLStreamException xmlse) { return false; } finally { PolicyUtils.IO.closeResource(reader); PolicyUtils.IO.closeResource(ios); } }
Example #21
Source File: SafePolicyReader.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * Reads policy reference element <wsp:PolicyReference/> and returns referenced policy URI as String * * @param reader The XMLStreamReader should be in START_ELEMENT state and point to the PolicyReference element. * @return The URI contained in the PolicyReference */ public String readPolicyReferenceElement(final XMLStreamReader reader) { try { if (NamespaceVersion.resolveAsToken(reader.getName()) == XmlToken.PolicyReference) { // "PolicyReference" element interests me for (int i = 0; i < reader.getAttributeCount(); i++) { if (XmlToken.resolveToken(reader.getAttributeName(i).getLocalPart()) == XmlToken.Uri) { final String uriValue = reader.getAttributeValue(i); reader.next(); return uriValue; } } } reader.next(); return null; } catch(XMLStreamException e) { throw LOGGER.logSevereException(new WebServiceException(PolicyMessages.WSP_1001_XML_EXCEPTION_WHEN_PROCESSING_POLICY_REFERENCE(), e)); } }
Example #22
Source File: SafePolicyReader.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * Reads policy reference element <wsp:PolicyReference/> and returns referenced policy URI as String * * @param reader The XMLStreamReader should be in START_ELEMENT state and point to the PolicyReference element. * @return The URI contained in the PolicyReference */ public String readPolicyReferenceElement(final XMLStreamReader reader) { try { if (NamespaceVersion.resolveAsToken(reader.getName()) == XmlToken.PolicyReference) { // "PolicyReference" element interests me for (int i = 0; i < reader.getAttributeCount(); i++) { if (XmlToken.resolveToken(reader.getAttributeName(i).getLocalPart()) == XmlToken.Uri) { final String uriValue = reader.getAttributeValue(i); reader.next(); return uriValue; } } } reader.next(); return null; } catch(XMLStreamException e) { throw LOGGER.logSevereException(new WebServiceException(PolicyMessages.WSP_1001_XML_EXCEPTION_WHEN_PROCESSING_POLICY_REFERENCE(), e)); } }
Example #23
Source File: XmlPolicyModelUnmarshaller.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
private PolicySourceModel initializeNewModel(final StartElement element) throws PolicyException, XMLStreamException { PolicySourceModel model; final NamespaceVersion nsVersion = NamespaceVersion.resolveVersion(element.getName().getNamespaceURI()); final Attribute policyName = getAttributeByName(element, nsVersion.asQName(XmlToken.Name)); final Attribute xmlId = getAttributeByName(element, PolicyConstants.XML_ID); Attribute policyId = getAttributeByName(element, PolicyConstants.WSU_ID); if (policyId == null) { policyId = xmlId; } else if (xmlId != null) { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0058_MULTIPLE_POLICY_IDS_NOT_ALLOWED())); } model = createSourceModel(nsVersion, (policyId == null) ? null : policyId.getValue(), (policyName == null) ? null : policyName.getValue()); return model; }
Example #24
Source File: PolicyWSDLParserExtension.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
@Override public boolean definitionsElements(final XMLStreamReader reader){ LOGGER.entering(); if (NamespaceVersion.resolveAsToken(reader.getName()) == XmlToken.Policy) { // Only "Policy" element interests me readSinglePolicy( policyReader.readPolicyElement( reader, (null == reader.getLocation().getSystemId()) ? // baseUrl "" : reader.getLocation().getSystemId()), false); LOGGER.exiting(); return true; } LOGGER.exiting(); return false; }
Example #25
Source File: XmlPolicyModelMarshaller.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Marshal a policy onto the given XMLStreamWriter. * * @param model A policy source model. * @param writer An XML stream writer. * @throws PolicyException If marshalling failed. */ private void marshal(final PolicySourceModel model, final XMLStreamWriter writer) throws PolicyException { final StaxSerializer serializer = new StaxSerializer(writer); final TypedXmlWriter policy = TXW.create(model.getNamespaceVersion().asQName(XmlToken.Policy), TypedXmlWriter.class, serializer); marshalDefaultPrefixes(model, policy); marshalPolicyAttributes(model, policy); marshal(model.getNamespaceVersion(), model.getRootNode(), policy); policy.commit(); serializer.flush(); }
Example #26
Source File: XmlPolicyModelMarshaller.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Marshal given ModelNode and child elements on given TypedXmlWriter. * * @param nsVersion The WS-Policy version. * @param rootNode The ModelNode that is marshalled. * @param writer The TypedXmlWriter onto which the content of the rootNode is marshalled. */ private void marshal(final NamespaceVersion nsVersion, final ModelNode rootNode, final TypedXmlWriter writer) { for (ModelNode node : rootNode) { final AssertionData data = node.getNodeData(); if (marshallInvisible || data == null || !data.isPrivateAttributeSet()) { TypedXmlWriter child = null; if (data == null) { child = writer._element(nsVersion.asQName(node.getType().getXmlToken()), TypedXmlWriter.class); } else { child = writer._element(data.getName(), TypedXmlWriter.class); final String value = data.getValue(); if (value != null) { child._pcdata(value); } if (data.isOptionalAttributeSet()) { child._attribute(nsVersion.asQName(XmlToken.Optional), Boolean.TRUE); } if (data.isIgnorableAttributeSet()) { child._attribute(nsVersion.asQName(XmlToken.Ignorable), Boolean.TRUE); } for (Entry<QName, String> entry : data.getAttributesSet()) { child._attribute(entry.getKey(), entry.getValue()); } } marshal(nsVersion, node, child); } } }
Example #27
Source File: XmlPolicyModelUnmarshaller.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private void parseAssertionData(NamespaceVersion nsVersion, String value, ModelNode childNode, final StartElement childElement) throws IllegalArgumentException, PolicyException { // finish assertion node processing: create and set assertion data... final Map<QName, String> attributeMap = new HashMap<QName, String>(); boolean optional = false; boolean ignorable = false; final Iterator iterator = childElement.getAttributes(); while (iterator.hasNext()) { final Attribute nextAttribute = (Attribute) iterator.next(); final QName name = nextAttribute.getName(); if (attributeMap.containsKey(name)) { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0059_MULTIPLE_ATTRS_WITH_SAME_NAME_DETECTED_FOR_ASSERTION(nextAttribute.getName(), childElement.getName()))); } else { if (nsVersion.asQName(XmlToken.Optional).equals(name)) { optional = parseBooleanValue(nextAttribute.getValue()); } else if (nsVersion.asQName(XmlToken.Ignorable).equals(name)) { ignorable = parseBooleanValue(nextAttribute.getValue()); } else { attributeMap.put(name, nextAttribute.getValue()); } } } final AssertionData nodeData = new AssertionData(childElement.getName(), value, attributeMap, childNode.getType(), optional, ignorable); // check visibility value syntax if present... if (nodeData.containsAttribute(PolicyConstants.VISIBILITY_ATTRIBUTE)) { final String visibilityValue = nodeData.getAttributeValue(PolicyConstants.VISIBILITY_ATTRIBUTE); if (!PolicyConstants.VISIBILITY_VALUE_PRIVATE.equals(visibilityValue)) { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0004_UNEXPECTED_VISIBILITY_ATTR_VALUE(visibilityValue))); } } childNode.setOrReplaceNodeData(nodeData); }
Example #28
Source File: XmlPolicyModelUnmarshaller.java From hottub with GNU General Public License v2.0 | 5 votes |
private void parseAssertionData(NamespaceVersion nsVersion, String value, ModelNode childNode, final StartElement childElement) throws IllegalArgumentException, PolicyException { // finish assertion node processing: create and set assertion data... final Map<QName, String> attributeMap = new HashMap<QName, String>(); boolean optional = false; boolean ignorable = false; final Iterator iterator = childElement.getAttributes(); while (iterator.hasNext()) { final Attribute nextAttribute = (Attribute) iterator.next(); final QName name = nextAttribute.getName(); if (attributeMap.containsKey(name)) { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0059_MULTIPLE_ATTRS_WITH_SAME_NAME_DETECTED_FOR_ASSERTION(nextAttribute.getName(), childElement.getName()))); } else { if (nsVersion.asQName(XmlToken.Optional).equals(name)) { optional = parseBooleanValue(nextAttribute.getValue()); } else if (nsVersion.asQName(XmlToken.Ignorable).equals(name)) { ignorable = parseBooleanValue(nextAttribute.getValue()); } else { attributeMap.put(name, nextAttribute.getValue()); } } } final AssertionData nodeData = new AssertionData(childElement.getName(), value, attributeMap, childNode.getType(), optional, ignorable); // check visibility value syntax if present... if (nodeData.containsAttribute(PolicyConstants.VISIBILITY_ATTRIBUTE)) { final String visibilityValue = nodeData.getAttributeValue(PolicyConstants.VISIBILITY_ATTRIBUTE); if (!PolicyConstants.VISIBILITY_VALUE_PRIVATE.equals(visibilityValue)) { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0004_UNEXPECTED_VISIBILITY_ATTR_VALUE(visibilityValue))); } } childNode.setOrReplaceNodeData(nodeData); }
Example #29
Source File: XmlPolicyModelUnmarshaller.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private void parseAssertionData(NamespaceVersion nsVersion, String value, ModelNode childNode, final StartElement childElement) throws IllegalArgumentException, PolicyException { // finish assertion node processing: create and set assertion data... final Map<QName, String> attributeMap = new HashMap<QName, String>(); boolean optional = false; boolean ignorable = false; final Iterator iterator = childElement.getAttributes(); while (iterator.hasNext()) { final Attribute nextAttribute = (Attribute) iterator.next(); final QName name = nextAttribute.getName(); if (attributeMap.containsKey(name)) { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0059_MULTIPLE_ATTRS_WITH_SAME_NAME_DETECTED_FOR_ASSERTION(nextAttribute.getName(), childElement.getName()))); } else { if (nsVersion.asQName(XmlToken.Optional).equals(name)) { optional = parseBooleanValue(nextAttribute.getValue()); } else if (nsVersion.asQName(XmlToken.Ignorable).equals(name)) { ignorable = parseBooleanValue(nextAttribute.getValue()); } else { attributeMap.put(name, nextAttribute.getValue()); } } } final AssertionData nodeData = new AssertionData(childElement.getName(), value, attributeMap, childNode.getType(), optional, ignorable); // check visibility value syntax if present... if (nodeData.containsAttribute(PolicyConstants.VISIBILITY_ATTRIBUTE)) { final String visibilityValue = nodeData.getAttributeValue(PolicyConstants.VISIBILITY_ATTRIBUTE); if (!PolicyConstants.VISIBILITY_VALUE_PRIVATE.equals(visibilityValue)) { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0004_UNEXPECTED_VISIBILITY_ATTR_VALUE(visibilityValue))); } } childNode.setOrReplaceNodeData(nodeData); }
Example #30
Source File: PolicyWSDLParserExtension.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Reads policy reference URIs from PolicyURIs attribute and returns them * as a String array returns null if there is no such attribute. This method * will attempt to check for the attribute in every supported policy namespace. * Resulting array of URIs is concatenation of URIs defined in all found * PolicyURIs attribute version. */ private String[] getPolicyURIsFromAttr(final XMLStreamReader reader) { final StringBuilder policyUriBuffer = new StringBuilder(); for (NamespaceVersion version : NamespaceVersion.values()) { final String value = reader.getAttributeValue(version.toString(), XmlToken.PolicyUris.toString()); if (value != null) { policyUriBuffer.append(value).append(" "); } } return (policyUriBuffer.length() > 0) ? policyUriBuffer.toString().split("[\\n ]+") : null; }