Search in sources :

Example 81 with PathElement

use of org.jboss.as.controller.PathElement in project wildfly by wildfly.

the class ExpressionSupportSmokeTestCase method isAttributeExcluded.

private boolean isAttributeExcluded(PathAddress address, String attrName, ModelNode attrDesc, ModelNode resourceNoDefaults) {
    if (!attrDesc.get(ACCESS_TYPE).isDefined() || !attrDesc.get(ACCESS_TYPE).asString().equalsIgnoreCase("read-write")) {
        return true;
    }
    if (attrDesc.get(STORAGE).isDefined() && !attrDesc.get(STORAGE).asString().equalsIgnoreCase("configuration")) {
        return true;
    }
    if (attrDesc.get(ModelDescriptionConstants.DEPRECATED).isDefined()) {
        return true;
    }
    // Special cases
    if ("default-web-module".equals(attrName)) {
        if (address.size() > 1) {
            PathElement subPe = address.getElement(address.size() - 2);
            if ("subsystem".equals(subPe.getKey()) && "web".equals(subPe.getValue()) && "virtual-server".equals(address.getLastElement().getKey())) {
                // so skip it
                return true;
            }
        }
    } else if ("policy-modules".equals(attrName) || "login-modules".equals(attrName)) {
        if (address.size() > 2) {
            PathElement subPe = address.getElement(address.size() - 3);
            if ("subsystem".equals(subPe.getKey()) && "security".equals(subPe.getValue()) && "security-domain".equals(address.getElement(address.size() - 2).getKey())) {
                // we could exclude all deprecated attributes, but for now I'd rather be specific
                return true;
            }
        }
    } else if ("virtual-nodes".equals(attrName)) {
        if (address.size() > 3) {
            PathElement subPe = address.getElement(address.size() - 3);
            PathElement containerPe = address.getElement(address.size() - 2);
            PathElement distPe = address.getElement(address.size() - 1);
            if ("subsystem".equals(subPe.getKey()) && "infinispan".equals(subPe.getValue()) && "cache-container".equals(containerPe.getKey()) && "distributed-cache".equals(distPe.getKey())) {
                // This is a distributed cache attribute in Infinispan which has been deprecated
                return true;
            }
        }
    } else if (address.size() > 0 && "transactions".equals(address.getLastElement().getValue()) && "subsystem".equals(address.getLastElement().getKey())) {
        if (attrName.contains("jdbc")) {
            // Ignore jdbc store attributes unless jdbc store is enabled
            return !resourceNoDefaults.hasDefined("use-jdbc-store") || !resourceNoDefaults.get("use-jdbc-store").asBoolean();
        } else if (attrName.contains("journal")) {
            // Ignore journal store attributes unless journal store is enabled
            return !resourceNoDefaults.hasDefined("use-journal-store") || !resourceNoDefaults.get("use-journal-store").asBoolean();
        }
    }
    return false;
}
Also used : PathElement(org.jboss.as.controller.PathElement)

Example 82 with PathElement

use of org.jboss.as.controller.PathElement in project wildfly by wildfly.

the class SecuritySubsystemParser method parseSecurityDomain.

