Java Code Examples for org.jboss.as.controller.parsing.ParseUtils

The following examples show how to use org.jboss.as.controller.parsing.ParseUtils. These examples are extracted from open source projects. 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
private void parseHostRelease(XMLExtendedStreamReader reader, ModelNode addOp) throws XMLStreamException {

        boolean sawId = false;
        final int count = reader.getAttributeCount();
        for (int i = 0; i < count; i++) {

            final String value = reader.getAttributeValue(i);
            if (!isNoNamespaceAttribute(reader, i)) {
                throw ParseUtils.unexpectedAttribute(reader, i);
            }

            final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
            if (attribute == Attribute.ID) {
                sawId = true;
                HostExcludeResourceDefinition.HOST_RELEASE.parseAndSetParameter(value, addOp, reader);
            } else {
                throw unexpectedAttribute(reader, i);
            }
        }

        if (!sawId) {
            throw missingRequired(reader, Attribute.ID.getLocalName());
        }

        requireNoContent(reader);
    }
 
Example 2
Source Project: keycloak   Source File: KeycloakSubsystemParser.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void readElement(final XMLExtendedStreamReader reader, final List<ModelNode> list) throws XMLStreamException {
    // Require no attributes
    ParseUtils.requireNoAttributes(reader);
    ModelNode addKeycloakSub = Util.createAddOperation(PathAddress.pathAddress(KeycloakExtension.PATH_SUBSYSTEM));
    list.add(addKeycloakSub);

    while (reader.hasNext() && nextTag(reader) != END_ELEMENT) {
        if (reader.getLocalName().equals(RealmDefinition.TAG_NAME)) {
            readRealm(reader, list);
        }
        else if (reader.getLocalName().equals(SecureDeploymentDefinition.TAG_NAME)) {
            readDeployment(reader, list);
        }
    }
}
 
Example 3
@Override
public void readElement(XMLExtendedStreamReader reader, List<ModelNode> list) throws XMLStreamException {
    ParseUtils.requireNoAttributes(reader);
    list.add(Util.createAddOperation(PathAddress.pathAddress(ModelDescriptionConstants.SUBSYSTEM, SUBSYSTEM_NAME)));

    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        final String element = reader.getLocalName();
        switch (element) {
            case "child": {
                list.add(parseChild(reader));
                break;
            }
            default: {
                throw ParseUtils.unexpectedElement(reader);
            }
        }
    }
}
 
Example 4
/**
 * {@inheritDoc}
 */
@Override
public void readElement(XMLExtendedStreamReader reader, List<ModelNode> list) throws XMLStreamException {
    ParseUtils.requireNoAttributes(reader);
    list.add(createAddOperation());

    boolean gotConnector = false;

    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        final String element = reader.getLocalName();
        switch (element) {
            case CommonAttributes.JMX_CONNECTOR: {
                if (gotConnector) {
                    throw ParseUtils.duplicateNamedElement(reader, CommonAttributes.JMX_CONNECTOR);
                }
                parseConnector(reader);
                gotConnector = true;
                break;
            }
            default: {
                throw ParseUtils.unexpectedElement(reader);
            }
        }
    }
}
 
Example 5
private void parseSensitivity(ModelNode add, XMLExtendedStreamReader reader) throws XMLStreamException {
    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 CommonAttributes.NON_CORE_MBEANS:
                JMXSubsystemRootResource.CORE_MBEAN_SENSITIVITY.parseAndSetParameter(value, add, reader);
                break;
            default:
                throw ParseUtils.unexpectedAttribute(reader, i);
        }
    }

    ParseUtils.requireNoContent(reader);
}
 
Example 6
private void parseSensitiveClassifications(final XMLExtendedStreamReader reader, final ModelNode address,
        final List<ModelNode> list) throws XMLStreamException {

    ParseUtils.requireNoAttributes(reader);

    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        requireNamespace(reader, namespace);
        final Element element = Element.forName(reader.getLocalName());
        switch (element) {
            case SENSITIVE_CLASSIFICATION: {
                parseSensitivityClassification(reader, address, list);
                break;
            }
            default: {
                throw unexpectedElement(reader);
            }
        }
    }
}
 
