Search in sources :

Example 51 with Property

use of org.jboss.dmr.Property in project wildfly by wildfly.

the class SecuritySubsystemPersister method writeLoginModuleStack.

private void writeLoginModuleStack(XMLExtendedStreamWriter writer, ModelNode modelNode) throws XMLStreamException {
    if (modelNode.isDefined() && modelNode.asInt() > 0) {
        List<Property> stacks = modelNode.asPropertyList();
        for (Property stack : stacks) {
            writer.writeStartElement(Element.LOGIN_MODULE_STACK.getLocalName());
            writer.writeAttribute(Attribute.NAME.getLocalName(), stack.getName());
            writeLoginModule(writer, stack.getValue(), Constants.LOGIN_MODULE);
            writer.writeEndElement();
        }
    }
}
Also used : Property(org.jboss.dmr.Property)

Example 52 with Property

use of org.jboss.dmr.Property in project wildfly by wildfly.

the class SecuritySubsystemPersister method writeContent.

@Override
public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context) throws XMLStreamException {
    context.startSubsystemElement(Namespace.CURRENT.getUriString(), false);
    ModelNode node = context.getModelNode();
    if (SecuritySubsystemRootResourceDefinition.DEEP_COPY_SUBJECT_MODE.isMarshallable(node) || SecuritySubsystemRootResourceDefinition.INITIALIZE_JACC.isMarshallable(node)) {
        writer.writeEmptyElement(Element.SECURITY_MANAGEMENT.getLocalName());
        if (SecuritySubsystemRootResourceDefinition.DEEP_COPY_SUBJECT_MODE.isMarshallable(node)) {
            SecuritySubsystemRootResourceDefinition.DEEP_COPY_SUBJECT_MODE.marshallAsAttribute(node, writer);
        }
        if (SecuritySubsystemRootResourceDefinition.INITIALIZE_JACC.isMarshallable(node)) {
            SecuritySubsystemRootResourceDefinition.INITIALIZE_JACC.marshallAsAttribute(node, writer);
        }
    }
    if (node.hasDefined(SECURITY_DOMAIN) && node.get(SECURITY_DOMAIN).asInt() > 0) {
        writer.writeStartElement(Element.SECURITY_DOMAINS.getLocalName());
        ModelNode securityDomains = node.get(SECURITY_DOMAIN);
        for (String policy : securityDomains.keys()) {
            writer.writeStartElement(Element.SECURITY_DOMAIN.getLocalName());
            writer.writeAttribute(Attribute.NAME.getLocalName(), policy);
            ModelNode policyDetails = securityDomains.get(policy);
            SecurityDomainResourceDefinition.CACHE_TYPE.marshallAsAttribute(policyDetails, writer);
            writeSecurityDomainContent(writer, policyDetails);
            writer.writeEndElement();
        }
        writer.writeEndElement();
    }
    if (node.hasDefined(Constants.VAULT)) {
        ModelNode vault = node.get(Constants.VAULT, Constants.CLASSIC);
        writer.writeStartElement(Element.VAULT.getLocalName());
        VaultResourceDefinition.CODE.marshallAsAttribute(vault, writer);
        if (vault.hasDefined(Constants.VAULT_OPTIONS)) {
            ModelNode properties = vault.get(Constants.VAULT_OPTIONS);
            for (Property prop : properties.asPropertyList()) {
                writer.writeEmptyElement(Element.VAULT_OPTION.getLocalName());
                writer.writeAttribute(Attribute.NAME.getLocalName(), prop.getName());
                writer.writeAttribute(Attribute.VALUE.getLocalName(), prop.getValue().asString());
            }
        }
        writer.writeEndElement();
    }
    writeElytronIntegration(writer, node);
    writer.writeEndElement();
}
Also used : ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property)

Example 53 with Property

use of org.jboss.dmr.Property in project wildfly by wildfly.

the class LoggingDeploymentResourceTestCase method testEarDeploymentConfigurationResource.

