コード例 #1
0
ファイル: AppClientXml.java プロジェクト: GeekkeeG/wildfly
  private void parseServerProfile(
      final XMLExtendedStreamReader reader, final ModelNode address, final List<ModelNode> list)
      throws XMLStreamException {
    // Attributes
    requireNoAttributes(reader);

    // Content
    final Set<String> configuredSubsystemTypes = new HashSet<String>();
    while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
      if (Element.forName(reader.getLocalName()) != Element.SUBSYSTEM) {
        throw unexpectedElement(reader);
      }
      if (!configuredSubsystemTypes.add(reader.getNamespaceURI())) {
        throw AppClientLogger.ROOT_LOGGER.duplicateSubsystemDeclaration(reader.getLocation());
      }
      // parse subsystem
      final List<ModelNode> subsystems = new ArrayList<ModelNode>();
      reader.handleAny(subsystems);

      // Process subsystems
      for (final ModelNode update : subsystems) {
        // Process relative subsystem path address
        final ModelNode subsystemAddress = address.clone();
        for (final Property path : update.get(OP_ADDR).asPropertyList()) {
          subsystemAddress.add(path.getName(), path.getValue().asString());
        }
        update.get(OP_ADDR).set(subsystemAddress);
        list.add(update);
      }
    }
  }
コード例 #2
0
  private void setProps(ModelNode requestProperties) throws Exception {
    props = new TreeSet<RequestProp>();
    if (opName.equals("add")) {
      UserObject usrObj = (UserObject) node.getUserObject();
      props.add(
          new RequestProp(
              "/" + usrObj.getName() + "=<name>/",
              "Resource name for the new " + usrObj.getName(),
              true,
              ModelType.STRING));
    }

    if (opName.equals("write-attribute") && node.isLeaf()) {
      ModelNode nameNode = requestProperties.get("name");
      nameNode
          .get("type")
          .set(ModelType.UNDEFINED); // undefined type will display as uneditable String
      UserObject usrObj = (UserObject) node.getUserObject();
      ModelNode nameNodeValue = new ModelNode();
      nameNodeValue.set(usrObj.getName());
      props.add(new RequestProp("name", requestProperties.get("name"), nameNodeValue));

      ModelNode rscDesc =
          cliGuiCtx.getExecutor().doCommand(node.addressPath() + ":read-resource-description");
      ModelNode valueNode = rscDesc.get("result", "attributes", usrObj.getName());
      valueNode.get("required").set(false); // value is never required for write-attribute
      ModelNode valueNodeValue = usrObj.getBackingNode().get(usrObj.getName());
      props.add(new RequestProp("value", valueNode, valueNodeValue));
      return;
    }

    for (Property prop : requestProperties.asPropertyList()) {
      props.add(new RequestProp(prop.getName(), prop.getValue(), null));
    }
  }
コード例 #3
0
  /*
   * Tests access to local cache attributes
   */
  @SuppressWarnings("deprecation")
  @Test
  public void testDistributedCacheMixedJDBCStoreReadWriteOperation() throws Exception {

    ModelNode stringKeyedTable = createStringKeyedTable();

    // Parse and install the XML into the controller
    String subsystemXml = getSubsystemXml();
    KernelServices servicesA =
        this.createKernelServicesBuilder().setSubsystemXml(subsystemXml).build();

    // read the distributed cache mixed-keyed-jdbc-store datasource attribute
    ModelNode result =
        servicesA.executeOperation(
            getMixedKeyedJDBCCacheStoreReadOperation(
                "maximal",
                DistributedCacheResourceDefinition.WILDCARD_PATH.getKey(),
                "dist",
                JDBCStoreResourceDefinition.Attribute.DATA_SOURCE));
    Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
    Assert.assertEquals("ExampleDS", result.get(RESULT).asString());

    // write the batching attribute
    result =
        servicesA.executeOperation(
            getMixedKeyedJDBCCacheStoreWriteOperation(
                "maximal",
                DistributedCacheResourceDefinition.WILDCARD_PATH.getKey(),
                "dist",
                JDBCStoreResourceDefinition.Attribute.DATA_SOURCE,
                "new-datasource"));
    Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());

    // re-read the batching attribute
    result =
        servicesA.executeOperation(
            getMixedKeyedJDBCCacheStoreReadOperation(
                "maximal",
                DistributedCacheResourceDefinition.WILDCARD_PATH.getKey(),
                "dist",
                JDBCStoreResourceDefinition.Attribute.DATA_SOURCE));
    Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
    Assert.assertEquals("new-datasource", result.get(RESULT).asString());

    // read the string-keyed-table attribute
    result =
        servicesA.executeOperation(
            getMixedKeyedJDBCCacheStoreReadOperation(
                "maximal",
                DistributedCacheResourceDefinition.WILDCARD_PATH.getKey(),
                "dist",
                MixedKeyedJDBCStoreResourceDefinition.DeprecatedAttribute.STRING_TABLE));
    Assert.assertEquals(result.toString(), SUCCESS, result.get(OUTCOME).asString());
    Assert.assertEquals(
        stringKeyedTable.asPropertyList().size(), result.get(RESULT).asPropertyList().size());
    for (Property property : stringKeyedTable.asPropertyList()) {
      Assert.assertTrue(result.get(RESULT).hasDefined(property.getName()));
      Assert.assertEquals(property.getValue(), result.get(RESULT).get(property.getName()));
    }
  }
