Java Code Examples for org.jboss.as.controller.parsing.ParseUtils#requireNoContent()
The following examples show how to use
org.jboss.as.controller.parsing.ParseUtils#requireNoContent() .
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: KeycloakSubsystemParser.java From keycloak with Apache License 2.0 | 6 votes |
void readPrivateKey(XMLExtendedStreamReader reader, ModelNode addKeyStore) throws XMLStreamException { for (int i = 0; i < reader.getAttributeCount(); i++) { String name = reader.getAttributeLocalName(i); String value = reader.getAttributeValue(i); SimpleAttributeDefinition attr = KeyStorePrivateKeyDefinition.lookup(name); if (attr == null) { throw ParseUtils.unexpectedAttribute(reader, i); } attr.parseAndSetParameter(value, addKeyStore, reader); } if (!addKeyStore.hasDefined(Constants.Model.PRIVATE_KEY_ALIAS)) { throw ParseUtils.missingRequired(reader, Constants.XML.PRIVATE_KEY_ALIAS); } if (!addKeyStore.hasDefined(Constants.Model.PRIVATE_KEY_PASSWORD)) { throw ParseUtils.missingRequired(reader, Constants.XML.PRIVATE_KEY_PASSWORD); } ParseUtils.requireNoContent(reader); }
Example 2
Source File: KeycloakSubsystemParser.java From keycloak with Apache License 2.0 | 6 votes |
void readPrivateKey(XMLExtendedStreamReader reader, ModelNode addKeyStore) throws XMLStreamException { for (int i = 0; i < reader.getAttributeCount(); i++) { String name = reader.getAttributeLocalName(i); String value = reader.getAttributeValue(i); SimpleAttributeDefinition attr = KeyStorePrivateKeyDefinition.lookup(name); if (attr == null) { throw ParseUtils.unexpectedAttribute(reader, i); } attr.parseAndSetParameter(value, addKeyStore, reader); } if (!addKeyStore.hasDefined(Constants.Model.PRIVATE_KEY_ALIAS)) { throw ParseUtils.missingRequired(reader, asSet(Constants.XML.PRIVATE_KEY_ALIAS)); } if (!addKeyStore.hasDefined(Constants.Model.PRIVATE_KEY_PASSWORD)) { throw ParseUtils.missingRequired(reader, asSet(Constants.XML.PRIVATE_KEY_PASSWORD)); } ParseUtils.requireNoContent(reader); }
Example 3
Source File: KeycloakSubsystemParser.java From keycloak with Apache License 2.0 | 6 votes |
void readPrincipalNameMapping(ModelNode addServiceProvider, XMLExtendedStreamReader reader) throws XMLStreamException { boolean policySet = false; for (int i = 0; i < reader.getAttributeCount(); i++) { String name = reader.getAttributeLocalName(i); String value = reader.getAttributeValue(i); if (Constants.XML.PRINCIPAL_NAME_MAPPING_POLICY.equals(name)) { policySet = true; ServiceProviderDefinition.PRINCIPAL_NAME_MAPPING_POLICY.parseAndSetParameter(value, addServiceProvider, reader); } else if (Constants.XML.PRINCIPAL_NAME_MAPPING_ATTRIBUTE_NAME.equals(name)) { ServiceProviderDefinition.PRINCIPAL_NAME_MAPPING_ATTRIBUTE_NAME.parseAndSetParameter(value, addServiceProvider, reader); } else { throw ParseUtils.unexpectedAttribute(reader, i); } } if (!policySet) { throw ParseUtils.missingRequired(reader, Constants.XML.PRINCIPAL_NAME_MAPPING_POLICY); } ParseUtils.requireNoContent(reader); }
Example 4
Source File: KeycloakSubsystemParser.java From keycloak with Apache License 2.0 | 5 votes |
void readSingleLogout(ModelNode addIdentityProvider, XMLExtendedStreamReader reader) throws XMLStreamException { ModelNode slo = addIdentityProvider.get(Constants.Model.SINGLE_LOGOUT); for (int i = 0; i < reader.getAttributeCount(); i++) { String name = reader.getAttributeLocalName(i); String value = reader.getAttributeValue(i); SimpleAttributeDefinition attr = SingleLogoutDefinition.lookup(name); if (attr == null) { throw ParseUtils.unexpectedAttribute(reader, i); } attr.parseAndSetParameter(value, slo, reader); } ParseUtils.requireNoContent(reader); }
Example 5
Source File: SimpleSubsystemExtension.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
/** {@inheritDoc} */ @Override public void readElement(XMLExtendedStreamReader reader, List<ModelNode> list) throws XMLStreamException { // Require no content ParseUtils.requireNoContent(reader); list.add(Util.createAddOperation(PathAddress.pathAddress(PathElement.pathElement(SUBSYSTEM, SUBSYSTEM_NAME)))); }
Example 6
Source File: AttributeParsers.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void parseElement(AttributeDefinition ad, XMLExtendedStreamReader reader, ModelNode addPermissionMapper) throws XMLStreamException { ParseUtils.requireSingleAttribute(reader, NAME); String name = reader.getAttributeValue(0); addPermissionMapper.get(ad.getName()).add(name); ParseUtils.requireNoContent(reader); }
Example 7
Source File: KeycloakSubsystemParser.java From keycloak with Apache License 2.0 | 5 votes |
void readHttpClient(final ModelNode addIdentityProvider, final XMLExtendedStreamReader reader) throws XMLStreamException { ModelNode httpClientNode = addIdentityProvider.get(Constants.Model.HTTP_CLIENT); for (int i = 0; i < reader.getAttributeCount(); i++) { String name = reader.getAttributeLocalName(i); String value = reader.getAttributeValue(i); SimpleAttributeDefinition attr = HttpClientDefinition.lookup(name); if (attr == null) { throw ParseUtils.unexpectedAttribute(reader, i); } attr.parseAndSetParameter(value, httpClientNode, reader); } ParseUtils.requireNoContent(reader); }
Example 8
Source File: MainSubsystemExtension.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
/** {@inheritDoc} */ @Override public void readElement(XMLExtendedStreamReader reader, List<ModelNode> list) throws XMLStreamException { // Require no content ParseUtils.requireNoContent(reader); list.add(Util.createAddOperation(PathAddress.pathAddress(PathElement.pathElement(SUBSYSTEM, SUBSYSTEM_NAME)))); }
Example 9
Source File: KeepAliveTimeAttributeDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
public void parseAndSetParameter(final ModelNode operation, final XMLExtendedStreamReader reader) throws XMLStreamException { ModelNode model = new ModelNode(); final int attrCount = reader.getAttributeCount(); Set<Attribute> required = EnumSet.of(Attribute.TIME, Attribute.UNIT); for (int i = 0; i < attrCount; i++) { requireNoNamespaceAttribute(reader, i); final String value = reader.getAttributeValue(i); final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); required.remove(attribute); switch (attribute) { case TIME: { KEEPALIVE_TIME_TIME.parseAndSetParameter(value, model, reader); break; } case UNIT: { KEEPALIVE_TIME_UNIT.parseAndSetParameter(value, model, reader); break; } default: throw unexpectedAttribute(reader, i); } } if (!required.isEmpty()) { throw missingRequired(reader, required); } ParseUtils.requireNoContent(reader); operation.get(getName()).set(model); }
Example 10
Source File: VersionedExtensionCommon.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void readElement(XMLExtendedStreamReader reader, List<ModelNode> list) throws XMLStreamException { ParseUtils.requireNoAttributes(reader); ParseUtils.requireNoContent(reader); ModelNode subsystemAdd = Util.createAddOperation(PathAddress.pathAddress(PathElement.pathElement(SUBSYSTEM, SUBSYSTEM_NAME))); subsystemAdd.get("test-attribute").set("This is only a test"); list.add(subsystemAdd); addChildElements(list); }
Example 11
Source File: JMXExtension.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private void parseAuditLogHandler(XMLExtendedStreamReader reader, List<ModelNode> list) throws XMLStreamException { String name = null; final int count = reader.getAttributeCount(); for (int i = 0; i < count; i++) { final String value = reader.getAttributeValue(i); final String attribute = reader.getAttributeLocalName(i); switch (attribute) { case NAME: name = value; break; default: throw ParseUtils.unexpectedAttribute(reader, i); } } if (name == null) { throw ParseUtils.missingRequired(reader, Collections.singleton(NAME)); } ModelNode op = createOperation(ADD, JmxAuditLoggerResourceDefinition.PATH_ELEMENT.getKey(), JmxAuditLoggerResourceDefinition.PATH_ELEMENT.getValue(), JmxAuditLogHandlerReferenceResourceDefinition.PATH_ELEMENT.getKey(), name); list.add(op); ParseUtils.requireNoContent(reader); }
Example 12
Source File: NewExtension.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void readElement(XMLExtendedStreamReader reader, List<ModelNode> list) throws XMLStreamException { ParseUtils.requireNoAttributes(reader); ParseUtils.requireNoContent(reader); ModelNode subsystemAdd = Util.createAddOperation(PathAddress.pathAddress(PathElement.pathElement(SUBSYSTEM, SUBSYSTEM_NAME))); subsystemAdd.get("test").set("Hello"); subsystemAdd.get("properties", "one").set("A"); subsystemAdd.get("properties", "two").set("B"); list.add(subsystemAdd); }
Example 13
Source File: JMXExtension.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
protected ModelNode parseShowModelElement(XMLExtendedStreamReader reader, String showModelChild) throws XMLStreamException { ModelNode op = createOperation(ADD, CommonAttributes.EXPOSE_MODEL, showModelChild); String domainName = null; Boolean properPropertyFormat = null; for (int i = 0; i < reader.getAttributeCount(); i++) { final String value = reader.getAttributeValue(i); final String attribute = reader.getAttributeLocalName(i); switch (attribute) { case CommonAttributes.DOMAIN_NAME: ExposeModelResource.getDomainNameAttribute(showModelChild).parseAndSetParameter(value, op, reader); break; case CommonAttributes.PROPER_PROPERTY_FORMAT: if (showModelChild.equals(CommonAttributes.RESOLVED)) { ExposeModelResourceResolved.PROPER_PROPERTY_FORMAT.parseAndSetParameter(value, op, reader); } else { throw ParseUtils.unexpectedAttribute(reader, i); } break; default: throw ParseUtils.unexpectedAttribute(reader, i); } } if (domainName == null && properPropertyFormat == null) { ParseUtils.requireNoContent(reader); } return op; }
Example 14
Source File: KeycloakSubsystemParser.java From keycloak with Apache License 2.0 | 5 votes |
void readSingleLogout(ModelNode addIdentityProvider, XMLExtendedStreamReader reader) throws XMLStreamException { ModelNode slo = addIdentityProvider.get(Constants.Model.SINGLE_LOGOUT); for (int i = 0; i < reader.getAttributeCount(); i++) { String name = reader.getAttributeLocalName(i); String value = reader.getAttributeValue(i); SimpleAttributeDefinition attr = SingleLogoutDefinition.lookup(name); if (attr == null) { throw ParseUtils.unexpectedAttribute(reader, i); } attr.parseAndSetParameter(value, slo, reader); } ParseUtils.requireNoContent(reader); }
Example 15
Source File: ValidateSubsystemExtension.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
/** {@inheritDoc} */ @Override public void readElement(XMLExtendedStreamReader reader, List<ModelNode> list) throws XMLStreamException { // Require no content ParseUtils.requireNoContent(reader); list.add(createAddSubsystemOperation()); }
Example 16
Source File: TestVaultParser.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void readElement(XMLExtendedStreamReader reader, List<ModelNode> ops) throws XMLStreamException { ParseUtils.requireNoAttributes(reader); ParseUtils.requireNoContent(reader); ops.add(Util.createAddOperation(PathAddress.pathAddress(TestVaultSubsystemResourceDescription.PATH))); }
Example 17
Source File: CliExtCommandsParser.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void readElement(XMLExtendedStreamReader reader, List<ModelNode> ops) throws XMLStreamException { ParseUtils.requireNoAttributes(reader); ParseUtils.requireNoContent(reader); ops.add(Util.createAddOperation(PathAddress.pathAddress(CliExtCommandsSubsystemResourceDescription.PATH))); }
Example 18
Source File: OtherServicesSubsystemExtension.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
/** {@inheritDoc} */ @Override public void readElement(XMLExtendedStreamReader reader, List<ModelNode> list) throws XMLStreamException { // Require no content ParseUtils.requireNoContent(reader); list.add(Util.createAddOperation(PathAddress.pathAddress(PathElement.pathElement(SUBSYSTEM, SUBSYSTEM_NAME)))); }
Example 19
Source File: AccessControlXml.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
private void parseApplicationClassification(final XMLExtendedStreamReader reader, final ModelNode address, final List<ModelNode> list) throws XMLStreamException { String name = null; String type = null; Boolean applicationValue = null; final int count = reader.getAttributeCount(); for (int i = 0; i < count; i++) { final String value = reader.getAttributeValue(i); if (!isNoNamespaceAttribute(reader, i)) { throw unexpectedAttribute(reader, i); } else { final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case NAME: name = value; break; case TYPE: type = value; break; case APPLICATION: applicationValue = Boolean.valueOf(value); break; default: { throw unexpectedAttribute(reader, i); } } } } if (name == null) { throw ParseUtils.missingRequired(reader, Collections.singleton(NAME)); } if (type == null) { throw ParseUtils.missingRequired(reader, Collections.singleton(Attribute.TYPE)); } if (applicationValue == null) { throw ParseUtils.missingRequired(reader, Collections.singleton(Attribute.APPLICATION)); } ModelNode newAddress = address.clone() .add(ApplicationClassificationTypeResourceDefinition.PATH_ELEMENT.getKey(), type) .add(ApplicationClassificationConfigResourceDefinition.PATH_ELEMENT.getKey(), name); list.add(Util.getWriteAttributeOperation(newAddress, ApplicationClassificationConfigResourceDefinition.CONFIGURED_APPLICATION.getName(), applicationValue.toString())); ParseUtils.requireNoContent(reader); }
Example 20
Source File: ThreadsParser.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
private void parseProperties(final XMLExtendedStreamReader reader, final Namespace threadsNamespace) throws XMLStreamException { if (threadsNamespace != Namespace.THREADS_1_0) { throw unexpectedElement(reader); } // else consume and discard the never implemented 1.0 "properties" element. // This code validates, which is a debatable given the data is going to be discarded while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { switch (Element.forName(reader.getLocalName())) { case PROPERTY: { final int attrCount = reader.getAttributeCount(); String propName = null; String propValue = null; for (int i = 0; i < attrCount; i++) { requireNoNamespaceAttribute(reader, i); final String value = reader.getAttributeValue(i); final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case NAME: { propName = value; break; } case VALUE: { propValue = value; } break; default: throw unexpectedAttribute(reader, i); } } if (propName == null || propValue == null) { Set<Attribute> missing = new HashSet<Attribute>(); if (propName == null) { missing.add(Attribute.NAME); } if (propValue == null) { missing.add(Attribute.VALUE); } throw missingRequired(reader, missing); } ParseUtils.requireNoContent(reader); } } } }