Java Code Examples for org.jboss.staxmapper.XMLExtendedStreamWriter#writeEndElement()

The following examples show how to use org.jboss.staxmapper.XMLExtendedStreamWriter#writeEndElement() . 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
Source File: ManagementXml_5.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void writeLdapCacheIfDefined(XMLExtendedStreamWriter writer, ModelNode parent) throws XMLStreamException {
    if (parent.hasDefined(CACHE)) {
        ModelNode cacheHolder = parent.require(CACHE);
        final ModelNode cache;
        final String type;

        if (cacheHolder.hasDefined(BY_ACCESS_TIME)) {
            cache = cacheHolder.require(BY_ACCESS_TIME);
            type = BY_ACCESS_TIME;
        } else if (cacheHolder.hasDefined(BY_SEARCH_TIME)) {
            cache = cacheHolder.require(BY_SEARCH_TIME);
            type = BY_SEARCH_TIME;
        } else {
            return;
        }

        writer.writeStartElement(Element.CACHE.getLocalName());
        if (type.equals(BY_SEARCH_TIME) == false) {
            writer.writeAttribute(Attribute.TYPE.getLocalName(), type);
        }
        LdapCacheResourceDefinition.EVICTION_TIME.marshallAsAttribute(cache, writer);
        LdapCacheResourceDefinition.CACHE_FAILURES.marshallAsAttribute(cache, writer);
        LdapCacheResourceDefinition.MAX_CACHE_SIZE.marshallAsAttribute(cache, writer);
        writer.writeEndElement();
    }
}
 
Example 2
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 6 votes vote down vote up
void writePrincipalNameMapping(XMLExtendedStreamWriter writer, ModelNode model) throws XMLStreamException {

        ModelNode policy = model.get(Constants.Model.PRINCIPAL_NAME_MAPPING_POLICY);
        ModelNode mappingAttribute = model.get(Constants.Model.PRINCIPAL_NAME_MAPPING_ATTRIBUTE_NAME);
        if (!policy.isDefined() && !mappingAttribute.isDefined()) {
            return;
        }
        writer.writeStartElement(Constants.XML.PRINCIPAL_NAME_MAPPING);
        if (policy.isDefined()) {
            writer.writeAttribute(Constants.XML.PRINCIPAL_NAME_MAPPING_POLICY, policy.asString());
        }
        if (mappingAttribute.isDefined()) {
            writer.writeAttribute(Constants.XML.PRINCIPAL_NAME_MAPPING_ATTRIBUTE_NAME, mappingAttribute.asString());
        }
        writer.writeEndElement();
    }
 
Example 3
Source File: ThreadsParser.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void writeBoundedQueueThreadPool(final XMLExtendedStreamWriter writer, final Property property, final String elementName,
                                        final boolean includeName, final boolean blocking)
        throws XMLStreamException {
    writer.writeStartElement(elementName);
    ModelNode node = property.getValue();
    if (includeName) {
        writer.writeAttribute(Attribute.NAME.getLocalName(), property.getName());
    }
    PoolAttributeDefinitions.ALLOW_CORE_TIMEOUT.marshallAsAttribute(node, writer);
    writeCountElement(PoolAttributeDefinitions.CORE_THREADS, node, writer);
    writeCountElement(PoolAttributeDefinitions.QUEUE_LENGTH, node, writer);
    writeCountElement(PoolAttributeDefinitions.MAX_THREADS, node, writer);

    writeTime(writer, node, Element.KEEPALIVE_TIME);
    writeRef(writer, node, Element.THREAD_FACTORY, THREAD_FACTORY);
    if (!blocking) {
        writeRef(writer, node, Element.HANDOFF_EXECUTOR, HANDOFF_EXECUTOR);
    }
    writer.writeEndElement();
}
 