コード例 #4
0
 // For any request params that are of type BYTES, replace the file path with the bytes from the
 // file
 private boolean replaceFilePathsWithBytes(ModelNode request)
     throws CommandFormatException, IOException {
   boolean didReplacement = false;
   ModelNode opDesc = new ModelNode();
   opDesc.get("address").set(request.get("address"));
   opDesc.get("operation").set("read-operation-description");
   final String opName = request.get("operation").asString();
   opDesc.get("name").set(opName);
   ModelNode response = execute(opDesc, false).getResponseNode();
   if (response.hasDefined("result", "request-properties")) {
     final ModelNode requestProps = response.get("result", "request-properties");
     for (Property prop : requestProps.asPropertyList()) {
       ModelNode typeDesc = prop.getValue().get("type");
       if (typeDesc.getType() == ModelType.TYPE
           && typeDesc.asType() == ModelType.BYTES
           && request.hasDefined(prop.getName())) {
         String filePath = request.get(prop.getName()).asString();
         File localFile = new File(filePath);
         if (!localFile.exists()) continue;
         try {
           request.get(prop.getName()).set(Util.readBytes(localFile));
           didReplacement = true;
         } catch (OperationFormatException e) {
           throw new CommandFormatException(e);
         }
       }
     }
   }
   return didReplacement;
 }
コード例 #5
0
  void launchServices(
      final OperationContext context,
      final PathAddress pathAddress,
      final ModelNode model,
      final ServiceVerificationHandler verificationHandler,
      final List<ServiceController<?>> newControllers)
      throws OperationFailedException {
    Handler newHandler = new Handler();

    newHandler.setClazz(
        HandlerResourceDefinition.CLASS.resolveModelAttribute(context, model).asString());

    ModelNode handler = Resource.Tools.readModel(context.readResourceFromRoot(pathAddress));

    if (handler.hasDefined(COMMON_HANDLER_PARAMETER.getName())) {
      for (ModelNode handlerParameter : handler.get(COMMON_HANDLER_PARAMETER.getName()).asList()) {
        Property property = handlerParameter.asProperty();
        String paramName = property.getName();
        String paramValue =
            HandlerParameterResourceDefinition.VALUE
                .resolveModelAttribute(context, property.getValue())
                .asString();

        KeyValueType kv = new KeyValueType();

        kv.setKey(paramName);
        kv.setValue(paramValue);

        newHandler.add(kv);
      }
    }

    SAMLHandlerService service = new SAMLHandlerService(newHandler);
    PathElement providerAlias = pathAddress.subAddress(0, pathAddress.size() - 1).getLastElement();

    ServiceTarget serviceTarget = context.getServiceTarget();
    ServiceBuilder<SAMLHandlerService> serviceBuilder =
        serviceTarget.addService(
            createServiceName(providerAlias.getValue(), newHandler.getClazz()), service);
    ServiceName serviceName;

    if (providerAlias.getKey().equals(IDENTITY_PROVIDER.getName())) {
      serviceName = IdentityProviderService.createServiceName(providerAlias.getValue());
    } else {
      serviceName = ServiceProviderService.createServiceName(providerAlias.getValue());
    }

    serviceBuilder.addDependency(
        serviceName, EntityProviderService.class, service.getEntityProviderService());

    ServiceController<SAMLHandlerService> controller =
        serviceBuilder
            .addListener(verificationHandler)
            .setInitialMode(ServiceController.Mode.PASSIVE)
            .install();

    if (newControllers != null) {
      newControllers.add(controller);
    }
  }
コード例 #6
0
  @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));
      }
    }
  }
