Search in sources :

Example 1 with ModelElement

use of org.wildfly.extension.picketlink.common.model.ModelElement in project wildfly by wildfly.

the class AbstractIDMSubsystemReader method parseJPAStoreConfig.

private void parseJPAStoreConfig(final XMLExtendedStreamReader reader, final ModelNode identityConfigurationNode, final List<ModelNode> addOperations) throws XMLStreamException {
    ModelNode jpaStoreNode = parseConfig(reader, JPA_STORE, null, identityConfigurationNode, JPAStoreResourceDefinition.INSTANCE.getAttributes(), addOperations);
    parseElement(new ElementParser() {

        @Override
        public void parse(final XMLExtendedStreamReader reader, final ModelElement element, final ModelNode parentNode, List<ModelNode> addOperations) throws XMLStreamException {
            switch(element) {
                case IDENTITY_STORE_CREDENTIAL_HANDLER:
                    parseCredentialHandlerConfig(reader, parentNode, addOperations);
                    break;
                case SUPPORTED_TYPES:
                    parseSupportedTypesConfig(reader, parentNode, addOperations);
                    break;
            }
        }
    }, JPA_STORE, jpaStoreNode, reader, addOperations);
}
Also used : ModelElement(org.wildfly.extension.picketlink.common.model.ModelElement) XMLStreamException(javax.xml.stream.XMLStreamException) ModelNode(org.jboss.dmr.ModelNode) XMLExtendedStreamReader(org.jboss.staxmapper.XMLExtendedStreamReader)

Example 2 with ModelElement

use of org.wildfly.extension.picketlink.common.model.ModelElement in project wildfly by wildfly.

the class AbstractIDMSubsystemReader method parseElement.

protected void parseElement(final ElementParser parser, ModelElement parentElement, final ModelNode parentNode, final XMLExtendedStreamReader reader, final List<ModelNode> addOperations) throws XMLStreamException {
    while (reader.hasNext() && reader.nextTag() != END_DOCUMENT) {
        if (!reader.isStartElement()) {
            if (reader.isEndElement() && reader.getLocalName().equals(parentElement.getName())) {
                break;
            }
            continue;
        }
        if (reader.getLocalName().equals(parentElement.getName())) {
            continue;
        }
        ModelElement element = ModelElement.forName(reader.getLocalName());
        if (element == null) {
            if (XMLElement.forName(reader.getLocalName()) != null) {
                continue;
            }
            throw unexpectedElement(reader);
        }
        parser.parse(reader, element, parentNode, addOperations);
    }
}
Also used : ModelElement(org.wildfly.extension.picketlink.common.model.ModelElement)

Example 3 with ModelElement

use of org.wildfly.extension.picketlink.common.model.ModelElement in project wildfly by wildfly.

the class AbstractIDMSubsystemReader method parseIdentityManagementConfig.

private void parseIdentityManagementConfig(final XMLExtendedStreamReader reader, final ModelNode parentNode, final List<ModelNode> addOperations) throws XMLStreamException {
    ModelNode identityManagementNode = parseConfig(reader, PARTITION_MANAGER, COMMON_NAME.getName(), parentNode, PartitionManagerResourceDefinition.INSTANCE.getAttributes(), addOperations);
    parseElement(new ElementParser() {

        @Override
        public void parse(final XMLExtendedStreamReader reader, final ModelElement element, final ModelNode parentNode, List<ModelNode> addOperations) throws XMLStreamException {
            switch(element) {
                case IDENTITY_CONFIGURATION:
                    parseIdentityConfigurationConfig(reader, parentNode, addOperations);
                    break;
            }
        }
    }, PARTITION_MANAGER, identityManagementNode, reader, addOperations);
}
Also used : ModelElement(org.wildfly.extension.picketlink.common.model.ModelElement) XMLStreamException(javax.xml.stream.XMLStreamException) ModelNode(org.jboss.dmr.ModelNode) XMLExtendedStreamReader(org.jboss.staxmapper.XMLExtendedStreamReader)

Example 4 with ModelElement

use of org.wildfly.extension.picketlink.common.model.ModelElement in project wildfly by wildfly.

the class IDMSubsystemReader_1_0 method parseLDAPMappingConfig.

@Override
protected void parseLDAPMappingConfig(final XMLExtendedStreamReader reader, final ModelNode identityProviderNode, final List<ModelNode> addOperations) throws XMLStreamException {
    String name = reader.getAttributeValue("", COMMON_CLASS_NAME.getName());
    if (name == null) {
        name = reader.getAttributeValue("", COMMON_CODE.getName());
        if (name != null) {
            name = AttributedTypeEnum.forType(name);
        }
    }
    ModelNode ldapMappingConfig = parseConfig(reader, LDAP_STORE_MAPPING, name, identityProviderNode, LDAPStoreMappingResourceDefinition.INSTANCE.getAttributes(), addOperations);
    parseElement(new ElementParser() {

        @Override
        public void parse(final XMLExtendedStreamReader reader, final ModelElement element, final ModelNode parentNode, List<ModelNode> addOperations) throws XMLStreamException {
            switch(element) {
                case LDAP_STORE_ATTRIBUTE:
                    parseConfig(reader, LDAP_STORE_ATTRIBUTE, LDAPStoreAttributeResourceDefinition.NAME.getName(), parentNode, LDAPStoreAttributeResourceDefinition.INSTANCE.getAttributes(), addOperations);
                    break;
            }
        }
    }, LDAP_STORE_MAPPING, ldapMappingConfig, reader, addOperations);
}
Also used : ModelElement(org.wildfly.extension.picketlink.common.model.ModelElement) XMLStreamException(javax.xml.stream.XMLStreamException) ModelNode(org.jboss.dmr.ModelNode) XMLExtendedStreamReader(org.jboss.staxmapper.XMLExtendedStreamReader)

Example 5 with ModelElement

use of org.wildfly.extension.picketlink.common.model.ModelElement in project wildfly by wildfly.

the class AbstractFederationSubsystemReader method parseElement.

protected void parseElement(final ElementParser parser, ModelElement parentElement, final ModelNode parentNode, final XMLExtendedStreamReader reader, final List<ModelNode> addOperations) throws XMLStreamException {
    Set<String> visited = new HashSet<>();
    while (reader.hasNext() && reader.nextTag() != END_DOCUMENT) {
        String tagName = reader.getLocalName();
        if (!reader.isStartElement()) {
            if (reader.isEndElement() && tagName.equals(parentElement.getName())) {
                break;
            }
            continue;
        }
        if (!tagName.equals(parentElement.getName())) {
            ModelElement element = ModelElement.forName(tagName);
            if (element != null) {
                parser.parse(reader, element, parentNode, addOperations);
            } else {
                if (XMLElement.forName(tagName) != null) {
                    if (visited.contains(tagName)) {
                        throw duplicateNamedElement(reader, tagName);
                    }
                } else {
                    throw unexpectedElement(reader);
                }
            }
        }
        visited.add(tagName);
    }
}
Also used : ModelElement(org.wildfly.extension.picketlink.common.model.ModelElement) HashSet(java.util.HashSet)

Aggregations

ModelElement (org.wildfly.extension.picketlink.common.model.ModelElement)17 XMLStreamException (javax.xml.stream.XMLStreamException)15 ModelNode (org.jboss.dmr.ModelNode)15 XMLExtendedStreamReader (org.jboss.staxmapper.XMLExtendedStreamReader)15 HashSet (java.util.HashSet)1