Example 4
Source File: LoggingSubsystemWriter.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void writeSocketHandler(final XMLExtendedStreamWriter writer, final ModelNode model, final String name) throws XMLStreamException {
    writer.writeStartElement(Element.SOCKET_HANDLER.getLocalName());
    writer.writeAttribute(HANDLER_NAME.getXmlName(), name);
    AUTOFLUSH.marshallAsAttribute(model, writer);
    SocketHandlerResourceDefinition.BLOCK_ON_RECONNECT.marshallAsAttribute(model, false, writer);
    ENABLED.marshallAsAttribute(model, false, writer);
    SocketHandlerResourceDefinition.OUTBOUND_SOCKET_BINDING_REF.marshallAsAttribute(model, writer);
    SocketHandlerResourceDefinition.SSL_CONTEXT.marshallAsAttribute(model, writer);

    ENCODING.marshallAsElement(model, writer);
    AbstractHandlerDefinition.FILTER_SPEC.marshallAsElement(model, writer);
    LEVEL.marshallAsElement(model, writer);
    SocketHandlerResourceDefinition.NAMED_FORMATTER.marshallAsElement(model, writer);
    SocketHandlerResourceDefinition.PROTOCOL.marshallAsElement(model, writer);

    writer.writeEndElement();
}
 
Example 5
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 6 votes vote down vote up
void writeIdentityProvider(XMLExtendedStreamWriter writer, ModelNode model) throws XMLStreamException {
    if (!model.isDefined()) {
        return;
    }

    for (Property idp : model.asPropertyList()) {
        writer.writeStartElement(Constants.XML.IDENTITY_PROVIDER);
        writer.writeAttribute(Constants.XML.ENTITY_ID, idp.getName());

        ModelNode idpAttributes = idp.getValue();
        for (SimpleAttributeDefinition attr : IdentityProviderDefinition.ATTRIBUTES) {
            attr.getAttributeMarshaller().marshallAsAttribute(attr, idpAttributes, false, writer);
        }

        writeSingleSignOn(writer, idpAttributes.get(Constants.Model.SINGLE_SIGN_ON));
        writeSingleLogout(writer, idpAttributes.get(Constants.Model.SINGLE_LOGOUT));
        writeKeys(writer, idpAttributes.get(Constants.Model.KEY));
        writeHttpClient(writer, idpAttributes.get(Constants.Model.HTTP_CLIENT));
        writeAllowedClockSkew(writer, idpAttributes.get(Constants.Model.ALLOWED_CLOCK_SKEW));
        writer.writeEndElement();
    }
}
 
Example 6
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 5 votes vote down vote up
public void writeSecureDeployment(XMLExtendedStreamWriter writer, ModelNode model) throws XMLStreamException {
    if (!model.get(Constants.Model.SECURE_DEPLOYMENT).isDefined()) {
        return;
    }

    for (Property sp : model.get(Constants.Model.SECURE_DEPLOYMENT).asPropertyList()) {
        writer.writeStartElement(Constants.XML.SECURE_DEPLOYMENT);
        writer.writeAttribute(Constants.XML.NAME, sp.getName());

        writeSps(writer, sp.getValue());
        writer.writeEndElement();
    }
}
 
Example 7
Source File: HostXml_8.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public boolean writeHttpManagementProtocol(XMLExtendedStreamWriter writer, ModelNode protocol) throws XMLStreamException {

    writer.writeStartElement(Element.HTTP_INTERFACE.getLocalName());
    HttpManagementResourceDefinition.HTTP_AUTHENTICATION_FACTORY.marshallAsAttribute(protocol, writer);
    HttpManagementResourceDefinition.SSL_CONTEXT.marshallAsAttribute(protocol, writer);
    HttpManagementResourceDefinition.SECURITY_REALM.marshallAsAttribute(protocol, writer);
    HttpManagementResourceDefinition.CONSOLE_ENABLED.marshallAsAttribute(protocol, writer);
    HttpManagementResourceDefinition.ALLOWED_ORIGINS.getMarshaller().marshallAsAttribute(
            HttpManagementResourceDefinition.ALLOWED_ORIGINS, protocol, true, writer);
    HttpManagementResourceDefinition.SASL_PROTOCOL.marshallAsAttribute(protocol, writer);
    HttpManagementResourceDefinition.SERVER_NAME.marshallAsAttribute(protocol, writer);

    if (HttpManagementResourceDefinition.HTTP_UPGRADE.isMarshallable(protocol)) {
        writer.writeEmptyElement(Element.HTTP_UPGRADE.getLocalName());
        HttpManagementResourceDefinition.ENABLED.marshallAsAttribute(protocol.require(HTTP_UPGRADE), writer);
        HttpManagementResourceDefinition.SASL_AUTHENTICATION_FACTORY.marshallAsAttribute(protocol.require(HTTP_UPGRADE), writer);
    }

    writer.writeEmptyElement(Element.SOCKET.getLocalName());
    HttpManagementResourceDefinition.INTERFACE.marshallAsAttribute(protocol, writer);
    HttpManagementResourceDefinition.HTTP_PORT.marshallAsAttribute(protocol, writer);
    HttpManagementResourceDefinition.HTTPS_PORT.marshallAsAttribute(protocol, writer);
    HttpManagementResourceDefinition.SECURE_INTERFACE.marshallAsAttribute(protocol, writer);

    writer.writeEndElement();

    return true;
}
 