コード例 #7
0
    private void addThreadFactories(final ModelNode result, final ModelNode model) {
      if (model.hasDefined(THREAD_FACTORY)) {
        ModelNode pools = model.get(THREAD_FACTORY);
        for (Property poolProp : pools.asPropertyList()) {
          final ModelNode operation =
              Util.getEmptyOperation(
                  ADD,
                  pathAddress(
                      PathElement.pathElement(SUBSYSTEM, SUBSYSTEM_NAME),
                      PathElement.pathElement(THREAD_FACTORY, poolProp.getName())));
          final ModelNode pool = poolProp.getValue();

          operation.get(NAME).set(pool.require(NAME));
          if (pool.hasDefined(GROUP_NAME)) {
            operation.get(GROUP_NAME).set(pool.get(GROUP_NAME));
          }
          if (pool.hasDefined(THREAD_NAME_PATTERN)) {
            operation.get(THREAD_NAME_PATTERN).set(pool.get(THREAD_NAME_PATTERN));
          }
          if (pool.hasDefined(PRIORITY)) {
            operation.get(PRIORITY).set(pool.get(PRIORITY));
          }
          if (pool.hasDefined(PROPERTIES)) {
            operation.get(PROPERTIES).set(pool.get(PROPERTIES));
          }
          result.add(operation);
        }
      }
    }
コード例 #8
0
    private void addUnboundedQueueThreadPools(final ModelNode result, final ModelNode model) {
      if (model.hasDefined(UNBOUNDED_QUEUE_THREAD_POOL)) {
        ModelNode pools = model.get(UNBOUNDED_QUEUE_THREAD_POOL);
        for (Property poolProp : pools.asPropertyList()) {
          final ModelNode operation =
              Util.getEmptyOperation(
                  ADD,
                  pathAddress(
                      PathElement.pathElement(SUBSYSTEM, SUBSYSTEM_NAME),
                      PathElement.pathElement(UNBOUNDED_QUEUE_THREAD_POOL, poolProp.getName())));
          final ModelNode pool = poolProp.getValue();

          operation.get(NAME).set(pool.require(NAME));
          if (pool.hasDefined(THREAD_FACTORY)) {
            operation.get(THREAD_FACTORY).set(pool.get(THREAD_FACTORY));
          }
          if (pool.hasDefined(PROPERTIES)) {
            operation.get(PROPERTIES).set(pool.get(PROPERTIES));
          }
          if (pool.hasDefined(MAX_THREADS)) {
            operation.get(MAX_THREADS).set(pool.get(MAX_THREADS));
          }
          if (pool.hasDefined(KEEPALIVE_TIME)) {
            operation.get(KEEPALIVE_TIME).set(pool.get(KEEPALIVE_TIME));
          }
          result.add(operation);
        }
      }
    }
コード例 #9
0
 private void addInterfaces(Map<String, ModelNode> map, ModelNode iface) {
   if (iface.isDefined()) {
     for (Property prop : iface.asPropertyList()) {
       map.put(prop.getName(), prop.getValue());
     }
   }
 }
コード例 #10
0
ファイル: MailSessionAdd.java プロジェクト: GeekkeeG/wildfly
  static MailSessionConfig from(final OperationContext operationContext, final ModelNode model)
      throws OperationFailedException {
    MailSessionConfig cfg = new MailSessionConfig();

    cfg.setJndiName(
        MailSessionDefinition.JNDI_NAME.resolveModelAttribute(operationContext, model).asString());
    cfg.setDebug(
        MailSessionDefinition.DEBUG.resolveModelAttribute(operationContext, model).asBoolean());
    if (MailSessionDefinition.FROM.resolveModelAttribute(operationContext, model).isDefined()) {
      cfg.setFrom(
          MailSessionDefinition.FROM.resolveModelAttribute(operationContext, model).asString());
    }
    if (model.hasDefined(SERVER_TYPE)) {
      ModelNode server = model.get(SERVER_TYPE);
      if (server.hasDefined(SMTP)) {
        cfg.setSmtpServer(readServerConfig(operationContext, server.get(SMTP)));
      }
      if (server.hasDefined(POP3)) {
        cfg.setPop3Server(readServerConfig(operationContext, server.get(POP3)));
      }
      if (server.hasDefined(IMAP)) {
        cfg.setImapServer(readServerConfig(operationContext, server.get(IMAP)));
      }
    }
    if (model.hasDefined(CUSTOM)) {
      for (Property server : model.get(CUSTOM).asPropertyList()) {
        cfg.addCustomServer(
            readCustomServerConfig(server.getName(), operationContext, server.getValue()));
      }
    }
    return cfg;
  }