@OperateOnDeployment(EAR_DEPLOYMENT_NAME)
@Test
public void testEarDeploymentConfigurationResource() throws Exception {
    ModelNode loggingConfiguration = readDeploymentResource(EAR_DEPLOYMENT_NAME, EAR_DEPLOYMENT_NAME + "/META-INF/logging.properties");
    // The address should have logging.properties
    Deque<Property> resultAddress = new ArrayDeque<>(Operations.getOperationAddress(loggingConfiguration).asPropertyList());
    Assert.assertTrue("The configuration path did not include logging.properties", resultAddress.getLast().getValue().asString().contains("logging.properties"));
    ModelNode handler = loggingConfiguration.get("handler", "FILE");
    Assert.assertTrue("The FILE handler was not found effective configuration", handler.isDefined());
    Assert.assertTrue(handler.hasDefined("properties"));
    String fileName = null;
    // Find the fileName property
    for (Property property : handler.get("properties").asPropertyList()) {
        if ("fileName".equals(property.getName())) {
            fileName = property.getValue().asString();
            break;
        }
    }
    Assert.assertNotNull("fileName property not found", fileName);
    Assert.assertTrue(fileName.endsWith("test-logging-ear.log"));
    // Check the WAR which should inherit the EAR's logging.properties
    loggingConfiguration = readSubDeploymentResource(EAR_DEPLOYMENT_NAME, EAR_WAR_DEPLOYMENT_NAME, EAR_DEPLOYMENT_NAME + "/META-INF/logging.properties");
    // The address should have logging.properties
    resultAddress = new ArrayDeque<>(Operations.getOperationAddress(loggingConfiguration).asPropertyList());
    Assert.assertTrue("The configuration path did not include logging.properties", resultAddress.getLast().getValue().asString().contains("logging.properties"));
    handler = loggingConfiguration.get("handler", "FILE");
    Assert.assertTrue("The FILE handler was not found effective configuration", handler.isDefined());
    Assert.assertTrue(handler.hasDefined("properties"));
    fileName = null;
    // Find the fileName property
    for (Property property : handler.get("properties").asPropertyList()) {
        if ("fileName".equals(property.getName())) {
            fileName = property.getValue().asString();
            break;
        }
    }
    Assert.assertNotNull("fileName property not found", fileName);
    Assert.assertTrue(fileName.endsWith("test-logging-ear.log"));
}
Also used : ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property) ArrayDeque(java.util.ArrayDeque) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) Test(org.junit.Test)

Example 54 with Property

use of org.jboss.dmr.Property in project wildfly by wildfly.

the class EJB3SubsystemXMLPersister method writeFilePassivationStores.

/**
 * Persist as a passivation-store using relevant attributes
 */
private void writeFilePassivationStores(XMLExtendedStreamWriter writer, ModelNode model) throws XMLStreamException {
    if (model.hasDefined(EJB3SubsystemModel.FILE_PASSIVATION_STORE)) {
        List<Property> caches = model.get(EJB3SubsystemModel.FILE_PASSIVATION_STORE).asPropertyList();
        for (Property property : caches) {
            // <strict-max-pool>
            writer.writeStartElement(EJB3SubsystemXMLElement.FILE_PASSIVATION_STORE.getLocalName());
            ModelNode store = property.getValue();
            writer.writeAttribute(EJB3SubsystemXMLAttribute.NAME.getLocalName(), property.getName());
            LegacyPassivationStoreResourceDefinition.IDLE_TIMEOUT.marshallAsAttribute(store, writer);
            LegacyPassivationStoreResourceDefinition.IDLE_TIMEOUT_UNIT.marshallAsAttribute(store, writer);
            FilePassivationStoreResourceDefinition.MAX_SIZE.marshallAsAttribute(store, writer);
            FilePassivationStoreResourceDefinition.RELATIVE_TO.marshallAsAttribute(store, writer);
            FilePassivationStoreResourceDefinition.GROUPS_PATH.marshallAsAttribute(store, writer);
            FilePassivationStoreResourceDefinition.SESSIONS_PATH.marshallAsAttribute(store, writer);
            FilePassivationStoreResourceDefinition.SUBDIRECTORY_COUNT.marshallAsAttribute(store, writer);
            writer.writeEndElement();
        }
    }
}
Also used : ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property)

Example 55 with Property

use of org.jboss.dmr.Property in project wildfly by wildfly.

the class EJB3SubsystemXMLPersister method writeRemoteHttpConnection.

private void writeRemoteHttpConnection(final XMLExtendedStreamWriter writer, final ModelNode profileNode) throws XMLStreamException {
    final List<Property> connections = profileNode.get(REMOTE_HTTP_CONNECTION).asPropertyList();
    for (final Property property : connections) {
        writer.writeStartElement(REMOTE_HTTP_CONNECTION);
        writer.writeAttribute(EJB3SubsystemXMLAttribute.NAME.getLocalName(), property.getName());
        final ModelNode connectionNode = property.getValue();
        RemoteHttpConnectionDefinition.URI.marshallAsAttribute(connectionNode, writer);
        writer.writeEndElement();
    }
}
Also used : ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property)

Aggregations

Property (org.jboss.dmr.Property)179 ModelNode (org.jboss.dmr.ModelNode)144 HashMap (java.util.HashMap)19 Test (org.junit.Test)19 AttributeDefinition (org.jboss.as.controller.AttributeDefinition)12 PathAddress (org.jboss.as.controller.PathAddress)11 ArrayList (java.util.ArrayList)10 ValueExpression (org.jboss.dmr.ValueExpression)10 ModelType (org.jboss.dmr.ModelType)9 Map (java.util.Map)8 HashSet (java.util.HashSet)7 ArrayDeque (java.util.ArrayDeque)6 OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)6 OperationFailedException (org.jboss.as.controller.OperationFailedException)6 SimpleAttributeDefinition (org.jboss.as.controller.SimpleAttributeDefinition)6 Properties (java.util.Properties)5 LoginModuleControlFlag (javax.security.auth.login.AppConfigurationEntry.LoginModuleControlFlag)4 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)4 HttpResponse (org.apache.http.HttpResponse)3 HttpGet (org.apache.http.client.methods.HttpGet)3