Example 8
Source File: StandaloneXml_7.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public boolean writeHttpManagementProtocol(XMLExtendedStreamWriter writer, ModelNode protocol) throws XMLStreamException {

    writer.writeStartElement(Element.HTTP_INTERFACE.getLocalName());
    HttpManagementResourceDefinition.HTTP_AUTHENTICATION_FACTORY.marshallAsAttribute(protocol, writer);
    HttpManagementResourceDefinition.SSL_CONTEXT.marshallAsAttribute(protocol, writer);
    HttpManagementResourceDefinition.SECURITY_REALM.marshallAsAttribute(protocol, writer);
    HttpManagementResourceDefinition.SASL_PROTOCOL.marshallAsAttribute(protocol, writer);
    HttpManagementResourceDefinition.SERVER_NAME.marshallAsAttribute(protocol, writer);

    boolean consoleEnabled = protocol.get(ModelDescriptionConstants.CONSOLE_ENABLED).asBoolean(true);
    if (!consoleEnabled) {
        HttpManagementResourceDefinition.CONSOLE_ENABLED.marshallAsAttribute(protocol, writer);
    }

    HttpManagementResourceDefinition.ALLOWED_ORIGINS.getMarshaller().marshallAsAttribute(
            HttpManagementResourceDefinition.ALLOWED_ORIGINS, protocol, true, writer);

    if (HttpManagementResourceDefinition.HTTP_UPGRADE.isMarshallable(protocol)) {
        writer.writeEmptyElement(Element.HTTP_UPGRADE.getLocalName());
        HttpManagementResourceDefinition.ENABLED.marshallAsAttribute(protocol.require(HTTP_UPGRADE), writer);
        HttpManagementResourceDefinition.SASL_AUTHENTICATION_FACTORY.marshallAsAttribute(protocol.require(HTTP_UPGRADE), writer);
    }

    if (HttpManagementResourceDefinition.SOCKET_BINDING.isMarshallable(protocol)
            || HttpManagementResourceDefinition.SECURE_SOCKET_BINDING.isMarshallable(protocol)) {
        writer.writeEmptyElement(Element.SOCKET_BINDING.getLocalName());
        HttpManagementResourceDefinition.SOCKET_BINDING.marshallAsAttribute(protocol, writer);
        HttpManagementResourceDefinition.SECURE_SOCKET_BINDING.marshallAsAttribute(protocol, writer);
    }

    writer.writeEndElement();

    return true;
}
 
Example 9
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 5 votes vote down vote up
void writePrivateKey(XMLExtendedStreamWriter writer, ModelNode model) throws XMLStreamException {
    ModelNode pk_alias = model.get(Constants.Model.PRIVATE_KEY_ALIAS);
    ModelNode pk_password = model.get(Constants.Model.PRIVATE_KEY_PASSWORD);

    if (!pk_alias.isDefined() && !pk_password.isDefined()) {
        return;
    }
    writer.writeStartElement(Constants.XML.PRIVATE_KEY);
    for (SimpleAttributeDefinition attr : KeyStorePrivateKeyDefinition.ATTRIBUTES) {
        attr.getAttributeMarshaller().marshallAsAttribute(attr, model, false, writer);
    }
    writer.writeEndElement();
}
 