コード例 #11
0
 static ModelNode parseCustomLoadMetric(XMLExtendedStreamReader reader) throws XMLStreamException {
   final ModelNode load = new ModelNode();
   final int count = reader.getAttributeCount();
   for (int i = 0; i < count; i++) {
     requireNoNamespaceAttribute(reader, i);
     final String value = reader.getAttributeValue(i);
     final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
     switch (attribute) {
       case CAPACITY:
         load.get(CAPACITY).set(value);
         break;
       case WEIGHT:
         load.get(WEIGHT).set(value);
         break;
       case CLASS:
         load.get(CLASS).set(value);
         break;
       default:
         unexpectedAttribute(reader, i);
     }
   }
   while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
     final Element element = Element.forName(reader.getLocalName());
     switch (element) {
       case PROPERTY:
         final Property property = parseProperty(reader);
         load.get("property").add(property.getName(), property.getValue());
         break;
       default:
         unexpectedElement(reader);
     }
   }
   return load;
 }
コード例 #12
0
  private static ModelFixer createModelFixer(ModelVersion version) {
    return (ModelNode model) -> {
      if (InfinispanModel.VERSION_4_1_0.requiresTransformation(version)) {
        final ModelNode maximal = model.get("cache-container", "maximal");
        maximal
            .asPropertyList()
            .stream()
            .filter(
                caches ->
                    caches.getName().equals("distributed-cache")
                        || caches.getName().equals("replicated-cache"))
            .forEach(
                p -> {
                  ModelNode caches = maximal.get(p.getName());
                  final List<Property> cachesModel = caches.asPropertyList();
                  for (Property cacheName : cachesModel) {
                    final ModelNode cache = caches.get(cacheName.getName());
                    if (cache.hasDefined("component")) {
                      cache.get("component", "backups").set(new ModelNode());
                    }
                  }
                });
      }

      if (InfinispanModel.VERSION_4_0_0.requiresTransformation(version)) {
        // Fix the legacy model to expect new default values applied in
        // StateTransferResourceDefinition#buildTransformation
        Arrays.asList("cache-with-string-keyed-store", "cache-with-binary-keyed-store")
            .forEach(
                cacheName -> {
                  ModelNode cache =
                      model.get("cache-container", "maximal", "replicated-cache", cacheName);
                  assertFalse(
                      cache.hasDefined(
                          StateTransferResourceDefinition.LEGACY_PATH.getKeyValuePair()));
                  ModelNode stateTransfer =
                      cache.get(StateTransferResourceDefinition.LEGACY_PATH.getKeyValuePair());
                  stateTransfer
                      .get(
                          StateTransferResourceDefinition.Attribute.CHUNK_SIZE
                              .getDefinition()
                              .getName())
                      .set(
                          StateTransferResourceDefinition.Attribute.CHUNK_SIZE
                              .getDefinition()
                              .getDefaultValue());
                  stateTransfer
                      .get(
                          StateTransferResourceDefinition.Attribute.TIMEOUT
                              .getDefinition()
                              .getName())
                      .set(
                          StateTransferResourceDefinition.Attribute.TIMEOUT
                              .getDefinition()
                              .getDefaultValue());
                });
      }
      return model;
    };
  }
コード例 #13
0
 /* Property logic */
 static void writeProperty(final XMLExtendedStreamWriter writer, Property property)
     throws XMLStreamException {
   writer.writeStartElement(Element.PROPERTY.getLocalName());
   writer.writeAttribute(NAME, property.getName());
   writer.writeAttribute(VALUE, property.getValue().asString());
   writer.writeEndElement();
 }
 @Override
 public void persist(XMLExtendedStreamWriter writer, ModelNode model) throws XMLStreamException {
   boolean wildcard = getPathElement().isWildcard();
   model =
       wildcard
           ? model.get(getPathElement().getKey())
           : model.get(getPathElement().getKeyValuePair());
   if (!model.isDefined()) {
     return;
   }
   boolean writeWrapper = getXmlWrapperElement() != null;
   if (writeWrapper) {
     writer.writeStartElement(getXmlWrapperElement());
   }
   writer.writeStartElement(getXmlElementName());
   if (wildcard) {
     for (Property p : model.asPropertyList()) {
       writer.writeAttribute(NAME, p.getName());
       for (AttributeDefinition def : getAttributes()) {
         def.getAttributeMarshaller().marshallAsAttribute(def, p.getValue(), false, writer);
       }
       persistChildren(writer, p.getValue());
     }
   } else {
     for (AttributeDefinition def : getAttributes()) {
       def.getAttributeMarshaller().marshallAsAttribute(def, model, false, writer);
     }
     persistChildren(writer, model);
   }
   writer.writeEndElement();
   if (writeWrapper) {
     writer.writeEndElement();
   }
 }
