Search in sources :

Example 1 with WorkManagerSecurity

use of org.jboss.as.connector.metadata.api.resourceadapter.WorkManagerSecurity in project wildfly by wildfly.

the class IronJacamarResourceCreator method addResourceAdapter.

private void addResourceAdapter(final Resource parent, String name, Activation ironJacamarMetadata) {
    final Resource ijResourceAdapter = new IronJacamarResource.IronJacamarRuntimeResource();
    final ModelNode model = ijResourceAdapter.getModel();
    model.get(Constants.ARCHIVE.getName()).set(name);
    setAttribute(model, Constants.BOOTSTRAP_CONTEXT, ironJacamarMetadata.getBootstrapContext());
    if (ironJacamarMetadata.getTransactionSupport() != null)
        model.get(Constants.TRANSACTION_SUPPORT.getName()).set(ironJacamarMetadata.getTransactionSupport().name());
    if (ironJacamarMetadata.getWorkManager() != null && ironJacamarMetadata.getWorkManager().getSecurity() != null) {
        org.jboss.jca.common.api.metadata.resourceadapter.WorkManagerSecurity security = ironJacamarMetadata.getWorkManager().getSecurity();
        model.get(Constants.WM_SECURITY.getName()).set(true);
        if (security.getDefaultGroups() != null) {
            for (String group : security.getDefaultGroups()) {
                model.get(Constants.WM_SECURITY_DEFAULT_GROUPS.getName()).add(group);
            }
        }
        if (security.getDefaultPrincipal() != null)
            model.get(Constants.WM_SECURITY_DEFAULT_PRINCIPAL.getName()).set(security.getDefaultPrincipal());
        model.get(Constants.WM_SECURITY_MAPPING_REQUIRED.getName()).set(security.isMappingRequired());
        if (security instanceof WorkManagerSecurity && ((WorkManagerSecurity) security).isElytronEnabled()) {
            model.get(Constants.WM_ELYTRON_SECURITY_DOMAIN.getName()).set(security.getDomain());
        } else {
            model.get(Constants.WM_SECURITY_DOMAIN.getName()).set(security.getDomain());
        }
        if (security.getGroupMappings() != null) {
            for (Map.Entry<String, String> entry : security.getGroupMappings().entrySet()) {
                final Resource mapping = new IronJacamarResource.IronJacamarRuntimeResource();
                final ModelNode subModel = mapping.getModel();
                subModel.get(Constants.WM_SECURITY_MAPPING_FROM.getName()).set(entry.getKey());
                subModel.get(Constants.WM_SECURITY_MAPPING_TO.getName()).set(entry.getKey());
                final PathElement element = PathElement.pathElement(Constants.WM_SECURITY_MAPPING_GROUPS.getName(), WM_SECURITY_MAPPING_GROUP.getName());
                ijResourceAdapter.registerChild(element, mapping);
            }
        }
        if (security.getUserMappings() != null) {
            for (Map.Entry<String, String> entry : security.getUserMappings().entrySet()) {
                final Resource mapping = new IronJacamarResource.IronJacamarRuntimeResource();
                final ModelNode subModel = mapping.getModel();
                subModel.get(Constants.WM_SECURITY_MAPPING_FROM.getName()).set(entry.getKey());
                subModel.get(Constants.WM_SECURITY_MAPPING_TO.getName()).set(entry.getKey());
                final PathElement element = PathElement.pathElement(Constants.WM_SECURITY_MAPPING_USERS.getName(), WM_SECURITY_MAPPING_USER.getName());
                ijResourceAdapter.registerChild(element, mapping);
            }
        }
    }
    if (ironJacamarMetadata.getBeanValidationGroups() != null) {
        for (String bv : ironJacamarMetadata.getBeanValidationGroups()) {
            model.get(Constants.BEANVALIDATION_GROUPS.getName()).add(new ModelNode().set(bv));
        }
    }
    if (ironJacamarMetadata.getConfigProperties() != null) {
        for (Map.Entry<String, String> config : ironJacamarMetadata.getConfigProperties().entrySet()) {
            addConfigProperties(ijResourceAdapter, config.getKey(), config.getValue());
        }
    }
    if (ironJacamarMetadata.getConnectionDefinitions() != null) {
        for (ConnectionDefinition connDef : ironJacamarMetadata.getConnectionDefinitions()) {
            addConnectionDefinition(ijResourceAdapter, connDef);
        }
    }
    if (ironJacamarMetadata.getAdminObjects() != null) {
        for (AdminObject adminObject : ironJacamarMetadata.getAdminObjects()) {
            addAdminObject(ijResourceAdapter, adminObject);
        }
    }
    final Resource statsResource = new IronJacamarResource.IronJacamarRuntimeResource();
    ijResourceAdapter.registerChild(PathElement.pathElement(Constants.STATISTICS_NAME, "local"), statsResource);
    final PathElement element = PathElement.pathElement(Constants.RESOURCEADAPTER_NAME, name);
    parent.registerChild(element, ijResourceAdapter);
}
Also used : ConnectionDefinition(org.jboss.jca.common.api.metadata.resourceadapter.ConnectionDefinition) Resource(org.jboss.as.controller.registry.Resource) WorkManagerSecurity(org.jboss.as.connector.metadata.api.resourceadapter.WorkManagerSecurity) PathElement(org.jboss.as.controller.PathElement) ModelNode(org.jboss.dmr.ModelNode) Map(java.util.Map) AdminObject(org.jboss.jca.common.api.metadata.resourceadapter.AdminObject)

Aggregations

Map (java.util.Map)1 WorkManagerSecurity (org.jboss.as.connector.metadata.api.resourceadapter.WorkManagerSecurity)1 PathElement (org.jboss.as.controller.PathElement)1 Resource (org.jboss.as.controller.registry.Resource)1 ModelNode (org.jboss.dmr.ModelNode)1 AdminObject (org.jboss.jca.common.api.metadata.resourceadapter.AdminObject)1 ConnectionDefinition (org.jboss.jca.common.api.metadata.resourceadapter.ConnectionDefinition)1