Search in sources :

Example 96 with Property

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

the class IIOPSubsystemAdd method getResourceProperties.

private void getResourceProperties(final Properties properties, PersistentResourceDefinition resource, OperationContext context, ModelNode model) throws OperationFailedException {
    for (AttributeDefinition attrDefinition : resource.getAttributes()) {
        if (attrDefinition instanceof PropertiesAttributeDefinition) {
            PropertiesAttributeDefinition pad = (PropertiesAttributeDefinition) attrDefinition;
            ModelNode resolvedModelAttribute = attrDefinition.resolveModelAttribute(context, model);
            if (resolvedModelAttribute.isDefined()) {
                for (final Property prop : resolvedModelAttribute.asPropertyList()) {
                    properties.setProperty(prop.getName(), prop.getValue().asString());
                }
            }
            continue;
        }
        ModelNode resolvedModelAttribute = attrDefinition.resolveModelAttribute(context, model);
        //FIXME
        if (resolvedModelAttribute.isDefined()) {
            String name = attrDefinition.getName();
            String value = resolvedModelAttribute.asString();
            String openjdkProperty = PropertiesMap.PROPS_MAP.get(name);
            if (openjdkProperty != null) {
                name = openjdkProperty;
            }
            properties.setProperty(name, value);
        }
    }
}
Also used : PropertiesAttributeDefinition(org.jboss.as.controller.PropertiesAttributeDefinition) PropertiesAttributeDefinition(org.jboss.as.controller.PropertiesAttributeDefinition) AttributeDefinition(org.jboss.as.controller.AttributeDefinition) ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property)

Example 97 with Property

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

the class PartitionManagerAddHandler method configureCredentialHandlers.

@SuppressWarnings({ "unchecked", "rawtypes" })
private void configureCredentialHandlers(OperationContext context, ModelNode identityStore, IdentityStoreConfigurationBuilder<?, ?> storeConfig) throws OperationFailedException {
    if (identityStore.hasDefined(IDENTITY_STORE_CREDENTIAL_HANDLER.getName())) {
        for (Property credentialHandler : identityStore.get(IDENTITY_STORE_CREDENTIAL_HANDLER.getName()).asPropertyList()) {
            ModelNode classNameNode = CredentialHandlerResourceDefinition.CLASS_NAME.resolveModelAttribute(context, credentialHandler.getValue());
            ModelNode codeNode = CredentialHandlerResourceDefinition.CODE.resolveModelAttribute(context, credentialHandler.getValue());
            ModelNode moduleNode = CredentialHandlerResourceDefinition.MODULE.resolveModelAttribute(context, credentialHandler.getValue());
            String typeName;
            if (classNameNode.isDefined()) {
                typeName = classNameNode.asString();
            } else if (codeNode.isDefined()) {
                typeName = CredentialTypeEnum.forType(codeNode.asString());
            } else {
                throw ROOT_LOGGER.typeNotProvided(IDENTITY_STORE_CREDENTIAL_HANDLER.getName());
            }
            storeConfig.addCredentialHandler(this.<CredentialHandler>loadClass(moduleNode, typeName));
        }
    }
}
Also used : ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property)

Example 98 with Property

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

the class PartitionManagerAddHandler method configureLDAPIdentityStore.