コード例 #15
0
  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();
    }
  }
コード例 #16
0
 private void addPaths(Map<String, ModelNode> map, ModelNode path) {
   if (path.isDefined()) {
     for (Property prop : path.asPropertyList()) {
       // TODO merge rather than replace existing?
       map.put(prop.getName(), prop.getValue());
     }
   }
 }
コード例 #17
0
 private Map<String, ModelNode> getSortedEntryMap(ModelNode parent, String name) {
   if (!parent.hasDefined(name)) {
     return Collections.emptyMap();
   }
   Map<String, ModelNode> sorted = new TreeMap<String, ModelNode>();
   for (Property prop : parent.get(name).asPropertyList()) {
     sorted.put(prop.getName(), prop.getValue());
   }
   return sorted;
 }
コード例 #18
0
 private void addSchemaLocations(Map<String, ModelNode> map, ModelNode namespaces) {
   if (namespaces.isDefined()) {
     for (Property prop : namespaces.asPropertyList()) {
       map.put(
           prop.getName(),
           SchemaLocationAddHandler.getAddSchemaLocationOperation(
               EMPTY, prop.getName(), prop.getValue().asString()));
     }
   }
 }
コード例 #19
0
 static void addConnectorServiceConfigs(final Configuration configuration, final ModelNode model)
     throws OperationFailedException {
   if (model.hasDefined(CommonAttributes.CONNECTOR_SERVICE)) {
     final List<ConnectorServiceConfiguration> configs =
         configuration.getConnectorServiceConfigurations();
     for (Property prop : model.get(CommonAttributes.CONNECTOR_SERVICE).asPropertyList()) {
       configs.add(createConnectorServiceConfiguration(prop.getName(), prop.getValue()));
     }
   }
 }
コード例 #20
0
 private Map<String, ModelNode> createMapIndexedByKey(ModelNode node) {
   Map<String, ModelNode> map = new HashMap<String, ModelNode>();
   if (!node.isDefined()) {
     return map;
   }
   for (Property prop : node.asPropertyList()) {
     map.put(prop.getName(), prop.getValue());
   }
   return map;
 }
コード例 #21
0
  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);
  }
コード例 #22
0
  private void writeWorkspaces(XMLExtendedStreamWriter writer, ModelNode repository)
      throws XMLStreamException {
    boolean started = false;
    // Write these model attributes of 'repository' onto the 'workspaces' XML element ...
    if (ModelAttributes.DEFAULT_WORKSPACE.isMarshallable(repository, false)) {
      started = startIfNeeded(writer, Element.WORKSPACES, started);
      ModelAttributes.DEFAULT_WORKSPACE.marshallAsAttribute(repository, writer);
    }
    if (ModelAttributes.ALLOW_WORKSPACE_CREATION.isMarshallable(repository, false)) {
      started = startIfNeeded(writer, Element.WORKSPACES, started);
      ModelAttributes.ALLOW_WORKSPACE_CREATION.marshallAsAttribute(repository, writer);
    }
    if (ModelAttributes.WORKSPACES_CACHE_CONTAINER.isMarshallable(repository, false)) {
      started = startIfNeeded(writer, Element.WORKSPACES, started);
      ModelAttributes.WORKSPACES_CACHE_CONTAINER.marshallAsAttribute(repository, writer);
    }
    if (has(repository, ModelKeys.PREDEFINED_WORKSPACE_NAMES)) {
      started = startIfNeeded(writer, Element.WORKSPACES, started);
      ModelNode names = repository.get(ModelKeys.PREDEFINED_WORKSPACE_NAMES);
      if (names.isDefined()) {
        Map<String, String> workspacesInitialContent = new HashMap<String, String>();
        if (has(repository, ModelKeys.WORKSPACES_INITIAL_CONTENT)) {
          List<ModelNode> initialContentNodes =
              repository.get(ModelKeys.WORKSPACES_INITIAL_CONTENT).asList();
          for (ModelNode modelNode : initialContentNodes) {
            Property property = modelNode.asProperty();
            workspacesInitialContent.put(property.getName(), property.getValue().asString());
          }
        }

        for (ModelNode workspace : repository.get(ModelKeys.PREDEFINED_WORKSPACE_NAMES).asList()) {
          writer.writeStartElement(Element.WORKSPACE.getLocalName());
          String name = workspace.asString();
          writer.writeAttribute(Attribute.NAME.getLocalName(), name);

          if (workspacesInitialContent.containsKey(name)) {
            writer.writeStartElement(Element.INITIAL_CONTENT.getLocalName());
            writer.writeCharacters(workspacesInitialContent.get(name));
            writer.writeEndElement();
          }

          writer.writeEndElement();
        }
      }
    }
    if (has(repository, ModelKeys.DEFAULT_INITIAL_CONTENT)) {
      started = startIfNeeded(writer, Element.WORKSPACES, started);
      writer.writeStartElement(Element.INITIAL_CONTENT.getLocalName());
      writer.writeCharacters(repository.get(ModelKeys.DEFAULT_INITIAL_CONTENT).asString());
      writer.writeEndElement();
    }
    if (started) {
      writer.writeEndElement();
    }
  }