private void parseSecurityDomain(List<ModelNode> list, XMLExtendedStreamReader reader, PathAddress parentAddress) throws XMLStreamException {
    ModelNode op = Util.createAddOperation();
    list.add(op);
    PathElement secDomainPath = null;
    EnumSet<Attribute> required = EnumSet.of(Attribute.NAME);
    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        requireNoNamespaceAttribute(reader, i);
        final String value = reader.getAttributeValue(i);
        final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
        required.remove(attribute);
        switch(attribute) {
            case NAME:
                {
                    if (value == null || value.length() == 0) {
                        throw invalidAttributeValue(reader, i);
                    }
                    secDomainPath = PathElement.pathElement(SECURITY_DOMAIN, value);
                    break;
                }
            case CACHE_TYPE:
                {
                    SecurityDomainResourceDefinition.CACHE_TYPE.parseAndSetParameter(value, op, reader);
                    break;
                }
            default:
                throw unexpectedAttribute(reader, i);
        }
    }
    if (!required.isEmpty()) {
        throw missingRequired(reader, required);
    }
    final PathAddress address = parentAddress.append(secDomainPath);
    op.get(OP_ADDR).set(address.toModelNode());
    final EnumSet<Element> visited = EnumSet.noneOf(Element.class);
    moduleNames = new HashMap<String, Integer>();
    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
        final Element element = Element.forName(reader.getLocalName());
        if (!visited.add(element)) {
            throw unexpectedElement(reader);
        }
        switch(element) {
            case AUTHENTICATION:
                {
                    if (visited.contains(Element.AUTHENTICATION_JASPI)) {
                        throw SecurityLogger.ROOT_LOGGER.xmlStreamExceptionAuth(reader.getLocation());
                    }
                    parseAuthentication(list, address, reader);
                    break;
                }
            case AUTHORIZATION:
                {
                    parseAuthorization(list, address, reader);
                    break;
                }
            case ACL:
                {
                    parseACL(list, address, reader);
                    break;
                }
            case AUDIT:
                {
                    parseAudit(list, address, reader);
                    break;
                }
            case IDENTITY_TRUST:
                {
                    parseIdentityTrust(list, address, reader);
                    break;
                }
            case MAPPING:
                {
                    parseMapping(list, address, reader);
                    break;
                }
            case AUTHENTICATION_JASPI:
                {
                    if (visited.contains(Element.AUTHENTICATION)) {
                        throw SecurityLogger.ROOT_LOGGER.xmlStreamExceptionAuth(reader.getLocation());
                    }
                    parseAuthenticationJaspi(list, address, reader);
                    break;
                }
            case JSSE:
                {
                    parseJSSE(list, address, reader);
                    break;
                }
            default:
                {
                    throw unexpectedElement(reader);
                }
        }
    }
    moduleNames.clear();
}
Also used : PathElement(org.jboss.as.controller.PathElement) ParseUtils.requireNoNamespaceAttribute(org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute) ParseUtils.unexpectedAttribute(org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute) PathAddress(org.jboss.as.controller.PathAddress) PathElement(org.jboss.as.controller.PathElement) ParseUtils.unexpectedElement(org.jboss.as.controller.parsing.ParseUtils.unexpectedElement) ModelNode(org.jboss.dmr.ModelNode)

Example 83 with PathElement

use of org.jboss.as.controller.PathElement in project wildfly by wildfly.

the class ACLResourceDefinition method registerChildren.

@Override
public void registerChildren(ManagementResourceRegistration resourceRegistration) {
    super.registerChildren(resourceRegistration);
    ManagementResourceRegistration moduleReg = resourceRegistration.registerSubModel(new LoginModuleResourceDefinition(Constants.ACL_MODULE));
    // https://issues.jboss.org/browse/WFLY-2474 acl-module was wrongly called login-module in 7.2.0
    resourceRegistration.registerAlias(PathElement.pathElement(Constants.LOGIN_MODULE), new AliasEntry(moduleReg) {

        @Override
        public PathAddress convertToTargetAddress(PathAddress address, AliasContext aliasContext) {
            PathElement element = address.getLastElement();
            element = PathElement.pathElement(Constants.ACL_MODULE, element.getValue());
            return address.subAddress(0, address.size() - 1).append(element);
        }
    });
}
Also used : PathElement(org.jboss.as.controller.PathElement) PathAddress(org.jboss.as.controller.PathAddress) ManagementResourceRegistration(org.jboss.as.controller.registry.ManagementResourceRegistration) AliasEntry(org.jboss.as.controller.registry.AliasEntry)

Example 84 with PathElement

use of org.jboss.as.controller.PathElement in project eap-additional-testsuite by jboss-set.

the class ExpressionSupportSmokeTestCase method isAttributeExcluded.