Example 10
Source File: RemotingSubsystemXMLPersister.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void writeRemoteOutboundConnection(final XMLExtendedStreamWriter writer, final String connectionName, final ModelNode model) throws XMLStreamException {
    // <remote-outbound-connection>
    writer.writeStartElement(Element.REMOTE_OUTBOUND_CONNECTION.getLocalName());

    writer.writeAttribute(Attribute.NAME.getLocalName(), connectionName);

    final String outboundSocketRef = model.get(OUTBOUND_SOCKET_BINDING_REF).asString();
    writer.writeAttribute(Attribute.OUTBOUND_SOCKET_BINDING_REF.getLocalName(), outboundSocketRef);

    if (model.hasDefined(CommonAttributes.USERNAME)) {
        writer.writeAttribute(Attribute.USERNAME.getLocalName(), model.require(CommonAttributes.USERNAME).asString());
    }

    if (model.hasDefined(CommonAttributes.SECURITY_REALM)) {
        writer.writeAttribute(Attribute.SECURITY_REALM.getLocalName(), model.require(SECURITY_REALM).asString());
    }

    if (model.hasDefined(CommonAttributes.PROTOCOL)) {
        writer.writeAttribute(Attribute.PROTOCOL.getLocalName(), model.require(PROTOCOL).asString());
    }
    if (model.hasDefined(CommonAttributes.AUTHENTICATION_CONTEXT)) {
        writer.writeAttribute(Attribute.AUTHENTICATION_CONTEXT.getLocalName(), model.require(AUTHENTICATION_CONTEXT).asString());
    }
    // write the connection-creation-options if any
    if (model.hasDefined(PROPERTY)) {
        writeProperties(writer, model.get(PROPERTY));
    }

    // </remote-outbound-connection>
    writer.writeEndElement();
}
 
Example 11
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 5 votes vote down vote up
void writeCertificate(XMLExtendedStreamWriter writer, ModelNode model) throws XMLStreamException {
    ModelNode value = model.get(Constants.Model.CERTIFICATE_ALIAS);
    if (!value.isDefined()) {
        return;
    }
    writer.writeStartElement(Constants.XML.CERTIFICATE);
    SimpleAttributeDefinition attr = KeyStoreCertificateDefinition.CERTIFICATE_ALIAS;
    attr.getAttributeMarshaller().marshallAsAttribute(attr, model, false, writer);
    writer.writeEndElement();
}
 
Example 12
Source File: KeycloakSubsystemParser.java    From keycloak with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void writeContent(final XMLExtendedStreamWriter writer, final SubsystemMarshallingContext context) throws XMLStreamException {
    context.startSubsystemElement(KeycloakExtension.NAMESPACE, false);
    writeRealms(writer, context);
    writeSecureDeployments(writer, context);
    writer.writeEndElement();
}
 
Example 13
Source File: AccessControlXml.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void writeServerGroupScopedRoles(XMLExtendedStreamWriter writer, ModelNode scopedRoles) throws XMLStreamException {
    writer.writeStartElement(Element.SERVER_GROUP_SCOPED_ROLES.getLocalName());

    for (Property property : scopedRoles.asPropertyList()) {
        writer.writeStartElement(Element.ROLE.getLocalName());
        writer.writeAttribute(Attribute.NAME.getLocalName(), property.getName());
        ModelNode value = property.getValue();
        ServerGroupScopedRoleResourceDefinition.BASE_ROLE.marshallAsAttribute(value, writer);
        ServerGroupScopedRoleResourceDefinition.SERVER_GROUPS.marshallAsElement(value, writer);
        writer.writeEndElement();
    }
    writer.writeEndElement();
}
 
Example 14
Source File: ThreadsParser.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void writeThreadFactory(final XMLExtendedStreamWriter writer, final Property property, final String elementName, final boolean includeName) throws XMLStreamException {
    writer.writeStartElement(elementName);
    ModelNode node = property.getValue();
    if (includeName) {
        writer.writeAttribute(Attribute.NAME.getLocalName(), property.getName());
    }
    PoolAttributeDefinitions.GROUP_NAME.marshallAsAttribute(node, writer);
    PoolAttributeDefinitions.THREAD_NAME_PATTERN.marshallAsAttribute(node, writer);
    PoolAttributeDefinitions.PRIORITY.marshallAsAttribute(node, writer);
    writer.writeEndElement();
}
 