コード例 #23
0
 private void writeProperties(final XMLExtendedStreamWriter writer, final ModelNode node)
     throws XMLStreamException {
   writer.writeStartElement(Element.PROPERTIES.getLocalName());
   for (Property prop : node.asPropertyList()) {
     writer.writeStartElement(Element.PROPERTY.getLocalName());
     writer.writeAttribute(Attribute.NAME.getLocalName(), prop.getName());
     PropertyResource.VALUE.marshallAsAttribute(prop.getValue(), writer);
     writer.writeEndElement();
   }
   writer.writeEndElement();
 }
コード例 #24
0
  private static void writeAcceptorContent(
      final XMLExtendedStreamWriter writer, final Property property) throws XMLStreamException {
    writer.writeAttribute(Attribute.NAME.getLocalName(), property.getName());
    final ModelNode value = property.getValue();

    RemoteTransportDefinition.SOCKET_BINDING.marshallAsAttribute(value, writer);
    InVMTransportDefinition.SERVER_ID.marshallAsAttribute(value, writer);
    CommonAttributes.FACTORY_CLASS.marshallAsElement(value, writer);

    writeTransportParam(writer, value.get(PARAM));
  }
コード例 #25
0
  public void addDeploymentOverlays(final List<ModelNode> updates) {
    if (domainModel.hasDefined(DEPLOYMENT_OVERLAY)) {

      HostFileRepository remoteRepository = null;
      if (!domainController.getLocalHostInfo().isMasterDomainController()) {
        remoteRepository = domainController.getRemoteFileRepository();
      }

      for (Property deploymentOverlay : domainModel.get(DEPLOYMENT_OVERLAY).asPropertyList()) {
        String name = deploymentOverlay.getName();
        ModelNode details = deploymentOverlay.getValue();

        PathAddress addr =
            PathAddress.pathAddress(PathElement.pathElement(DEPLOYMENT_OVERLAY, name));
        ModelNode addOp = Util.getEmptyOperation(ADD, addr.toModelNode());
        updates.add(addOp);

        if (details.hasDefined(CONTENT)) {

          for (Property content : details.get(CONTENT).asPropertyList()) {
            final String contentName = content.getName();
            final ModelNode contentDetails = content.getValue();
            byte[] hash = contentDetails.require(CONTENT).asBytes();
            File[] files = domainController.getLocalFileRepository().getDeploymentFiles(hash);
            if (files == null || files.length == 0) {
              if (remoteRepository != null) {
                remoteRepository.getDeploymentFiles(hash);
              }
            }
            addr =
                PathAddress.pathAddress(
                    PathElement.pathElement(DEPLOYMENT_OVERLAY, name),
                    PathElement.pathElement(CONTENT, contentName));
            addOp = Util.getEmptyOperation(ADD, addr.toModelNode());
            addOp.get(CONTENT).get(HASH).set(contentDetails.get(CONTENT));
            updates.add(addOp);
          }
        }
        if (serverGroup.hasDefined(DEPLOYMENT_OVERLAY)) {
          final ModelNode groupOverlay = serverGroup.get(DEPLOYMENT_OVERLAY).asObject();
          if (groupOverlay.has(name)) {
            ModelNode deploymentsNode = groupOverlay.get(name);
            if (deploymentsNode.has(DEPLOYMENT)) {
              for (Property content : deploymentsNode.get(DEPLOYMENT).asPropertyList()) {
                final String deploymentName = content.getName();
                final ModelNode deploymentDetails = content.getValue();
                addr =
                    PathAddress.pathAddress(
                        PathElement.pathElement(DEPLOYMENT_OVERLAY, name),
                        PathElement.pathElement(DEPLOYMENT, deploymentName));
                addOp = Util.getEmptyOperation(ADD, addr.toModelNode());
                updates.add(addOp);
              }
            }
          }
        }
      }
    }
  }
