private static void transformIorSettings(final ModelNode model, final ModelNode legacyValue) { for (final Property category : legacyValue.get(JacORBSubsystemConstants.DEFAULT).get(JacORBSubsystemConstants.SETTING) .asPropertyList()) { for (final Property property : category.getValue().asPropertyList()) { model.get(property.getName()).set(property.getValue()); } } } }
private void checkPropertiesWithExpression(final ModelNode legacyModel, final List<String> warnings) { final List<String> transformedExpressionProperties = new LinkedList<>(); for (Property property : legacyModel.asPropertyList()) { if (property.getValue().getType() == EXPRESSION && TRANSFORMED_PROPERTIES.contains(property.getName())) { transformedExpressionProperties.add(property.getName()); } } if (!transformedExpressionProperties.isEmpty()) { warnings.add(JacORBLogger.ROOT_LOGGER.expressionMigrationWarning(transformedExpressionProperties.toString())); } }
@Override public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException { this.moduleName = MODULE.resolveModelAttribute(context, model).asString(); this.properties.clear(); for (Property property : ModelNodes.optionalPropertyList(PROPERTIES.resolveModelAttribute(context, model)).orElse(Collections.emptyList())) { this.properties.put(property.getName(), property.getValue().asString()); } this.statisticsEnabled = STATISTICS_ENABLED.resolveModelAttribute(context, model).asBooleanOrNull(); return this; }
private void processLoginModules(OperationContext context, ModelNode node, BaseAuthenticationInfo authInfo, LoginModuleContainer container) throws OperationFailedException { for (Property moduleProperty : node.asPropertyList()) { ModelNode module = moduleProperty.getValue(); String codeName = extractCode(context, module, ModulesMap.AUTHENTICATION_MAP); String flag = LoginModuleResourceDefinition.FLAG.resolveModelAttribute(context, module).asString(); LoginModuleControlFlag controlFlag = getControlFlag(flag); Map<String, Object> options = extractOptions(context, module); AppConfigurationEntry entry = new AppConfigurationEntry(codeName, controlFlag, options); container.addAppConfigurationEntry(entry); ModelNode moduleName = LoginModuleResourceDefinition.MODULE.resolveModelAttribute(context, module); if (moduleName.isDefined() && !moduleName.asString().isEmpty()) { authInfo.addJBossModuleName(moduleName.asString()); } else { authInfo.addJBossModuleName(DEFAULT_MODULE); } } }
private void addCommonHostListenerDeps(OperationContext context, ServiceBuilder<WebServerService> builder, final PathElement listenerPath) { ModelNode listeners = Resource.Tools.readModel(context.readResource(PathAddress.pathAddress(listenerPath)), 1); if (listeners.isDefined()) { for (Property p : listeners.asPropertyList()) { for (Property listener : p.getValue().asPropertyList()) { builder.requires(ListenerResourceDefinition.LISTENER_CAPABILITY.getCapabilityServiceName(listener.getName())); } } } } }
private void writeExternalContext(final Property binding, final XMLExtendedStreamWriter writer) throws XMLStreamException { writer.writeStartElement(NamingSubsystemXMLElement.EXTERNAL_CONTEXT.getLocalName()); writer.writeAttribute(NamingSubsystemXMLAttribute.NAME.getLocalName(), binding.getName()); NamingBindingResourceDefinition.MODULE.marshallAsAttribute(binding.getValue(), writer); NamingBindingResourceDefinition.CLASS.marshallAsAttribute(binding.getValue(), writer); NamingBindingResourceDefinition.CACHE.marshallAsAttribute(binding.getValue(), writer); NamingBindingResourceDefinition.ENVIRONMENT.marshallAsElement(binding.getValue(), writer); writer.writeEndElement(); }
@SuppressWarnings("deprecation") private static void writeProtocolAttributes(XMLExtendedStreamWriter writer, Property property) throws XMLStreamException { writeGenericProtocolAttributes(writer, property); String protocol = property.getName(); if (containsName(ProtocolRegistration.MulticastProtocol.class, protocol)) { writeAttributes(writer, property.getValue(), SocketBindingProtocolResourceDefinition.Attribute.class); } else if (containsName(ProtocolRegistration.JdbcProtocol.class, protocol)) { writeAttributes(writer, property.getValue(), JDBCProtocolResourceDefinition.Attribute.class); } else if (containsName(ProtocolRegistration.EncryptProtocol.class, protocol)) { writeAttributes(writer, property.getValue(), EncryptProtocolResourceDefinition.Attribute.class); } else if (containsName(ProtocolRegistration.InitialHostsProtocol.class, protocol)) { writeAttributes(writer, property.getValue(), SocketDiscoveryProtocolResourceDefinition.Attribute.class); } else if (containsName(ProtocolRegistration.AuthProtocol.class, protocol)) { writeAuthToken(writer, property.getValue().get(AuthTokenResourceDefinition.WILDCARD_PATH.getKey()).asProperty()); } else { writeAttributes(writer, property.getValue(), GenericProtocolResourceDefinition.DeprecatedAttribute.class); } }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS); ModelNode authModules = Resource.Tools.readModel(resource).get(newKeyName); ModelNode result = new ModelNode(); if (authModules.isDefined()) { List<Property> loginModules = authModules.asPropertyList(); for (Property p : loginModules) { result.add(p.getValue()); } } context.getResult().set(result); } }
private Map<String, String> unwrap(final ModelNode model) { if (!model.hasDefined(PARAMETERS.getName())) { return Collections.emptyMap(); } ModelNode modelProps = model.get(PARAMETERS.getName()); Map<String, String> props = new HashMap<String, String>(); for (Property p : modelProps.asPropertyList()) { props.put(p.getName(), p.getValue().asString()); } return props; } }
private boolean processAudit(OperationContext context, String securityDomain, ModelNode node, ApplicationPolicy applicationPolicy) throws OperationFailedException { node = peek(node, AUDIT, CLASSIC, PROVIDER_MODULE); if (node == null) { return false; } AuditInfo auditInfo = new AuditInfo(securityDomain); for (Property moduleProperty : node.asPropertyList()) { ModelNode module = moduleProperty.getValue(); String codeName = MappingProviderModuleDefinition.CODE.resolveModelAttribute(context, module).asString(); Map<String, Object> options = extractOptions(context, module); AuditProviderEntry entry = new AuditProviderEntry(codeName, options); auditInfo.add(entry); ModelNode moduleName = MappingProviderModuleDefinition.MODULE.resolveModelAttribute(context, module); if (moduleName.isDefined() && !moduleName.asString().isEmpty()) { auditInfo.addJBossModuleName(moduleName.asString()); } else { auditInfo.addJBossModuleName(DEFAULT_MODULE); } } applicationPolicy.setAuditInfo(auditInfo); return true; }
private void writeLoginModuleStack(XMLExtendedStreamWriter writer, ModelNode modelNode) throws XMLStreamException { if (modelNode.isDefined() && modelNode.asInt() > 0) { List<Property> stacks = modelNode.asPropertyList(); for (Property stack : stacks) { writer.writeStartElement(Element.LOGIN_MODULE_STACK.getLocalName()); writer.writeAttribute(Attribute.NAME.getLocalName(), stack.getName()); writeLoginModule(writer, stack.getValue(), Constants.LOGIN_MODULE); writer.writeEndElement(); } } }
private static void writeAuthToken(XMLExtendedStreamWriter writer, Property token) throws XMLStreamException { writer.writeStartElement(XMLElement.forAuthTokenName(token.getName()).getLocalName()); if (PlainAuthTokenResourceDefinition.PATH.getValue().equals(token.getName())) { writeAttributes(writer, token.getValue(), AuthTokenResourceDefinition.Attribute.class); } if (DigestAuthTokenResourceDefinition.PATH.getValue().equals(token.getName())) { writeAttributes(writer, token.getValue(), Stream.concat(EnumSet.allOf(AuthTokenResourceDefinition.Attribute.class).stream(), EnumSet.allOf(DigestAuthTokenResourceDefinition.Attribute.class).stream())); } if (CipherAuthTokenResourceDefinition.PATH.getValue().equals(token.getName())) { writeAttributes(writer, token.getValue(), Stream.concat(EnumSet.allOf(AuthTokenResourceDefinition.Attribute.class).stream(), EnumSet.allOf(CipherAuthTokenResourceDefinition.Attribute.class).stream())); } writer.writeEndElement(); }
private static void readProperties(XMLExtendedStreamReader reader, ModelNode operation) throws XMLStreamException { while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { XMLElement element = XMLElement.forName(reader.getLocalName()); switch (element) { case PROPERTY: { Property property = ParseUtils.readProperty(reader, true); operation.get(LoadMetricResourceDefinition.SharedAttribute.PROPERTY.getName()).get(property.getName()).set(property.getValue()); break; } default: { throw unexpectedElement(reader); } } } }
@Override public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException { this.passivation = PASSIVATION.resolveModelAttribute(context, model).asBoolean(); this.fetchState = FETCH_STATE.resolveModelAttribute(context, model).asBoolean(); this.preload = PRELOAD.resolveModelAttribute(context, model).asBoolean(); this.purge = PURGE.resolveModelAttribute(context, model).asBoolean(); this.shared = SHARED.resolveModelAttribute(context, model).asBoolean(); this.maxBatchSize = MAX_BATCH_SIZE.resolveModelAttribute(context, model).asInt(); this.properties.clear(); for (Property property : ModelNodes.optionalPropertyList(PROPERTIES.resolveModelAttribute(context, model)).orElse(Collections.emptyList())) { this.properties.setProperty(property.getName(), property.getValue().asString()); } return this; }
private void addOpenjdkSubsystem(final PathAddress address, final ModelNode model, final Map<PathAddress, ModelNode> migrateOperations) { final ModelNode operation = Util.createAddOperation(address); for (final Property property : model.asPropertyList()) { if (property.getValue().isDefined()) { operation.get(property.getName()).set(property.getValue()); } } migrateOperations.put(address, operation); }
private boolean processIdentityTrust(OperationContext context, String securityDomain, ModelNode node, ApplicationPolicy applicationPolicy) throws OperationFailedException { node = peek(node, IDENTITY_TRUST, CLASSIC, TRUST_MODULE); if (node == null) { return false; } IdentityTrustInfo identityTrustInfo = new IdentityTrustInfo(securityDomain); for (Property moduleProperty : node.asPropertyList()) { ModelNode module = moduleProperty.getValue(); String codeName = LoginModuleResourceDefinition.CODE.resolveModelAttribute(context, module).asString(); String flag = LoginModuleResourceDefinition.FLAG.resolveModelAttribute(context, module).asString(); ControlFlag controlFlag = ControlFlag.valueOf(flag); Map<String, Object> options = extractOptions(context, module); IdentityTrustModuleEntry entry = new IdentityTrustModuleEntry(codeName, options); entry.setControlFlag(controlFlag); identityTrustInfo.add(entry); ModelNode moduleName = LoginModuleResourceDefinition.MODULE.resolveModelAttribute(context, module); if (moduleName.isDefined() && !moduleName.asString().isEmpty()) { identityTrustInfo.addJBossModuleName(moduleName.asString()); } else { identityTrustInfo.addJBossModuleName(DEFAULT_MODULE); } } applicationPolicy.setIdentityTrustInfo(identityTrustInfo); return true; }
private void writeManagedExecutorServices(final XMLExtendedStreamWriter writer, final ModelNode subModel) throws XMLStreamException { writer.writeStartElement(Element.MANAGED_EXECUTOR_SERVICES.getLocalName()); for (Property property : subModel.asPropertyList()) { writer.writeStartElement(Element.MANAGED_EXECUTOR_SERVICE.getLocalName()); writer.writeAttribute(Attribute.NAME.getLocalName(), property.getName()); for(SimpleAttributeDefinition ad : ManagedExecutorServiceResourceDefinition.ATTRIBUTES) { ad.marshallAsAttribute(property.getValue(), writer); } writer.writeEndElement(); } writer.writeEndElement(); }
private void writeObjectFactoryBinding(final Property binding, final XMLExtendedStreamWriter writer) throws XMLStreamException { writer.writeStartElement(NamingSubsystemXMLElement.OBJECT_FACTORY.getLocalName()); writer.writeAttribute(NamingSubsystemXMLAttribute.NAME.getLocalName(), binding.getName()); NamingBindingResourceDefinition.MODULE.marshallAsAttribute(binding.getValue(), writer); NamingBindingResourceDefinition.CLASS.marshallAsAttribute(binding.getValue(), writer); NamingBindingResourceDefinition.ENVIRONMENT.marshallAsElement(binding.getValue(), writer); writer.writeEndElement(); }
static Properties resolvePropertyValue(final OperationContext context, final ModelNode operation, final AttributeDefinition attribute) throws OperationFailedException { // Get the properties final Properties properties = new Properties(); if (operation.hasDefined(attribute.getName())) { for (Property p : resolveValue(context, operation, attribute).asPropertyList()) { properties.put(p.getName(), p.getValue().asString()); } } return properties; }
private boolean processACL(OperationContext context, String securityDomain, ModelNode node, ApplicationPolicy applicationPolicy) throws OperationFailedException { node = peek(node, ACL, CLASSIC, ACL_MODULE); if (node == null) { return false; } ACLInfo aclInfo = new ACLInfo(securityDomain); for (Property moduleProperty : node.asPropertyList()) { ModelNode module = moduleProperty.getValue(); String codeName = LoginModuleResourceDefinition.CODE.resolveModelAttribute(context, module).asString(); String flag = LoginModuleResourceDefinition.FLAG.resolveModelAttribute(context, module).asString(); ControlFlag controlFlag = ControlFlag.valueOf(flag); Map<String, Object> options = extractOptions(context, module); ACLProviderEntry entry = new ACLProviderEntry(codeName, options); entry.setControlFlag(controlFlag); aclInfo.add(entry); ModelNode moduleName = LoginModuleResourceDefinition.MODULE.resolveModelAttribute(context, module); if (moduleName.isDefined() && !moduleName.asString().isEmpty()) { aclInfo.addJBossModuleName(moduleName.asString()); } else { aclInfo.addJBossModuleName(DEFAULT_MODULE); } } applicationPolicy.setAclInfo(aclInfo); return true; }