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();
    }
  }
  private void configureIdentityStore(
      OperationContext context,
      ServiceBuilder<PartitionManager> serviceBuilder,
      ServiceVerificationHandler verificationHandler,
      List<ServiceController<?>> newControllers,
      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,
              verificationHandler,
              newControllers,
              partitionManagerService,
              identityStore,
              configurationName,
              namedIdentityConfigurationBuilder);
    } else if (storeType.equals(FILE_STORE.getName())) {
      storeConfig =
          configureFileIdentityStore(
              context,
              serviceBuilder,
              verificationHandler,
              newControllers,
              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);
  }
  @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));
      }
    }
  }