private LDAPStoreConfigurationBuilder configureLDAPIdentityStore(OperationContext context, ModelNode ldapIdentityStore, NamedIdentityConfigurationBuilder builder) throws OperationFailedException {
    LDAPStoreConfigurationBuilder storeConfig = builder.stores().ldap();
    ModelNode url = LDAPStoreResourceDefinition.URL.resolveModelAttribute(context, ldapIdentityStore);
    ModelNode bindDn = LDAPStoreResourceDefinition.BIND_DN.resolveModelAttribute(context, ldapIdentityStore);
    ModelNode bindCredential = LDAPStoreResourceDefinition.BIND_CREDENTIAL.resolveModelAttribute(context, ldapIdentityStore);
    ModelNode baseDn = LDAPStoreResourceDefinition.BASE_DN_SUFFIX.resolveModelAttribute(context, ldapIdentityStore);
    ModelNode uniqueIdAttributeName = LDAPStoreResourceDefinition.UNIQUE_ID_ATTRIBUTE_NAME.resolveModelAttribute(context, ldapIdentityStore);
    ModelNode activeDirectory = LDAPStoreResourceDefinition.ACTIVE_DIRECTORY.resolveModelAttribute(context, ldapIdentityStore);
    if (url.isDefined()) {
        storeConfig.url(url.asString());
    }
    if (bindDn.isDefined()) {
        storeConfig.bindDN(bindDn.asString());
    }
    if (bindCredential.isDefined()) {
        storeConfig.bindCredential(bindCredential.asString());
    }
    if (baseDn.isDefined()) {
        storeConfig.baseDN(baseDn.asString());
    }
    if (uniqueIdAttributeName.isDefined()) {
        storeConfig.uniqueIdentifierAttributeName(uniqueIdAttributeName.asString());
    }
    storeConfig.activeDirectory(activeDirectory.asBoolean());
    if (ldapIdentityStore.hasDefined(LDAP_STORE_MAPPING.getName())) {
        for (Property mappingNode : ldapIdentityStore.get(LDAP_STORE_MAPPING.getName()).asPropertyList()) {
            ModelNode ldapMapping = mappingNode.getValue();
            ModelNode classNameNode = LDAPStoreMappingResourceDefinition.CLASS_NAME.resolveModelAttribute(context, ldapMapping);
            ModelNode codeNode = LDAPStoreMappingResourceDefinition.CODE.resolveModelAttribute(context, ldapMapping);
            ModelNode moduleNode = LDAPStoreMappingResourceDefinition.MODULE.resolveModelAttribute(context, ldapMapping);
            String typeName;
            if (classNameNode.isDefined()) {
                typeName = classNameNode.asString();
            } else if (codeNode.isDefined()) {
                typeName = AttributedTypeEnum.forType(codeNode.asString());
            } else {
                throw ROOT_LOGGER.typeNotProvided(LDAP_STORE_MAPPING.getName());
            }
            LDAPMappingConfigurationBuilder storeMapping = storeConfig.mapping(this.<AttributedType>loadClass(moduleNode, typeName));
            ModelNode relatesToNode = LDAPStoreMappingResourceDefinition.RELATES_TO.resolveModelAttribute(context, ldapMapping);
            if (relatesToNode.isDefined()) {
                String relatesTo = AttributedTypeEnum.forType(relatesToNode.asString());
                if (relatesTo == null) {
                    relatesTo = relatesToNode.asString();
                }
                storeMapping.forMapping(this.<AttributedType>loadClass(moduleNode, relatesTo));
            } else {
                String baseDN = LDAPStoreMappingResourceDefinition.BASE_DN.resolveModelAttribute(context, ldapMapping).asString();
                storeMapping.baseDN(baseDN);
                String objectClasses = LDAPStoreMappingResourceDefinition.OBJECT_CLASSES.resolveModelAttribute(context, ldapMapping).asString();
                for (String objClass : objectClasses.split(",")) {
                    if (!objClass.trim().isEmpty()) {
                        storeMapping.objectClasses(objClass);
                    }
                }
                ModelNode parentAttributeName = LDAPStoreMappingResourceDefinition.PARENT_ATTRIBUTE.resolveModelAttribute(context, ldapMapping);
                if (parentAttributeName.isDefined()) {
                    storeMapping.parentMembershipAttributeName(parentAttributeName.asString());
                }
            }
            if (ldapMapping.hasDefined(LDAP_STORE_ATTRIBUTE.getName())) {
                for (Property attributeNode : ldapMapping.get(LDAP_STORE_ATTRIBUTE.getName()).asPropertyList()) {
                    ModelNode attribute = attributeNode.getValue();
                    String name = LDAPStoreAttributeResourceDefinition.NAME.resolveModelAttribute(context, attribute).asString();
                    String ldapName = LDAPStoreAttributeResourceDefinition.LDAP_NAME.resolveModelAttribute(context, attribute).asString();
                    boolean readOnly = LDAPStoreAttributeResourceDefinition.READ_ONLY.resolveModelAttribute(context, attribute).asBoolean();
                    if (readOnly) {
                        storeMapping.readOnlyAttribute(name, ldapName);
                    } else {
                        boolean isIdentifier = LDAPStoreAttributeResourceDefinition.IS_IDENTIFIER.resolveModelAttribute(context, attribute).asBoolean();
                        storeMapping.attribute(name, ldapName, isIdentifier);
                    }
                }
            }
        }
    } else {
        throw ROOT_LOGGER.idmLdapNoMappingDefined();
    }
    return storeConfig;
}
Also used : LDAPMappingConfigurationBuilder(org.picketlink.idm.config.LDAPMappingConfigurationBuilder) LDAPStoreConfigurationBuilder(org.picketlink.idm.config.LDAPStoreConfigurationBuilder) ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property)