Example 7
Source Project: keycloak   Source File: KeycloakSubsystemParser.java    License: Apache License 2.0 6 votes vote down vote up
void readSecureDeployment(XMLExtendedStreamReader reader, List<ModelNode> list) throws XMLStreamException {
    String name = readRequiredAttribute(reader, Constants.XML.NAME);

    PathAddress addr = PathAddress.pathAddress(
            PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, KeycloakSamlExtension.SUBSYSTEM_NAME),
            PathElement.pathElement(Constants.Model.SECURE_DEPLOYMENT, name));
    ModelNode addSecureDeployment = Util.createAddOperation(addr);
    list.add(addSecureDeployment);

    Set<String> parsedElements = new HashSet<>();
    while (reader.hasNext() && nextTag(reader) != END_ELEMENT) {
        String tagName = reader.getLocalName();
        if (parsedElements.contains(tagName)) {
            // all sub-elements of the secure deployment type should occur only once.
            throw ParseUtils.unexpectedElement(reader);
        }
        if (tagName.equals(Constants.XML.SERVICE_PROVIDER)) {
            readServiceProvider(reader, list, addr);
        } else {
            throw ParseUtils.unexpectedElement(reader);
        }
        parsedElements.add(tagName);
    }
}
 
Example 8
private void parseHostRelease(XMLExtendedStreamReader reader, ModelNode addOp) throws XMLStreamException {

        boolean sawId = false;
        final int count = reader.getAttributeCount();
        for (int i = 0; i < count; i++) {

            final String value = reader.getAttributeValue(i);
            if (!isNoNamespaceAttribute(reader, i)) {
                throw ParseUtils.unexpectedAttribute(reader, i);
            }

            final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
            if (attribute == Attribute.ID) {
                sawId = true;
                HostExcludeResourceDefinition.HOST_RELEASE.parseAndSetParameter(value, addOp, reader);
            } else {
                throw unexpectedAttribute(reader, i);
            }
        }

        if (!sawId) {
            throw missingRequired(reader, Attribute.ID.getLocalName());
        }

        requireNoContent(reader);
    }
 
Example 9
/**
 * Parse xml from provided <code>reader</code> and add resulting operations to passed list
 * @param reader xml reader to parse from
 * @param parentAddress address of the parent, used as base for all child elements
 * @param list list of operations where result will be put to.
 * @throws XMLStreamException if any error occurs while parsing
 */
public void parse(final XMLExtendedStreamReader reader, PathAddress parentAddress, List<ModelNode> list) throws XMLStreamException {
    if (decoratorElement != null) {
        parseDecorator(reader, parentAddress, list);
        return;
    }
    if (xmlWrapperElement != null) {
        if (reader.getLocalName().equals(xmlWrapperElement)) {
            if (reader.hasNext() && reader.nextTag() == END_ELEMENT) { return; }
        } else {
            throw ParseUtils.unexpectedElement(reader);
        }
        parseInternal(reader, parentAddress, list);
        while (reader.nextTag() != END_ELEMENT && !reader.getLocalName().equals(xmlWrapperElement)) {
            parseInternal(reader, parentAddress, list);
        }
    } else {
        parseInternal(reader, parentAddress, list);
    }
}
 
Example 10
private void parseHostRelease(XMLExtendedStreamReader reader, ModelNode addOp) throws XMLStreamException {

        boolean sawId = false;
        final int count = reader.getAttributeCount();
        for (int i = 0; i < count; i++) {

            final String value = reader.getAttributeValue(i);
            if (!isNoNamespaceAttribute(reader, i)) {
                throw ParseUtils.unexpectedAttribute(reader, i);
            }

            final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
            if (attribute == Attribute.ID) {
                sawId = true;
                HostExcludeResourceDefinition.HOST_RELEASE.parseAndSetParameter(value, addOp, reader);
            } else {
                throw unexpectedAttribute(reader, i);
            }
        }

        if (!sawId) {
            throw missingRequired(reader, Attribute.ID.getLocalName());
        }

        requireNoContent(reader);
    }
 
