private IdentityStoreConfigurationBuilder<?, ?> configureFileIdentityStore( OperationContext context, ServiceBuilder<PartitionManager> serviceBuilder, ServiceVerificationHandler verificationHandler, List<ServiceController<?>> newControllers, PartitionManagerService partitionManagerService, ModelNode resource, String configurationName, final NamedIdentityConfigurationBuilder builder) throws OperationFailedException { FileStoreConfigurationBuilder fileStoreBuilder = builder.stores().file(); String workingDir = FileStoreResourceDefinition.WORKING_DIR.resolveModelAttribute(context, resource).asString(); String relativeTo = FileStoreResourceDefinition.RELATIVE_TO.resolveModelAttribute(context, resource).asString(); ModelNode alwaysCreateFiles = FileStoreResourceDefinition.ALWAYS_CREATE_FILE.resolveModelAttribute(context, resource); ModelNode asyncWrite = FileStoreResourceDefinition.ASYNC_WRITE.resolveModelAttribute(context, resource); ModelNode asyncWriteThreadPool = FileStoreResourceDefinition.ASYNC_WRITE_THREAD_POOL.resolveModelAttribute( context, resource); fileStoreBuilder.preserveState(!alwaysCreateFiles.asBoolean()); fileStoreBuilder.asyncWrite(asyncWrite.asBoolean()); fileStoreBuilder.asyncWriteThreadPool(asyncWriteThreadPool.asInt()); if (serviceBuilder != null) { FileIdentityStoreService storeService = new FileIdentityStoreService(fileStoreBuilder, workingDir, relativeTo); ServiceName storeServiceName = PartitionManagerService.createIdentityStoreServiceName( partitionManagerService.getName(), configurationName, ModelElement.FILE_STORE.getName()); ServiceBuilder<FileIdentityStoreService> storeServiceBuilder = context.getServiceTarget().addService(storeServiceName, storeService); storeServiceBuilder.addDependency( PathManagerService.SERVICE_NAME, PathManager.class, storeService.getPathManager()); serviceBuilder.addDependency(storeServiceName); if (verificationHandler != null) { storeServiceBuilder.addListener(verificationHandler); } ServiceController<FileIdentityStoreService> controller = storeServiceBuilder.setInitialMode(Mode.PASSIVE).install(); if (newControllers != null) { newControllers.add(controller); } } return fileStoreBuilder; }
private JPAStoreSubsystemConfigurationBuilder configureJPAIdentityStore( OperationContext context, ServiceBuilder<PartitionManager> serviceBuilder, ServiceVerificationHandler verificationHandler, List<ServiceController<?>> newControllers, PartitionManagerService partitionManagerService, final ModelNode identityStore, String configurationName, final NamedIdentityConfigurationBuilder builder) throws OperationFailedException { JPAStoreSubsystemConfigurationBuilder storeConfig = builder .stores() .add(JPAStoreSubsystemConfiguration.class, JPAStoreSubsystemConfigurationBuilder.class); ModelNode jpaDataSourceNode = JPAStoreResourceDefinition.DATA_SOURCE.resolveModelAttribute(context, identityStore); ModelNode jpaEntityModule = JPAStoreResourceDefinition.ENTITY_MODULE.resolveModelAttribute(context, identityStore); ModelNode jpaEntityModuleUnitName = JPAStoreResourceDefinition.ENTITY_MODULE_UNIT_NAME.resolveModelAttribute( context, identityStore); ModelNode jpaEntityManagerFactoryNode = JPAStoreResourceDefinition.ENTITY_MANAGER_FACTORY.resolveModelAttribute( context, identityStore); if (jpaEntityModule.isDefined()) { storeConfig.entityModule(jpaEntityModule.asString()); } storeConfig.entityModuleUnitName(jpaEntityModuleUnitName.asString()); if (serviceBuilder != null) { JPAIdentityStoreService storeService = new JPAIdentityStoreService(storeConfig); ServiceName storeServiceName = PartitionManagerService.createIdentityStoreServiceName( partitionManagerService.getName(), configurationName, ModelElement.JPA_STORE.getName()); ServiceBuilder<JPAIdentityStoreService> storeServiceBuilder = context.getServiceTarget().addService(storeServiceName, storeService); storeServiceBuilder.addDependency( TxnServices.JBOSS_TXN_TRANSACTION_MANAGER, TransactionManager.class, storeService.getTransactionManager()); storeServiceBuilder.addDependency( TxnServices.JBOSS_TXN_SYNCHRONIZATION_REGISTRY, TransactionSynchronizationRegistry.class, storeService.getTransactionSynchronizationRegistry()); if (jpaDataSourceNode.isDefined()) { storeConfig.dataSourceJndiUrl(toJndiName(jpaDataSourceNode.asString())); storeServiceBuilder.addDependency( ContextNames.JAVA_CONTEXT_SERVICE_NAME.append( toJndiName(jpaDataSourceNode.asString()).split("/"))); } if (jpaEntityManagerFactoryNode.isDefined()) { storeConfig.entityManagerFactoryJndiName(jpaEntityManagerFactoryNode.asString()); storeServiceBuilder.addDependency( ContextNames.JAVA_CONTEXT_SERVICE_NAME.append( jpaEntityManagerFactoryNode.asString().split("/")), ValueManagedReferenceFactory.class, new InjectedValue<ValueManagedReferenceFactory>()); } serviceBuilder.addDependency(storeServiceName); if (verificationHandler != null) { storeServiceBuilder.addListener(verificationHandler); } ServiceController<JPAIdentityStoreService> controller = storeServiceBuilder.setInitialMode(Mode.PASSIVE).install(); if (newControllers != null) { newControllers.add(controller); } } return storeConfig; }
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); 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 (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; }