Example 99 with Property

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

the class PartitionManagerAddHandler method configureIdentityStore.

private void configureIdentityStore(OperationContext context, ServiceBuilder<PartitionManager> serviceBuilder, PartitionManagerService partitionManagerService, String configurationName, NamedIdentityConfigurationBuilder namedIdentityConfigurationBuilder, ModelNode modelNode) throws OperationFailedException {
    Property prop = modelNode.asProperty();
    String storeType = prop.getName();
    ModelNode identityStore = prop.getValue().asProperty().getValue();
    IdentityStoreConfigurationBuilder<?, ?> storeConfig = null;
    if (storeType.equals(JPA_STORE.getName())) {
        storeConfig = configureJPAIdentityStore(context, serviceBuilder, partitionManagerService, identityStore, configurationName, namedIdentityConfigurationBuilder);
    } else if (storeType.equals(FILE_STORE.getName())) {
        storeConfig = configureFileIdentityStore(context, serviceBuilder, partitionManagerService, identityStore, configurationName, namedIdentityConfigurationBuilder);
    } else if (storeType.equals(LDAP_STORE.getName())) {
        storeConfig = configureLDAPIdentityStore(context, identityStore, namedIdentityConfigurationBuilder);
    }
    ModelNode supportAttributeNode = JPAStoreResourceDefinition.SUPPORT_ATTRIBUTE.resolveModelAttribute(context, identityStore);
    storeConfig.supportAttributes(supportAttributeNode.asBoolean());
    ModelNode supportCredentialNode = JPAStoreResourceDefinition.SUPPORT_CREDENTIAL.resolveModelAttribute(context, identityStore);
    storeConfig.supportCredentials(supportCredentialNode.asBoolean());
    configureSupportedTypes(context, identityStore, storeConfig);
    configureCredentialHandlers(context, identityStore, storeConfig);
}
Also used : ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property)

Example 100 with Property

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

the class PartitionManagerAddHandler method configureSupportedTypes.

private void configureSupportedTypes(OperationContext context, ModelNode identityStore, IdentityStoreConfigurationBuilder storeConfig) throws OperationFailedException {
    boolean hasSupportedType = identityStore.hasDefined(SUPPORTED_TYPES.getName());
    if (hasSupportedType) {
        ModelNode featuresSetNode = identityStore.get(SUPPORTED_TYPES.getName()).asProperty().getValue();
        ModelNode supportsAllNode = SupportedTypesResourceDefinition.SUPPORTS_ALL.resolveModelAttribute(context, featuresSetNode);
        if (supportsAllNode.asBoolean()) {
            storeConfig.supportAllFeatures();
        }
        hasSupportedType = supportsAllNode.asBoolean();
        if (featuresSetNode.hasDefined(SUPPORTED_TYPE.getName())) {
            for (Property supportedTypeNode : featuresSetNode.get(SUPPORTED_TYPE.getName()).asPropertyList()) {
                ModelNode supportedType = supportedTypeNode.getValue();
                ModelNode classNameNode = SupportedTypeResourceDefinition.CLASS_NAME.resolveModelAttribute(context, supportedType);
                ModelNode codeNode = SupportedTypeResourceDefinition.CODE.resolveModelAttribute(context, supportedType);
                String typeName;
                if (classNameNode.isDefined()) {
                    typeName = classNameNode.asString();
                } else if (codeNode.isDefined()) {
                    typeName = AttributedTypeEnum.forType(codeNode.asString());
                } else {
                    throw ROOT_LOGGER.typeNotProvided(SUPPORTED_TYPE.getName());
                }
                ModelNode moduleNode = SupportedTypeResourceDefinition.MODULE.resolveModelAttribute(context, supportedType);
                Class<? extends AttributedType> attributedTypeClass = loadClass(moduleNode, typeName);
                if (Relationship.class.isAssignableFrom(attributedTypeClass)) {
                    storeConfig.supportGlobalRelationship((Class<? extends Relationship>) attributedTypeClass);
                } else {
                    storeConfig.supportType(attributedTypeClass);
                }
                hasSupportedType = true;
            }
        }
    }
    if (!hasSupportedType) {
        throw ROOT_LOGGER.idmNoSupportedTypesDefined();
    }
}
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