Example 11
private void parseHostRelease(XMLExtendedStreamReader reader, ModelNode addOp) throws XMLStreamException {

        boolean sawId = false;
        final int count = reader.getAttributeCount();
        for (int i = 0; i < count; i++) {

            final String value = reader.getAttributeValue(i);
            if (!isNoNamespaceAttribute(reader, i)) {
                throw ParseUtils.unexpectedAttribute(reader, i);
            }

            final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
            if (attribute == Attribute.ID) {
                sawId = true;
                HostExcludeResourceDefinition.HOST_RELEASE.parseAndSetParameter(value, addOp, reader);
            } else {
                throw unexpectedAttribute(reader, i);
            }
        }

        if (!sawId) {
            throw missingRequired(reader, Attribute.ID.getLocalName());
        }

        requireNoContent(reader);
    }
 
Example 12
Source Project: keycloak   Source File: KeycloakSubsystemParser.java    License: Apache License 2.0 6 votes vote down vote up
void readRoleIdentifiers(ModelNode addServiceProvider, XMLExtendedStreamReader reader) throws XMLStreamException {
    ParseUtils.requireNoAttributes(reader);

    while (reader.hasNext() && nextTag(reader) != END_ELEMENT) {
        String tagName = reader.getLocalName();

        if (!Constants.XML.ATTRIBUTE.equals(tagName)) {
            throw ParseUtils.unexpectedElement(reader);
        }

        ParseUtils.requireSingleAttribute(reader, Constants.XML.NAME);
        String name = ParseUtils.readStringAttributeElement(reader, Constants.XML.NAME);

        ServiceProviderDefinition.ROLE_ATTRIBUTES.parseAndAddParameterElement(name, addServiceProvider, reader);
    }
}
 
Example 13
Source Project: keycloak   Source File: KeycloakSubsystemParser.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void readElement(final XMLExtendedStreamReader reader, final List<ModelNode> list) throws XMLStreamException {
    // Require no attributes
    ParseUtils.requireNoAttributes(reader);
    ModelNode addKeycloakSub = Util.createAddOperation(PathAddress.pathAddress(KeycloakExtension.PATH_SUBSYSTEM));
    list.add(addKeycloakSub);

    while (reader.hasNext() && nextTag(reader) != END_ELEMENT) {
        if (reader.getLocalName().equals(RealmDefinition.TAG_NAME)) {
            readRealm(reader, list);
        }
        else if (reader.getLocalName().equals(SecureDeploymentDefinition.TAG_NAME)) {
            readDeployment(reader, list);
        }
        else if (reader.getLocalName().equals(SecureServerDefinition.TAG_NAME)) {
            readSecureServer(reader, list);
        }
    }
}
 
Example 14
private void parseGroup(XMLExtendedStreamReader reader, ModelNode op, boolean wildcard) throws XMLStreamException {
    Map<String, AttributeDefinition> groupAttrs = attributesByGroup.get(reader.getLocalName());
    for (AttributeDefinition attrGroup : groupAttrs.values()) {
        if (op.hasDefined(attrGroup.getName())) {
            throw ParseUtils.unexpectedElement(reader);
        }
    }
    parseAttributes(reader, op, groupAttrs, wildcard);
    // Check if there are also element attributes inside a group
    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        AttributeDefinition ad = groupAttrs.get(reader.getLocalName());
        if (ad != null) {
            ad.getParser().parseElement(ad, reader, op);
        } else {
            throw ParseUtils.unexpectedElement(reader);
        }
    }
}
 
Example 15
private void parseHostRelease(XMLExtendedStreamReader reader, ModelNode addOp) throws XMLStreamException {

        boolean sawId = false;
        final int count = reader.getAttributeCount();
        for (int i = 0; i < count; i++) {

            final String value = reader.getAttributeValue(i);
            if (!isNoNamespaceAttribute(reader, i)) {
                throw ParseUtils.unexpectedAttribute(reader, i);
            }

            final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
            if (attribute == Attribute.ID) {
                sawId = true;
                HostExcludeResourceDefinition.HOST_RELEASE.parseAndSetParameter(value, addOp, reader);
            } else {
                throw unexpectedAttribute(reader, i);
            }
        }

        if (!sawId) {
            throw missingRequired(reader, Attribute.ID.getLocalName());
        }

        requireNoContent(reader);
    }
 