Example 15
Source File: OtherServicesSubsystemExtension.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
/** {@inheritDoc} */
@Override
public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context) throws XMLStreamException {
    context.startSubsystemElement(OtherServicesSubsystemExtension.NAMESPACE, false);
    writer.writeEndElement();
}
 
Example 16
Source File: HostXml_14.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
void writeContent(final XMLExtendedStreamWriter writer, final ModelMarshallingContext context)
        throws XMLStreamException {

    final ModelNode modelNode = context.getModelNode();

    writer.writeStartDocument();
    writer.writeStartElement(Element.HOST.getLocalName());

    writer.writeDefaultNamespace(Namespace.CURRENT.getUriString());
    writeNamespaces(writer, modelNode);
    writeSchemaLocation(writer, modelNode);

    if (modelNode.hasDefined(NAME)) {
        HostResourceDefinition.NAME.marshallAsAttribute(modelNode, writer);
    }
    if (modelNode.hasDefined(ORGANIZATION)) {
        HostResourceDefinition.ORGANIZATION_IDENTIFIER.marshallAsAttribute(modelNode, writer);
    }

    if (modelNode.hasDefined(EXTENSION)) {
        extensionXml.writeExtensions(writer, modelNode.get(EXTENSION));
    }

    if (modelNode.hasDefined(SYSTEM_PROPERTY)) {
        writeProperties(writer, modelNode.get(SYSTEM_PROPERTY), Element.SYSTEM_PROPERTIES, false);
    }

    if (modelNode.hasDefined(PATH)) {
        writePaths(writer, modelNode.get(PATH), false);
    }

    boolean hasCoreServices = modelNode.hasDefined(CORE_SERVICE);
    if (hasCoreServices && modelNode.get(CORE_SERVICE).hasDefined(VAULT)) {
        writeVault(writer, modelNode.get(CORE_SERVICE, VAULT));
    }

    if (hasCoreServices) {
        ManagementXml managementXml = ManagementXml.newInstance(CURRENT, this, false);
        managementXml.writeManagement(writer, modelNode.get(CORE_SERVICE, MANAGEMENT), true);
    }

    if (modelNode.hasDefined(DOMAIN_CONTROLLER)) {
        ModelNode ignoredResources = null;
        ModelNode discoveryOptions = null;
        if (hasCoreServices && modelNode.get(CORE_SERVICE).hasDefined(IGNORED_RESOURCES)
                && modelNode.get(CORE_SERVICE, IGNORED_RESOURCES).hasDefined(IGNORED_RESOURCE_TYPE)) {
            ignoredResources = modelNode.get(CORE_SERVICE, IGNORED_RESOURCES, IGNORED_RESOURCE_TYPE);
        }
        if (hasCoreServices && modelNode.get(CORE_SERVICE).hasDefined(DISCOVERY_OPTIONS)
                && modelNode.get(CORE_SERVICE, DISCOVERY_OPTIONS).hasDefined(ModelDescriptionConstants.OPTIONS)) {
            // List of discovery option types and names, in the order they were provided
            discoveryOptions = modelNode.get(CORE_SERVICE, DISCOVERY_OPTIONS, ModelDescriptionConstants.OPTIONS);
        }
        writeDomainController(writer, modelNode.get(DOMAIN_CONTROLLER), ignoredResources, discoveryOptions);
    }

    if (modelNode.hasDefined(INTERFACE)) {
        writeInterfaces(writer, modelNode.get(INTERFACE));
    }
    if (modelNode.hasDefined(JVM)) {
        writer.writeStartElement(Element.JVMS.getLocalName());
        ModelNode jvms = modelNode.get(JVM);
        for (final String jvm : jvms.keys()) {
            JvmXml.writeJVMElement(writer, jvm, jvms.get(jvm));
        }
        writer.writeEndElement();
    }

    if (modelNode.hasDefined(SERVER_CONFIG)) {
        writer.writeStartElement(Element.SERVERS.getLocalName());
        // Write the directory grouping
        HostResourceDefinition.DIRECTORY_GROUPING.marshallAsAttribute(modelNode, writer);
        writeServers(writer, modelNode.get(SERVER_CONFIG));
        writer.writeEndElement();
    } else if (modelNode.hasDefined(DIRECTORY_GROUPING)) {
        // In case there are no servers defined, write an empty element, preserving the directory grouping
        writer.writeEmptyElement(Element.SERVERS.getLocalName());
        HostResourceDefinition.DIRECTORY_GROUPING.marshallAsAttribute(modelNode, writer);
    }

    writeHostProfile(writer, context);

    if (modelNode.hasDefined(SOCKET_BINDING_GROUP)) {
        Set<String> groups = modelNode.get(SOCKET_BINDING_GROUP).keys();
        if (groups.size() > 1) {
            throw ControllerLogger.ROOT_LOGGER.multipleModelNodes(SOCKET_BINDING_GROUP);
        }
        for (String group : groups) {
            writeSocketBindingGroup(writer, modelNode.get(SOCKET_BINDING_GROUP, group), group);
        }
    }


    writer.writeEndElement();
    writer.writeEndDocument();
}
 