コード例 #26
0
 private void writeStoreProperties(XMLExtendedStreamWriter writer, ModelNode store)
     throws XMLStreamException {
   if (store.hasDefined(ModelKeys.PROPERTY)) {
     for (Property property : store.get(ModelKeys.PROPERTY).asPropertyList()) {
       writer.writeStartElement(Element.PROPERTY.getLocalName());
       writer.writeAttribute(Attribute.NAME.getLocalName(), property.getName());
       writer.writeCharacters(property.getValue().asString());
       writer.writeEndElement();
     }
   }
 }
コード例 #27
0
  /** {@inheritDoc} */
  @Override
  public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context)
      throws XMLStreamException {
    context.startSubsystemElement(Namespace.CURRENT.getUriString(), false);
    final ModelNode model = context.getModelNode();

    writeWorkerThreadPoolIfAttributesSet(writer, model);

    if (model.hasDefined(CONNECTOR)) {
      final ModelNode connector = model.get(CONNECTOR);
      for (String name : connector.keys()) {
        writeConnector(writer, connector.require(name), name);
      }
    }
    if (model.hasDefined(OUTBOUND_CONNECTION)
        || model.hasDefined(REMOTE_OUTBOUND_CONNECTION)
        || model.hasDefined(LOCAL_OUTBOUND_CONNECTION)) {
      // write <outbound-connections> element
      writer.writeStartElement(Element.OUTBOUND_CONNECTIONS.getLocalName());

      if (model.hasDefined(OUTBOUND_CONNECTION)) {
        final List<Property> outboundConnections = model.get(OUTBOUND_CONNECTION).asPropertyList();
        for (Property property : outboundConnections) {
          final String connectionName = property.getName();
          // get the specific outbound-connection
          final ModelNode genericOutboundConnectionModel = property.getValue();
          // process and write outbound connection
          this.writeOutboundConnection(writer, connectionName, genericOutboundConnectionModel);
        }
      }
      if (model.hasDefined(REMOTE_OUTBOUND_CONNECTION)) {
        final List<Property> remoteOutboundConnections =
            model.get(REMOTE_OUTBOUND_CONNECTION).asPropertyList();
        for (Property property : remoteOutboundConnections) {
          final String connectionName = property.getName();
          // get the specific remote outbound connection
          final ModelNode remoteOutboundConnectionModel = property.getValue();
          // process and write remote outbound connection
          this.writeRemoteOutboundConnection(writer, connectionName, remoteOutboundConnectionModel);
        }
      }
      if (model.hasDefined(LOCAL_OUTBOUND_CONNECTION)) {
        final List<Property> localOutboundConnections =
            model.get(LOCAL_OUTBOUND_CONNECTION).asPropertyList();
        for (Property property : localOutboundConnections) {
          final String connectionName = property.getName();
          // get the specific local outbound connection
          final ModelNode localOutboundConnectionModel = property.getValue();
          // process and write local outbound connection
          this.writeLocalOutboundConnection(writer, connectionName, localOutboundConnectionModel);
        }
      }
      // </outbound-connections>
      writer.writeEndElement();
    }

    writer.writeEndElement();
  }