Example 16
Source Project: keycloak   Source File: KeycloakSubsystemParser.java    License: Apache License 2.0 6 votes vote down vote up
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 17
private void parseHostRelease(XMLExtendedStreamReader reader, ModelNode addOp) throws XMLStreamException {

        boolean sawId = false;
        final int count = reader.getAttributeCount();
        for (int i = 0; i < count; i++) {

            final String value = reader.getAttributeValue(i);
            if (!isNoNamespaceAttribute(reader, i)) {
                throw ParseUtils.unexpectedAttribute(reader, i);
            }

            final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
            if (attribute == Attribute.ID) {
                sawId = true;
                HostExcludeResourceDefinition.HOST_RELEASE.parseAndSetParameter(value, addOp, reader);
            } else {
                throw unexpectedAttribute(reader, i);
            }
        }

        if (!sawId) {
            throw missingRequired(reader, Attribute.ID.getLocalName());
        }

        requireNoContent(reader);
    }
 
Example 18
private void parseHostRelease(XMLExtendedStreamReader reader, ModelNode addOp) throws XMLStreamException {

        boolean sawId = false;
        final int count = reader.getAttributeCount();
        for (int i = 0; i < count; i++) {

            final String value = reader.getAttributeValue(i);
            if (!isNoNamespaceAttribute(reader, i)) {
                throw ParseUtils.unexpectedAttribute(reader, i);
            }

            final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
            if (attribute == Attribute.ID) {
                sawId = true;
                HostExcludeResourceDefinition.HOST_RELEASE.parseAndSetParameter(value, addOp, reader);
            } else {
                throw unexpectedAttribute(reader, i);
            }
        }

        if (!sawId) {
            throw missingRequired(reader, Attribute.ID.getLocalName());
        }

        requireNoContent(reader);
    }
 
Example 19
private void parseServerSocketBindings(final XMLExtendedStreamReader reader, final ModelNode serverAddOperation) throws XMLStreamException {
    // Handle attributes

    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        final String value = reader.getAttributeValue(i);
        if (!isNoNamespaceAttribute(reader, i)) {
            throw ParseUtils.unexpectedAttribute(reader, i);
        } else {
            final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
            switch (attribute) {
                case SOCKET_BINDING_GROUP: {
                    ServerConfigResourceDefinition.SOCKET_BINDING_GROUP.parseAndSetParameter(value, serverAddOperation, reader);
                    break;
                }
                case DEFAULT_INTERFACE: {
                    ServerConfigResourceDefinition.SOCKET_BINDING_DEFAULT_INTERFACE.parseAndSetParameter(value, serverAddOperation, reader);
                    break;
                }
                case PORT_OFFSET: {
                    ServerConfigResourceDefinition.SOCKET_BINDING_PORT_OFFSET.parseAndSetParameter(value, serverAddOperation, reader);
                    break;
                }
                default:
                    throw unexpectedAttribute(reader, i);
            }
        }
    }

    // Handle elements
    requireNoContent(reader);

}
 
Example 20
@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 21
@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 22
Source Project: keycloak   Source File: KeycloakSubsystemParser.java    License: Apache License 2.0 5 votes vote down vote up
void readSingleSignOn(ModelNode addIdentityProvider, XMLExtendedStreamReader reader) throws XMLStreamException {
    ModelNode sso = addIdentityProvider.get(Constants.Model.SINGLE_SIGN_ON);
    for (int i = 0; i < reader.getAttributeCount(); i++) {
        String name = reader.getAttributeLocalName(i);
        String value = reader.getAttributeValue(i);

        SimpleAttributeDefinition attr = SingleSignOnDefinition.lookup(name);
        if (attr == null) {
            throw ParseUtils.unexpectedAttribute(reader, i);
        }
        attr.parseAndSetParameter(value, sso, reader);
    }
    ParseUtils.requireNoContent(reader);
}
 
Example 23
void parseConnector(XMLExtendedStreamReader reader) throws XMLStreamException {
    JmxLogger.ROOT_LOGGER.jmxConnectorNotSupported();
    String serverBinding = null;
    String registryBinding = null;
    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 CommonAttributes.SERVER_BINDING: {
                serverBinding = value;
                break;
            }
            case CommonAttributes.REGISTRY_BINDING: {
                registryBinding = value;
                break;
            }
            default: {
                throw ParseUtils.unexpectedAttribute(reader, i);
            }
        }
    }
    // Require no content
    ParseUtils.requireNoContent(reader);
    if (serverBinding == null) {
        throw ParseUtils.missingRequired(reader, Collections.singleton(CommonAttributes.SERVER_BINDING));
    }
    if (registryBinding == null) {
        throw ParseUtils.missingRequired(reader, Collections.singleton(CommonAttributes.REGISTRY_BINDING));
    }
}
 