Example 17
Source File: NewExtension.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void writeContent(XMLExtendedStreamWriter streamWriter, SubsystemMarshallingContext context) throws XMLStreamException {
    context.startSubsystemElement(namespace, false);
    streamWriter.writeEndElement();
}
 
Example 18
Source File: SubsystemInitialization.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void writeContent(XMLExtendedStreamWriter streamWriter, SubsystemMarshallingContext context) throws XMLStreamException {
    context.startSubsystemElement(namespace, false);
    streamWriter.writeEndElement();
}
 
Example 19
Source File: ManagementXml_5.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void writeAuthentication(XMLExtendedStreamWriter writer, ModelNode realm) throws XMLStreamException {
    writer.writeStartElement(Element.AUTHENTICATION.getLocalName());
    ModelNode authentication = realm.require(AUTHENTICATION);

    if (authentication.hasDefined(TRUSTSTORE)) {
        ModelNode truststore = authentication.require(TRUSTSTORE);
        boolean hasCredential = truststore.hasDefined(KeystoreAttributes.KEYSTORE_PASSWORD_CREDENTIAL_REFERENCE.getName());
        if(hasCredential) {
                writer.writeStartElement(Element.TRUSTSTORE.getLocalName());
            } else {
                writer.writeEmptyElement(Element.TRUSTSTORE.getLocalName());
            }
        KeystoreAttributes.KEYSTORE_PROVIDER.marshallAsAttribute(truststore, writer);
        KeystoreAttributes.KEYSTORE_PATH.marshallAsAttribute(truststore, writer);
        KeystoreAttributes.KEYSTORE_RELATIVE_TO.marshallAsAttribute(truststore, writer);
        KeystoreAttributes.KEYSTORE_PASSWORD.marshallAsAttribute(truststore, writer);
        KeystoreAttributes.KEYSTORE_PASSWORD_CREDENTIAL_REFERENCE.marshallAsElement(truststore, writer);
        if (hasCredential) {
            writer.writeEndElement();
        }
    }

    if (authentication.hasDefined(LOCAL)) {
        ModelNode local = authentication.require(LOCAL);
        writer.writeStartElement(Element.LOCAL.getLocalName());
        LocalAuthenticationResourceDefinition.DEFAULT_USER.marshallAsAttribute(local, writer);
        LocalAuthenticationResourceDefinition.ALLOWED_USERS.marshallAsAttribute(local, writer);
        LocalAuthenticationResourceDefinition.SKIP_GROUP_LOADING.marshallAsAttribute(local, writer);
        writer.writeEndElement();
    }

    if (authentication.hasDefined(KERBEROS)) {
        ModelNode kerberos = authentication.require(KERBEROS);
        writer.writeEmptyElement(Element.KERBEROS.getLocalName());
        KerberosAuthenticationResourceDefinition.REMOVE_REALM.marshallAsAttribute(kerberos, writer);
    }

    if (authentication.hasDefined(JAAS)) {
        ModelNode jaas = authentication.get(JAAS);
        writer.writeStartElement(Element.JAAS.getLocalName());
        JaasAuthenticationResourceDefinition.NAME.marshallAsAttribute(jaas, writer);
        JaasAuthenticationResourceDefinition.ASSIGN_GROUPS.marshallAsAttribute(jaas, writer);
        writer.writeEndElement();
    } else if (authentication.hasDefined(LDAP)) {
        ModelNode userLdap = authentication.get(LDAP);
        writer.writeStartElement(Element.LDAP.getLocalName());
        LdapAuthenticationResourceDefinition.CONNECTION.marshallAsAttribute(userLdap, writer);
        LdapAuthenticationResourceDefinition.BASE_DN.marshallAsAttribute(userLdap, writer);
        LdapAuthenticationResourceDefinition.RECURSIVE.marshallAsAttribute(userLdap, writer);
        LdapAuthenticationResourceDefinition.USER_DN.marshallAsAttribute(userLdap, writer);
        LdapAuthenticationResourceDefinition.ALLOW_EMPTY_PASSWORDS.marshallAsAttribute(userLdap, writer);
        LdapAuthenticationResourceDefinition.USERNAME_LOAD.marshallAsAttribute(userLdap, writer);

        writeLdapCacheIfDefined(writer, userLdap);

        if (LdapAuthenticationResourceDefinition.USERNAME_FILTER.isMarshallable(userLdap)) {
            writer.writeEmptyElement(Element.USERNAME_FILTER.getLocalName());
            LdapAuthenticationResourceDefinition.USERNAME_FILTER.marshallAsAttribute(userLdap, writer);
        } else if (LdapAuthenticationResourceDefinition.ADVANCED_FILTER.isMarshallable(userLdap)) {
            writer.writeEmptyElement(Element.ADVANCED_FILTER.getLocalName());
            LdapAuthenticationResourceDefinition.ADVANCED_FILTER.marshallAsAttribute(userLdap, writer);
        }
        writer.writeEndElement();
    } else if (authentication.hasDefined(PROPERTIES)) {
        ModelNode properties = authentication.require(PROPERTIES);
        writer.writeEmptyElement(Element.PROPERTIES.getLocalName());
        PropertiesAuthenticationResourceDefinition.PATH.marshallAsAttribute(properties, writer);
        PropertiesAuthenticationResourceDefinition.RELATIVE_TO.marshallAsAttribute(properties, writer);
        PropertiesAuthenticationResourceDefinition.PLAIN_TEXT.marshallAsAttribute(properties, writer);
    } else if (authentication.has(USERS)) {
        ModelNode userDomain = authentication.get(USERS);
        ModelNode users = userDomain.hasDefined(USER) ? userDomain.require(USER) : new ModelNode().setEmptyObject();
        writer.writeStartElement(Element.USERS.getLocalName());
        for (String userName : users.keys()) {
            ModelNode currentUser = users.get(userName);
            writer.writeStartElement(Element.USER.getLocalName());
            writer.writeAttribute(Attribute.USERNAME.getLocalName(), userName);
            UserResourceDefinition.PASSWORD.marshallAsElement(currentUser, writer);
            UserResourceDefinition.CREDENTIAL_REFERENCE.marshallAsElement(currentUser, writer);
            writer.writeEndElement();
        }
        writer.writeEndElement();
    } else if (authentication.hasDefined(PLUG_IN)) {
        writePlugIn_Authentication(writer, authentication.get(PLUG_IN));
    }

    writer.writeEndElement();
}
 
Example 20
Source File: BpmPlatformParser.java    From camunda-bpm-platform with Apache License 2.0 3 votes vote down vote up
/** {@inheritDoc} */
@Override
public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context) throws XMLStreamException {

  context.startSubsystemElement(Namespace.CURRENT.getUriString(), false);
  
  writeProcessEnginesContent(writer, context);
  
  writeJobExecutorContent(writer, context);
  
  // end subsystem
  writer.writeEndElement();
}