コード例 #28
0
    /** {@inheritDoc} */
    @Override
    public void writeContent(XMLExtendedStreamWriter writer, SubsystemMarshallingContext context)
        throws XMLStreamException {
      context.startSubsystemElement(Namespace.CURRENT.getUriString(), false);
      ModelNode scanners = context.getModelNode();
      for (final Property list : scanners.asPropertyList()) {
        final ModelNode node = list.getValue();

        for (final Property scanner : node.asPropertyList()) {

          writer.writeEmptyElement(Element.DEPLOYMENT_SCANNER.getLocalName());
          writer.writeAttribute(Attribute.NAME.getLocalName(), scanner.getName());
          ModelNode configuration = scanner.getValue();
          if (configuration.hasDefined(CommonAttributes.PATH)) {
            writer.writeAttribute(
                Attribute.PATH.getLocalName(), configuration.get(CommonAttributes.PATH).asString());
          }
          if (configuration.hasDefined(CommonAttributes.SCAN_ENABLED)) {
            writer.writeAttribute(
                Attribute.SCAN_ENABLED.getLocalName(),
                configuration.get(CommonAttributes.SCAN_ENABLED).asString());
          }
          if (configuration.hasDefined(CommonAttributes.SCAN_INTERVAL)) {
            writer.writeAttribute(
                Attribute.SCAN_INTERVAL.getLocalName(),
                configuration.get(CommonAttributes.SCAN_INTERVAL).asString());
          }
          if (configuration.hasDefined(CommonAttributes.RELATIVE_TO)) {
            writer.writeAttribute(
                Attribute.RELATIVE_TO.getLocalName(),
                configuration.get(CommonAttributes.RELATIVE_TO).asString());
          }
          if (configuration.hasDefined(CommonAttributes.AUTO_DEPLOY_ZIPPED)) {
            if (!configuration.get(CommonAttributes.AUTO_DEPLOY_ZIPPED).asBoolean()) {
              writer.writeAttribute(
                  Attribute.AUTO_DEPLOY_ZIPPED.getLocalName(), Boolean.FALSE.toString());
            }
          }
          if (configuration.hasDefined(CommonAttributes.AUTO_DEPLOY_EXPLODED)) {
            if (configuration.get(CommonAttributes.AUTO_DEPLOY_EXPLODED).asBoolean()) {
              writer.writeAttribute(
                  Attribute.AUTO_DEPLOY_EXPLODED.getLocalName(), Boolean.TRUE.toString());
            }
          }
          if (configuration.hasDefined(CommonAttributes.DEPLOYMENT_TIMEOUT)) {
            writer.writeAttribute(
                Attribute.DEPLOYMENT_TIMEOUT.getLocalName(),
                configuration.get(CommonAttributes.DEPLOYMENT_TIMEOUT).asString());
          }
        }
        writer.writeEndElement();
      }
    }
コード例 #29
0
 public Map<String, String> unwrap(final OperationContext context, final ModelNode model)
     throws OperationFailedException {
   if (!model.hasDefined(getName())) {
     return new HashMap<String, String>();
   }
   ModelNode modelProps = model.get(getName());
   Map<String, String> props = new HashMap<String, String>();
   for (Property p : modelProps.asPropertyList()) {
     props.put(p.getName(), context.resolveExpressions(p.getValue()).asString());
   }
   return props;
 }
コード例 #30
0
ファイル: DomainXml.java プロジェクト: rodzyn0688/jboss-as
  private void writeServerGroup(
      final XMLExtendedStreamWriter writer, final String groupName, final ModelNode group)
      throws XMLStreamException {
    writer.writeStartElement(Element.SERVER_GROUP.getLocalName());
    writer.writeAttribute(Attribute.NAME.getLocalName(), groupName);
    writer.writeAttribute(Attribute.PROFILE.getLocalName(), group.get(PROFILE).asString());

    // JVM
    if (group.hasDefined(JVM)) {
      for (final Property jvm : group.get(JVM).asPropertyList()) {
        JvmXml.writeJVMElement(writer, jvm.getName(), jvm.getValue());
        break; // TODO just write the first !?
      }
    }

    // Socket binding ref
    String bindingGroupRef =
        group.hasDefined(SOCKET_BINDING_GROUP) ? group.get(SOCKET_BINDING_GROUP).asString() : null;
    String portOffset =
        group.hasDefined(SOCKET_BINDING_PORT_OFFSET)
            ? group.get(SOCKET_BINDING_PORT_OFFSET).asString()
            : null;
    Boolean managementSubsystemEndpoint =
        group.hasDefined(MANAGEMENT_SUBSYSTEM_ENDPOINT)
            ? group.get(MANAGEMENT_SUBSYSTEM_ENDPOINT).asBoolean()
            : null;
    if (bindingGroupRef != null || portOffset != null) {
      writer.writeStartElement(Element.SOCKET_BINDING_GROUP.getLocalName());
      if (bindingGroupRef != null) {
        writeAttribute(writer, Attribute.REF, bindingGroupRef);
      }
      if (portOffset != null) {
        writeAttribute(writer, Attribute.PORT_OFFSET, portOffset);
      }
      if (managementSubsystemEndpoint != null) {
        writeAttribute(
            writer,
            Attribute.MANAGEMENT_SUBSYSTEM_ENDPOINT,
            managementSubsystemEndpoint.toString());
      }
      writer.writeEndElement();
    }

    if (group.hasDefined(DEPLOYMENT)) {
      writeServerGroupDeployments(writer, group.get(DEPLOYMENT));
    }
    // System properties
    if (group.hasDefined(SYSTEM_PROPERTY)) {
      writeProperties(writer, group.get(SYSTEM_PROPERTY), Element.SYSTEM_PROPERTIES, false);
    }

    writer.writeEndElement();
  }