com.sun.xml.internal.ws.policy.privateutil.LocalizationMessages Java Examples
The following examples show how to use
com.sun.xml.internal.ws.policy.privateutil.LocalizationMessages.
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: XmlPolicyModelUnmarshaller.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
private StringBuilder processCharacters(final ModelNode.Type currentNodeType, final Characters characters, final StringBuilder currentValueBuffer) throws PolicyException { if (characters.isWhiteSpace()) { return currentValueBuffer; } else { final StringBuilder buffer = (currentValueBuffer == null) ? new StringBuilder() : currentValueBuffer; final String data = characters.getData(); if (currentNodeType == ModelNode.Type.ASSERTION || currentNodeType == ModelNode.Type.ASSERTION_PARAMETER_NODE) { return buffer.append(data); } else { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0009_UNEXPECTED_CDATA_ON_SOURCE_MODEL_NODE(currentNodeType, data))); } } }
Example #2
Source File: XmlPolicyModelUnmarshaller.java From openjdk-8 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 #3
Source File: PolicyMap.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Places new subject into policy map under the scope identified by it's type and policy map key. * * @param scopeType the type of the scope the subject belongs to * @param key a policy map key to be used to store the subject * @param subject actual policy subject to be stored in the policy map * * @throw IllegalArgumentException in case the scope type is not recognized. */ void putSubject(final ScopeType scopeType, final PolicyMapKey key, final PolicySubject subject) { switch (scopeType) { case SERVICE: serviceMap.putSubject(key, subject); break; case ENDPOINT: endpointMap.putSubject(key, subject); break; case OPERATION: operationMap.putSubject(key, subject); break; case INPUT_MESSAGE: inputMessageMap.putSubject(key, subject); break; case OUTPUT_MESSAGE: outputMessageMap.putSubject(key, subject); break; case FAULT_MESSAGE: faultMessageMap.putSubject(key, subject); break; default: throw LOGGER.logSevereException(new IllegalArgumentException(LocalizationMessages.WSP_0002_UNRECOGNIZED_SCOPE_TYPE(scopeType))); } }
Example #4
Source File: XmlPolicyModelUnmarshaller.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Method checks if the storage type is supported and transforms it to XMLEventReader instance which is then returned. * Throws PolicyException if the transformation is not succesfull or if the storage type is not supported. * * @param storage An XMLEventReader instance. * @return The storage cast to an XMLEventReader. * @throws PolicyException If the XMLEventReader cast failed. */ private XMLEventReader createXMLEventReader(final Object storage) throws PolicyException { if (storage instanceof XMLEventReader) { return (XMLEventReader) storage; } else if (!(storage instanceof Reader)) { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0022_STORAGE_TYPE_NOT_SUPPORTED(storage.getClass().getName()))); } try { return XMLInputFactory.newInstance().createXMLEventReader((Reader) storage); } catch (XMLStreamException e) { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0014_UNABLE_TO_INSTANTIATE_READER_FOR_STORAGE(), e)); } }
Example #5
Source File: XmlPolicyModelUnmarshaller.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Method checks if the storage type is supported and transforms it to XMLEventReader instance which is then returned. * Throws PolicyException if the transformation is not succesfull or if the storage type is not supported. * * @param storage An XMLEventReader instance. * @return The storage cast to an XMLEventReader. * @throws PolicyException If the XMLEventReader cast failed. */ private XMLEventReader createXMLEventReader(final Object storage) throws PolicyException { if (storage instanceof XMLEventReader) { return (XMLEventReader) storage; } else if (!(storage instanceof Reader)) { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0022_STORAGE_TYPE_NOT_SUPPORTED(storage.getClass().getName()))); } try { return XMLInputFactory.newInstance().createXMLEventReader((Reader) storage); } catch (XMLStreamException e) { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0014_UNABLE_TO_INSTANTIATE_READER_FOR_STORAGE(), e)); } }
Example #6
Source File: XmlPolicyModelUnmarshaller.java From openjdk-jdk9 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 #7
Source File: XmlPolicyModelUnmarshaller.java From TencentKona-8 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 #8
Source File: PolicyMap.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private PolicyMapKey createLocalCopy(final PolicyMapKey key) { if (key == null) { throw LOGGER.logSevereException(new IllegalArgumentException(LocalizationMessages.WSP_0045_POLICY_MAP_KEY_MUST_NOT_BE_NULL())); } final PolicyMapKey localKeyCopy = new PolicyMapKey(key); localKeyCopy.setHandler(scopeKeyHandler); return localKeyCopy; }
Example #9
Source File: PolicyModelTranslator.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * The method translates {@link PolicySourceModel} structure into normalized {@link Policy} expression. The resulting Policy * is disconnected from its model, thus any additional changes in model will have no effect on the Policy expression. * * @param model the model to be translated into normalized policy expression. Must not be {@code null}. * @return translated policy expression in it's normalized form. * @throws PolicyException in case of translation failure */ public Policy translate(final PolicySourceModel model) throws PolicyException { LOGGER.entering(model); if (model == null) { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0043_POLICY_MODEL_TRANSLATION_ERROR_INPUT_PARAM_NULL())); } PolicySourceModel localPolicyModelCopy; try { localPolicyModelCopy = model.clone(); } catch (CloneNotSupportedException e) { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0016_UNABLE_TO_CLONE_POLICY_SOURCE_MODEL(), e)); } final String policyId = localPolicyModelCopy.getPolicyId(); final String policyName = localPolicyModelCopy.getPolicyName(); final Collection<AssertionSet> alternatives = createPolicyAlternatives(localPolicyModelCopy); LOGGER.finest(LocalizationMessages.WSP_0052_NUMBER_OF_ALTERNATIVE_COMBINATIONS_CREATED(alternatives.size())); Policy policy = null; if (alternatives.size() == 0) { policy = Policy.createNullPolicy(model.getNamespaceVersion(), policyName, policyId); LOGGER.finest(LocalizationMessages.WSP_0055_NO_ALTERNATIVE_COMBINATIONS_CREATED()); } else if (alternatives.size() == 1 && alternatives.iterator().next().isEmpty()) { policy = Policy.createEmptyPolicy(model.getNamespaceVersion(), policyName, policyId); LOGGER.finest(LocalizationMessages.WSP_0026_SINGLE_EMPTY_ALTERNATIVE_COMBINATION_CREATED()); } else { policy = Policy.createPolicy(model.getNamespaceVersion(), policyName, policyId, alternatives); LOGGER.finest(LocalizationMessages.WSP_0057_N_ALTERNATIVE_COMBINATIONS_M_POLICY_ALTERNATIVES_CREATED(alternatives.size(), policy.getNumberOfAssertionSets())); } LOGGER.exiting(policy); return policy; }
Example #10
Source File: PolicyMap.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private static PolicyMapKey createOperationOrInputOutputMessageKey(final QName service, final QName port, final QName operation) { if (service == null || port == null || operation == null) { throw LOGGER.logSevereException(new IllegalArgumentException(LocalizationMessages.WSP_0029_SERVICE_PORT_OPERATION_PARAM_MUST_NOT_BE_NULL(service, port, operation))); } return new PolicyMapKey(service, port, operation, operationAndInputOutputMessageKeyHandler); }
Example #11
Source File: PolicySourceModel.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Iterates through policy vocabulary and extracts set of namespaces used in * the policy expression. * * @return collection of used namespaces within given policy instance * @throws PolicyException Thrown if internal processing failed. */ private Collection<String> getUsedNamespaces() throws PolicyException { final Set<String> namespaces = new HashSet<String>(); namespaces.add(getNamespaceVersion().toString()); if (this.policyId != null) { namespaces.add(PolicyConstants.WSU_NAMESPACE_URI); } final Queue<ModelNode> nodesToBeProcessed = new LinkedList<ModelNode>(); nodesToBeProcessed.add(rootNode); ModelNode processedNode; while ((processedNode = nodesToBeProcessed.poll()) != null) { for (ModelNode child : processedNode.getChildren()) { if (child.hasChildren()) { if (!nodesToBeProcessed.offer(child)) { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0081_UNABLE_TO_INSERT_CHILD(nodesToBeProcessed, child))); } } if (child.isDomainSpecific()) { final AssertionData nodeData = child.getNodeData(); namespaces.add(nodeData.getName().getNamespaceURI()); if (nodeData.isPrivateAttributeSet()) { namespaces.add(PolicyConstants.SUN_POLICY_NAMESPACE_URI); } for (Entry<QName, String> attribute : nodeData.getAttributesSet()) { namespaces.add(attribute.getKey().getNamespaceURI()); } } } } return namespaces; }
Example #12
Source File: ExternalAttachmentsUnmarshaller.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private void processUri(final Characters chars, final Map<URI, Policy> map) throws PolicyException { final String data = chars.getData().trim(); try { final URI uri = new URI(data); if (this.currentPolicy != null) { map.put(uri, this.currentPolicy); this.currentUri = null; this.currentPolicy = null; } else { this.currentUri = uri; } } catch (URISyntaxException e) { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0093_INVALID_URI(data, chars.getLocation())), e); } }
Example #13
Source File: XmlPolicyModelMarshaller.java From hottub with GNU General Public License v2.0 | 5 votes |
public void marshal(final PolicySourceModel model, final Object storage) throws PolicyException { if (storage instanceof StaxSerializer) { marshal(model, (StaxSerializer) storage); } else if (storage instanceof TypedXmlWriter) { marshal(model, (TypedXmlWriter) storage); } else if (storage instanceof XMLStreamWriter) { marshal(model, (XMLStreamWriter) storage); } else { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0022_STORAGE_TYPE_NOT_SUPPORTED(storage.getClass().getName()))); } }
Example #14
Source File: ModelNode.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
void setReferencedModel(final PolicySourceModel model) { if (this.type != Type.POLICY_REFERENCE) { throw LOGGER.logSevereException(new UnsupportedOperationException(LocalizationMessages.WSP_0050_OPERATION_NOT_SUPPORTED_FOR_THIS_BUT_POLICY_REFERENCE_NODE_TYPE(type))); } referencedModel = model; }
Example #15
Source File: PolicyMapKey.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
PolicyMapKey(final QName service, final QName port, final QName operation, final QName faultMessage, final PolicyMapKeyHandler handler) { if (handler == null) { throw LOGGER.logSevereException(new IllegalArgumentException(LocalizationMessages.WSP_0046_POLICY_MAP_KEY_HANDLER_NOT_SET())); } this.service = service; this.port = port; this.operation = operation; this.faultMessage = faultMessage; this.handler = handler; }
Example #16
Source File: PolicyScope.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
void attach(final PolicySubject subject) { if (subject == null) { throw LOGGER.logSevereException(new IllegalArgumentException(LocalizationMessages.WSP_0020_SUBJECT_PARAM_MUST_NOT_BE_NULL())); } subjects.add(subject); }
Example #17
Source File: ExternalAttachmentsUnmarshaller.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private void processUri(final Characters chars, final Map<URI, Policy> map) throws PolicyException { final String data = chars.getData().trim(); try { final URI uri = new URI(data); if (this.currentPolicy != null) { map.put(uri, this.currentPolicy); this.currentUri = null; this.currentPolicy = null; } else { this.currentUri = uri; } } catch (URISyntaxException e) { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0093_INVALID_URI(data, chars.getLocation())), e); } }
Example #18
Source File: ModelNode.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Method checks the PSM state machine if the creation of new child of given type is plausible for a node element * with type set to this type instance. * * @param childType The type. * @return True if the type is supported, false otherwise */ private boolean isChildTypeSupported(final Type childType) { switch (this) { case POLICY: case ALL: case EXACTLY_ONE: switch (childType) { case ASSERTION_PARAMETER_NODE: return false; default: return true; } case POLICY_REFERENCE: return false; case ASSERTION: switch (childType) { case POLICY: case POLICY_REFERENCE: case ASSERTION_PARAMETER_NODE: return true; default: return false; } case ASSERTION_PARAMETER_NODE: switch (childType) { case ASSERTION_PARAMETER_NODE: return true; default: return false; } default: throw LOGGER.logSevereException(new IllegalStateException( LocalizationMessages.WSP_0060_POLICY_ELEMENT_TYPE_UNKNOWN(this))); } }
Example #19
Source File: ExternalAttachmentsUnmarshaller.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private void checkEndTagName(final QName expectedName, final EndElement element) throws PolicyException { final QName actualName = element.getName(); if (!expectedName.equals(actualName)) { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0091_END_ELEMENT_NO_MATCH(expectedName, element, element.getLocation()))); } }
Example #20
Source File: PolicyModelTranslator.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private static ModelNode getReferencedModelRootNode(final ModelNode policyReferenceNode) throws PolicyException { final PolicySourceModel referencedModel = policyReferenceNode.getReferencedModel(); if (referencedModel == null) { final PolicyReferenceData refData = policyReferenceNode.getPolicyReferenceData(); if (refData == null) { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0041_POLICY_REFERENCE_NODE_FOUND_WITH_NO_POLICY_REFERENCE_IN_IT())); } else { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0010_UNEXPANDED_POLICY_REFERENCE_NODE_FOUND_REFERENCING(refData.getReferencedModelUri()))); } } else { return referencedModel.getRootNode(); } }
Example #21
Source File: ExternalAttachmentsUnmarshaller.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private void processUri(final Characters chars, final Map<URI, Policy> map) throws PolicyException { final String data = chars.getData().trim(); try { final URI uri = new URI(data); if (this.currentPolicy != null) { map.put(uri, this.currentPolicy); this.currentUri = null; this.currentPolicy = null; } else { this.currentUri = uri; } } catch (URISyntaxException e) { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0093_INVALID_URI(data, chars.getLocation())), e); } }
Example #22
Source File: PolicyModelTranslator.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static ModelNode getReferencedModelRootNode(final ModelNode policyReferenceNode) throws PolicyException { final PolicySourceModel referencedModel = policyReferenceNode.getReferencedModel(); if (referencedModel == null) { final PolicyReferenceData refData = policyReferenceNode.getPolicyReferenceData(); if (refData == null) { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0041_POLICY_REFERENCE_NODE_FOUND_WITH_NO_POLICY_REFERENCE_IN_IT())); } else { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0010_UNEXPANDED_POLICY_REFERENCE_NODE_FOUND_REFERENCING(refData.getReferencedModelUri()))); } } else { return referencedModel.getRootNode(); } }
Example #23
Source File: PolicyModelTranslator.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * The method translates {@link PolicySourceModel} structure into normalized {@link Policy} expression. The resulting Policy * is disconnected from its model, thus any additional changes in model will have no effect on the Policy expression. * * @param model the model to be translated into normalized policy expression. Must not be {@code null}. * @return translated policy expression in it's normalized form. * @throws PolicyException in case of translation failure */ public Policy translate(final PolicySourceModel model) throws PolicyException { LOGGER.entering(model); if (model == null) { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0043_POLICY_MODEL_TRANSLATION_ERROR_INPUT_PARAM_NULL())); } PolicySourceModel localPolicyModelCopy; try { localPolicyModelCopy = model.clone(); } catch (CloneNotSupportedException e) { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0016_UNABLE_TO_CLONE_POLICY_SOURCE_MODEL(), e)); } final String policyId = localPolicyModelCopy.getPolicyId(); final String policyName = localPolicyModelCopy.getPolicyName(); final Collection<AssertionSet> alternatives = createPolicyAlternatives(localPolicyModelCopy); LOGGER.finest(LocalizationMessages.WSP_0052_NUMBER_OF_ALTERNATIVE_COMBINATIONS_CREATED(alternatives.size())); Policy policy = null; if (alternatives.size() == 0) { policy = Policy.createNullPolicy(model.getNamespaceVersion(), policyName, policyId); LOGGER.finest(LocalizationMessages.WSP_0055_NO_ALTERNATIVE_COMBINATIONS_CREATED()); } else if (alternatives.size() == 1 && alternatives.iterator().next().isEmpty()) { policy = Policy.createEmptyPolicy(model.getNamespaceVersion(), policyName, policyId); LOGGER.finest(LocalizationMessages.WSP_0026_SINGLE_EMPTY_ALTERNATIVE_COMBINATION_CREATED()); } else { policy = Policy.createPolicy(model.getNamespaceVersion(), policyName, policyId, alternatives); LOGGER.finest(LocalizationMessages.WSP_0057_N_ALTERNATIVE_COMBINATIONS_M_POLICY_ALTERNATIVES_CREATED(alternatives.size(), policy.getNumberOfAssertionSets())); } LOGGER.exiting(policy); return policy; }
Example #24
Source File: AssertionData.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private void setModelNodeType(final ModelNode.Type type) throws IllegalArgumentException { if (type == ModelNode.Type.ASSERTION || type == ModelNode.Type.ASSERTION_PARAMETER_NODE) { this.type = type; } else { throw LOGGER.logSevereException(new IllegalArgumentException( LocalizationMessages.WSP_0074_CANNOT_CREATE_ASSERTION_BAD_TYPE(type, ModelNode.Type.ASSERTION, ModelNode.Type.ASSERTION_PARAMETER_NODE))); } }
Example #25
Source File: PolicyModelTranslator.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private static ModelNode getReferencedModelRootNode(final ModelNode policyReferenceNode) throws PolicyException { final PolicySourceModel referencedModel = policyReferenceNode.getReferencedModel(); if (referencedModel == null) { final PolicyReferenceData refData = policyReferenceNode.getPolicyReferenceData(); if (refData == null) { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0041_POLICY_REFERENCE_NODE_FOUND_WITH_NO_POLICY_REFERENCE_IN_IT())); } else { throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0010_UNEXPANDED_POLICY_REFERENCE_NODE_FOUND_REFERENCING(refData.getReferencedModelUri()))); } } else { return referencedModel.getRootNode(); } }
Example #26
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 #27
Source File: NormalizedModelGenerator.java From TencentKona-8 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 #28
Source File: ExternalAttachmentsUnmarshaller.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private Map<URI, Policy> unmarshal(final XMLEventReader reader, final StartElement parentElement) throws PolicyException { XMLEvent event = null; while (reader.hasNext()) { try { event = reader.peek(); switch (event.getEventType()) { case XMLStreamConstants.START_DOCUMENT: case XMLStreamConstants.COMMENT: reader.nextEvent(); break; case XMLStreamConstants.CHARACTERS: processCharacters(event.asCharacters(), parentElement, map); reader.nextEvent(); break; case XMLStreamConstants.END_ELEMENT: processEndTag(event.asEndElement(), parentElement); reader.nextEvent(); return map; case XMLStreamConstants.START_ELEMENT: final StartElement element = event.asStartElement(); processStartTag(element, parentElement, reader, map); break; case XMLStreamConstants.END_DOCUMENT: return map; default: throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0087_UNKNOWN_EVENT(event))); } } catch (XMLStreamException e) { final Location location = event == null ? null : event.getLocation(); throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0088_FAILED_PARSE(location)), e); } } return map; }
Example #29
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 #30
Source File: PolicyScope.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
void attach(final PolicySubject subject) { if (subject == null) { throw LOGGER.logSevereException(new IllegalArgumentException(LocalizationMessages.WSP_0020_SUBJECT_PARAM_MUST_NOT_BE_NULL())); } subjects.add(subject); }