static void writeSSL(XMLExtendedStreamWriter writer, ModelNode sslConfig)
     throws XMLStreamException {
   writer.writeStartElement(Element.SSL.getLocalName());
   writeAttribute(writer, Attribute.KEY_ALIAS.getLocalName(), sslConfig);
   writeAttribute(writer, Attribute.PASSWORD.getLocalName(), sslConfig);
   writeAttribute(writer, Attribute.CERTIFICATE_KEY_FILE.getLocalName(), sslConfig);
   writeAttribute(writer, Attribute.CIPHER_SUITE.getLocalName(), sslConfig);
   writeAttribute(writer, Attribute.PROTOCOL.getLocalName(), sslConfig);
   writeAttribute(writer, Attribute.CA_CERTIFICATE_FILE.getLocalName(), sslConfig);
   writeAttribute(writer, Attribute.CA_REVOCATION_URL.getLocalName(), sslConfig);
   writer.writeEndElement();
 }
Exemplo n.º 2
0
  /** {@inheritDoc} */
  @Override
  public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context)
      throws XMLStreamException {

    context.startSubsystemElement(Namespace.CURRENT.getUriString(), false);

    ModelNode node = context.getModelNode();

    writeAttribute(writer, Attribute.NATIVE.getLocalName(), node);
    writeAttribute(writer, Attribute.DEFAULT_VIRTUAL_SERVER.getLocalName(), node);
    writeAttribute(writer, Attribute.INSTANCE_ID.getLocalName(), node);
    if (node.hasDefined(CONTAINER_CONFIG)) {
      writeContainerConfig(writer, node.get(CONTAINER_CONFIG));
    }
    if (node.hasDefined(CONNECTOR)) {
      for (final Property connector : node.get(CONNECTOR).asPropertyList()) {
        final ModelNode config = connector.getValue();
        writer.writeStartElement(Element.CONNECTOR.getLocalName());
        writer.writeAttribute(NAME, connector.getName());
        writeAttribute(writer, Attribute.PROTOCOL.getLocalName(), config);
        writeAttribute(writer, Attribute.SOCKET_BINDING.getLocalName(), config);
        writeAttribute(writer, Attribute.SCHEME.getLocalName(), config);
        writeAttribute(writer, Attribute.ENABLED.getLocalName(), config);
        writeAttribute(writer, Attribute.ENABLE_LOOKUPS.getLocalName(), config);
        writeAttribute(writer, Attribute.PROXY_NAME.getLocalName(), config);
        writeAttribute(writer, Attribute.PROXY_PORT.getLocalName(), config);
        writeAttribute(writer, Attribute.SECURE.getLocalName(), config);
        writeAttribute(writer, Attribute.EXECUTOR.getLocalName(), config);
        writeAttribute(writer, Attribute.MAX_POST_SIZE.getLocalName(), config);
        writeAttribute(writer, Attribute.MAX_SAVE_POST_SIZE.getLocalName(), config);
        writeAttribute(writer, Attribute.MAX_CONNECTIONS.getLocalName(), config);
        writeAttribute(writer, Attribute.REDIRECT_PORT.getLocalName(), config);

        if (config.get(SSL).isDefined() && config.get(SSL).has("configuration")) {
          ModelNode sslConfig = config.get(SSL).get("configuration");
          writer.writeStartElement(Element.SSL.getLocalName());
          writeAttribute(writer, Attribute.NAME.getLocalName(), sslConfig);
          writeAttribute(writer, Attribute.KEY_ALIAS.getLocalName(), sslConfig);
          writeAttribute(writer, Attribute.PASSWORD.getLocalName(), sslConfig);
          writeAttribute(writer, Attribute.CERTIFICATE_KEY_FILE.getLocalName(), sslConfig);
          writeAttribute(writer, Attribute.CIPHER_SUITE.getLocalName(), sslConfig);
          writeAttribute(writer, Attribute.PROTOCOL.getLocalName(), sslConfig);
          writeAttribute(writer, Attribute.VERIFY_CLIENT.getLocalName(), sslConfig);
          writeAttribute(writer, Attribute.VERIFY_DEPTH.getLocalName(), sslConfig);
          writeAttribute(writer, Attribute.CERTIFICATE_FILE.getLocalName(), sslConfig);
          writeAttribute(writer, Attribute.CA_CERTIFICATE_FILE.getLocalName(), sslConfig);
          writeAttribute(writer, Attribute.CA_REVOCATION_URL.getLocalName(), sslConfig);
          writeAttribute(writer, Attribute.SESSION_CACHE_SIZE.getLocalName(), sslConfig);
          writeAttribute(writer, Attribute.SESSION_TIMEOUT.getLocalName(), sslConfig);
          writer.writeEndElement();
        }
        if (config.hasDefined(VIRTUAL_SERVER)) {
          for (final ModelNode virtualServer : config.get(VIRTUAL_SERVER).asList()) {
            writer.writeEmptyElement(VIRTUAL_SERVER);
            writer.writeAttribute(NAME, virtualServer.asString());
          }
        }

        writer.writeEndElement();
      }
    }
    if (node.hasDefined(VIRTUAL_SERVER)) {
      for (final Property host : node.get(VIRTUAL_SERVER).asPropertyList()) {
        final ModelNode config = host.getValue();
        writer.writeStartElement(Element.VIRTUAL_SERVER.getLocalName());
        writer.writeAttribute(NAME, host.getName());
        writeAttribute(writer, Attribute.DEFAULT_WEB_MODULE.getLocalName(), config);
        if (config.hasDefined(ENABLE_WELCOME_ROOT) && config.get(ENABLE_WELCOME_ROOT).asBoolean())
          writer.writeAttribute(ENABLE_WELCOME_ROOT, "true");

        if (config.hasDefined(ALIAS)) {
          for (final ModelNode alias : config.get(ALIAS).asList()) {
            writer.writeEmptyElement(ALIAS);
            writer.writeAttribute(NAME, alias.asString());
          }
        }

        if (config.get(ACCESS_LOG).isDefined() && config.get(ACCESS_LOG).has("configuration")) {
          ModelNode accessLog = config.get(ACCESS_LOG).get("configuration");
          writer.writeStartElement(Element.ACCESS_LOG.getLocalName());
          writeAttribute(writer, Attribute.PATTERN.getLocalName(), accessLog);
          writeAttribute(writer, Attribute.RESOLVE_HOSTS.getLocalName(), accessLog);
          writeAttribute(writer, Attribute.EXTENDED.getLocalName(), accessLog);
          writeAttribute(writer, Attribute.PREFIX.getLocalName(), accessLog);
          writeAttribute(writer, Attribute.ROTATE.getLocalName(), accessLog);

          if (accessLog.has(DIRECTORY) && accessLog.get(DIRECTORY).has("configuration")) {
            ModelNode directory = accessLog.get(DIRECTORY).get("configuration");
            String name = Element.DIRECTORY.getLocalName();
            boolean startwritten = false;
            startwritten =
                writeAttribute(
                    writer, Attribute.PATH.getLocalName(), directory, startwritten, name);
            startwritten =
                writeAttribute(
                    writer, Attribute.RELATIVE_TO.getLocalName(), directory, startwritten, name);
            if (startwritten) writer.writeEndElement();
          }
          writer.writeEndElement();
        }

        if (config.hasDefined(REWRITE)) {
          for (final ModelNode rewritenode : config.get(REWRITE).asList()) {
            String name = getAddedRule(rewritenode);
            ModelNode rewrite;
            if (rewritenode.hasDefined(name)) rewrite = rewritenode.get(name);
            else rewrite = rewritenode;
            writer.writeStartElement(REWRITE);
            writeAttribute(writer, Attribute.PATTERN.getLocalName(), rewrite);
            writeAttribute(writer, Attribute.SUBSTITUTION.getLocalName(), rewrite);
            writeAttribute(writer, Attribute.FLAGS.getLocalName(), rewrite);

            if (rewrite.hasDefined(CONDITION)) {
              for (final ModelNode conditionnode : rewrite.get(CONDITION).asList()) {
                String condname = getAddedConditionName(conditionnode);
                ModelNode condition;
                if (conditionnode.hasDefined(condname)) condition = conditionnode.get(condname);
                else condition = conditionnode;
                writer.writeStartElement(CONDITION);
                writeAttribute(writer, Attribute.TEST.getLocalName(), condition);
                writeAttribute(writer, Attribute.PATTERN.getLocalName(), condition);
                writeAttribute(writer, Attribute.FLAGS.getLocalName(), condition);
                writer.writeEndElement();
              }
            }
            writer.writeEndElement();
          }
        }

        if (config.hasDefined(SSO) && config.get(SSO).has("configuration")) {
          final ModelNode sso;
          sso = config.get(SSO).get("configuration");
          writer.writeStartElement(SSO);
          writeAttribute(writer, Attribute.CACHE_CONTAINER.getLocalName(), sso);
          writeAttribute(writer, Attribute.CACHE_NAME.getLocalName(), sso);
          writeAttribute(writer, Attribute.DOMAIN.getLocalName(), sso);
          writeAttribute(writer, Attribute.REAUTHENTICATE.getLocalName(), sso);
          writer.writeEndElement();
        }

        // End of the VIRTUAL_SERVER
        writer.writeEndElement();
      }
    }
    writer.writeEndElement();
  }