private boolean isAttributeExcluded(PathAddress address, String attrName, ModelNode attrDesc, ModelNode resourceNoDefaults) {
    if (!attrDesc.get(ACCESS_TYPE).isDefined() || !attrDesc.get(ACCESS_TYPE).asString().equalsIgnoreCase("read-write")) {
        return true;
    }
    if (attrDesc.get(STORAGE).isDefined() && !attrDesc.get(STORAGE).asString().equalsIgnoreCase("configuration")) {
        return true;
    }
    if (attrDesc.get(ModelDescriptionConstants.DEPRECATED).isDefined()) {
        return true;
    }
    // Special cases
    if ("default-web-module".equals(attrName)) {
        if (address.size() > 1) {
            PathElement subPe = address.getElement(address.size() - 2);
            if ("subsystem".equals(subPe.getKey()) && "web".equals(subPe.getValue()) && "virtual-server".equals(address.getLastElement().getKey())) {
                // so skip it
                return true;
            }
        }
    } else if ("policy-modules".equals(attrName) || "login-modules".equals(attrName)) {
        if (address.size() > 2) {
            PathElement subPe = address.getElement(address.size() - 3);
            if ("subsystem".equals(subPe.getKey()) && "security".equals(subPe.getValue()) && "security-domain".equals(address.getElement(address.size() - 2).getKey())) {
                // we could exclude all deprecated attributes, but for now I'd rather be specific
                return true;
            }
        }
    } else if ("virtual-nodes".equals(attrName)) {
        if (address.size() > 3) {
            PathElement subPe = address.getElement(address.size() - 3);
            PathElement containerPe = address.getElement(address.size() - 2);
            PathElement distPe = address.getElement(address.size() - 1);
            if ("subsystem".equals(subPe.getKey()) && "infinispan".equals(subPe.getValue()) && "cache-container".equals(containerPe.getKey()) && "distributed-cache".equals(distPe.getKey())) {
                // This is a distributed cache attribute in Infinispan which has been deprecated
                return true;
            }
        }
    } else if (address.size() > 0 && "transactions".equals(address.getLastElement().getValue()) && "subsystem".equals(address.getLastElement().getKey())) {
        if (attrName.contains("jdbc")) {
            // Ignore jdbc store attributes unless jdbc store is enabled
            return !resourceNoDefaults.hasDefined("use-jdbc-store") || !resourceNoDefaults.get("use-jdbc-store").asBoolean();
        } else if (attrName.contains("journal")) {
            // Ignore journal store attributes unless journal store is enabled
            return !resourceNoDefaults.hasDefined("use-journal-store") || !resourceNoDefaults.get("use-journal-store").asBoolean();
        }
    }
    return false;
}
Also used : PathElement(org.jboss.as.controller.PathElement)

Aggregations

PathElement (org.jboss.as.controller.PathElement)84 PathAddress (org.jboss.as.controller.PathAddress)47 ModelNode (org.jboss.dmr.ModelNode)46 Resource (org.jboss.as.controller.registry.Resource)24 OperationFailedException (org.jboss.as.controller.OperationFailedException)12 ServiceName (org.jboss.msc.service.ServiceName)12 Test (org.junit.Test)10 Map (java.util.Map)9 ArrayList (java.util.ArrayList)8 OperationStepHandler (org.jboss.as.controller.OperationStepHandler)8 ParseUtils.requireNoNamespaceAttribute (org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute)7 ParseUtils.unexpectedAttribute (org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute)7 ManagementResourceRegistration (org.jboss.as.controller.registry.ManagementResourceRegistration)7 DeploymentResourceSupport (org.jboss.as.server.deployment.DeploymentResourceSupport)7 AbstractSubsystemBaseTest (org.jboss.as.subsystem.test.AbstractSubsystemBaseTest)7 ServiceTarget (org.jboss.msc.service.ServiceTarget)6 StatisticsResourceDefinition (org.jboss.as.connector.dynamicresource.StatisticsResourceDefinition)4 AttributeDefinition (org.jboss.as.controller.AttributeDefinition)4 OperationContext (org.jboss.as.controller.OperationContext)4 StandardResourceDescriptionResolver (org.jboss.as.controller.descriptions.StandardResourceDescriptionResolver)4