Example 24
@Override
public void readElement(XMLExtendedStreamReader reader, List<ModelNode> list) throws XMLStreamException {
    boolean showResolvedModel = false;
    boolean showExpressionModel = false;
    boolean connectorAdd = false;

    ParseUtils.requireNoAttributes(reader);

    list.add(createAddOperation());

    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        final String element = reader.getLocalName();
        switch (element) {
            case CommonAttributes.EXPOSE_RESOLVED_MODEL:
                if (showResolvedModel) {
                    throw ParseUtils.duplicateNamedElement(reader, CommonAttributes.EXPOSE_RESOLVED_MODEL);
                }
                showResolvedModel = true;
                list.add(parseShowModelElement(reader, CommonAttributes.RESOLVED));
                break;
            case CommonAttributes.EXPOSE_EXPRESSION_MODEL:
                if (showExpressionModel) {
                    throw ParseUtils.duplicateNamedElement(reader, CommonAttributes.EXPOSE_EXPRESSION_MODEL);
                }
                showExpressionModel = true;
                list.add(parseShowModelElement(reader, CommonAttributes.EXPRESSION));
                break;
            case REMOTING_CONNECTOR:
                if (connectorAdd) {
                    throw ParseUtils.duplicateNamedElement(reader, CommonAttributes.REMOTING_CONNECTOR);
                }
                connectorAdd = true;
                list.add(parseRemoteConnector(reader));
                break;
            default: {
                throw ParseUtils.unexpectedElement(reader);
            }
        }
    }
}
 
Example 25
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 26
private void parseAuditLogElement(XMLExtendedStreamReader reader, List<ModelNode> list) throws XMLStreamException {

            ModelNode op = createOperation(ADD, JmxAuditLoggerResourceDefinition.PATH_ELEMENT.getKey(), JmxAuditLoggerResourceDefinition.PATH_ELEMENT.getValue());

            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 CommonAttributes.LOG_BOOT: {
                        JmxAuditLoggerResourceDefinition.LOG_BOOT.parseAndSetParameter(value, op, reader);
                        break;
                    }
                    case CommonAttributes.LOG_READ_ONLY: {
                        JmxAuditLoggerResourceDefinition.LOG_READ_ONLY.parseAndSetParameter(value, op, reader);
                        break;
                    }
                    case CommonAttributes.ENABLED: {
                        JmxAuditLoggerResourceDefinition.ENABLED.parseAndSetParameter(value, op, reader);
                        break;
                    }
                    default: {
                        throw ParseUtils.unexpectedAttribute(reader, i);
                    }
                }
            }
            list.add(op);

            while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
                final String element = reader.getLocalName();
                switch (element) {
                    case CommonAttributes.HANDLERS:
                        parseAuditLogHandlers(reader, list);
                        break;
                    default: {
                        throw ParseUtils.unexpectedElement(reader);
                    }
                }
            }
        }
 
Example 27
/** {@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 28
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 29
public void parseAccessControlConstraints(final XMLExtendedStreamReader reader, final ModelNode accAuthzAddr, final List<ModelNode> list) throws XMLStreamException {
    ParseUtils.requireNoAttributes(reader);

    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        requireNamespace(reader, namespace);
        final Element element = Element.forName(reader.getLocalName());
        switch (element) {
            case VAULT_EXPRESSION_SENSITIVITY: {
                ModelNode vaultAddr = accAuthzAddr.clone().add(CONSTRAINT, VAULT_EXPRESSION);
                parseClassificationType(reader, vaultAddr, list, true);
                break;
            }
            case SENSITIVE_CLASSIFICATIONS: {
                ModelNode sensAddr = accAuthzAddr.clone().add(CONSTRAINT, SENSITIVITY_CLASSIFICATION);
                parseSensitiveClassifications(reader, sensAddr, list);
                break;
            }
            case APPLICATION_CLASSIFICATIONS: {
                ModelNode applAddr = accAuthzAddr.clone().add(CONSTRAINT, APPLICATION_CLASSIFICATION);
                parseApplicationClassifications(reader, applAddr, list);
                break;
            }
            default: {
                throw unexpectedElement(reader);
            }
        }
    }
}
 
Example 30
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);
    }