private void writeApplicationSecurityDomain(final XMLExtendedStreamWriter writer, final Property property) throws XMLStreamException { writer.writeStartElement(APPLICATION_SECURITY_DOMAIN); writer.writeAttribute(EJB3SubsystemXMLAttribute.NAME.getLocalName(), property.getName()); ApplicationSecurityDomainDefinition.SECURITY_DOMAIN.marshallAsAttribute(property.getValue(), writer); ApplicationSecurityDomainDefinition.ENABLE_JACC.marshallAsAttribute(property.getValue(), writer); writer.writeEndElement(); }
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 void writeStrictMaxPoolConfig(final XMLExtendedStreamWriter writer, final Property strictMaxPoolModel) throws XMLStreamException { // write the "name" attribute of the pool final ModelNode strictMaxPoolModelNode = strictMaxPoolModel.getValue(); writer.writeAttribute(EJB3SubsystemXMLAttribute.NAME.getLocalName(), strictMaxPoolModel.getName()); StrictMaxPoolResourceDefinition.MAX_POOL_SIZE.marshallAsAttribute(strictMaxPoolModelNode, writer); StrictMaxPoolResourceDefinition.DERIVE_SIZE.marshallAsAttribute(strictMaxPoolModelNode, writer); StrictMaxPoolResourceDefinition.INSTANCE_ACQUISITION_TIMEOUT.marshallAsAttribute(strictMaxPoolModelNode, writer); StrictMaxPoolResourceDefinition.INSTANCE_ACQUISITION_TIMEOUT_UNIT.marshallAsAttribute(strictMaxPoolModelNode, writer); }
@Override protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model) throws OperationFailedException { String acquisitionName = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.ADDRESS)).getLastElement().getValue(); MscRuntimeContainerJobExecutor mscRuntimeContainerJobExecutor = new MscRuntimeContainerJobExecutor(); if (model.hasDefined(SubsystemAttributeDefinitons.PROPERTIES.getName())) { List<Property> properties = SubsystemAttributeDefinitons.PROPERTIES.resolveModelAttribute(context, model).asPropertyList(); for (Property property : properties) { PropertyHelper.applyProperty(mscRuntimeContainerJobExecutor, property.getName(), property.getValue().asString()); } } // start new service for job executor ServiceController<RuntimeContainerJobExecutor> serviceController = context.getServiceTarget().addService(ServiceNames.forMscRuntimeContainerJobExecutorService(acquisitionName), mscRuntimeContainerJobExecutor) .addDependency(ServiceNames.forMscRuntimeContainerDelegate()) .addDependency(ServiceNames.forMscExecutorService()) .setInitialMode(Mode.ACTIVE) .install(); }
private void writeNewConfigProperties(XMLExtendedStreamWriter streamWriter, ModelNode ra) throws XMLStreamException { if (ra.hasDefined(CONFIG_PROPERTIES.getName())) { for (Property connectionProperty : ra.get(CONFIG_PROPERTIES.getName()).asPropertyList()) { writeProperty(streamWriter, ra, connectionProperty.getName(), connectionProperty .getValue().get("value").asString(), Activation.Tag.CONFIG_PROPERTY.getLocalName()); } } }
@Override public OperationStepHandler apply(OperationStepHandler handler) { return (context, operation) -> { if (operation.hasDefined(this.attribute.getName())) { // Translate deprecated table attribute into separate add table operation ModelNode addTableOperation = Util.createAddOperation(context.getCurrentAddress().append(this.path)); ModelNode parameters = operation.get(this.attribute.getName()); for (Property parameter : parameters.asPropertyList()) { addTableOperation.get(parameter.getName()).set(parameter.getValue()); } context.addStep(addTableOperation, context.getResourceRegistration().getOperationHandler(PathAddress.pathAddress(this.path), ModelDescriptionConstants.ADD), context.getCurrentStage()); } handler.execute(context, operation); }; }
private void writeLoginModule(XMLExtendedStreamWriter writer, ModelNode modelNode, String key, final String elementName) throws XMLStreamException { if (!modelNode.hasDefined(key)){ return; } final ModelNode modules = modelNode.get(key); for (Property moduleProp : modules.asPropertyList()) { ModelNode module = moduleProp.getValue(); writer.writeStartElement(elementName); if (!moduleProp.getName().equals(module.get(CODE).asString())) { writer.writeAttribute(NAME, moduleProp.getName()); } LoginModuleResourceDefinition.CODE.marshallAsAttribute(module, writer); LoginModuleResourceDefinition.FLAG.marshallAsAttribute(module, writer); MappingModuleDefinition.TYPE.marshallAsAttribute(module, writer); JASPIMappingModuleDefinition.LOGIN_MODULE_STACK_REF.marshallAsAttribute(module, writer); LoginModuleResourceDefinition.MODULE.marshallAsAttribute(module, false, writer); if (module.hasDefined(Constants.MODULE_OPTIONS)) { for (ModelNode option : module.get(Constants.MODULE_OPTIONS).asList()) { writer.writeEmptyElement(Element.MODULE_OPTION.getLocalName()); writer.writeAttribute(Attribute.NAME.getLocalName(), option.asProperty().getName()); writer.writeAttribute(Attribute.VALUE.getLocalName(), option.asProperty().getValue().asString()); } } writer.writeEndElement(); } }
@Override public ModelNode transformOperation(ModelNode operation) { if (operation.hasDefined(PROPERTIES)) { final ModelNode addOperation = operation.clone(); List<Property> properties = addOperation.remove(PROPERTIES).asPropertyList(); List<ModelNode> operations = new ArrayList<>(properties.size() + 1); operations.add(addOperation); PathAddress address = this.addressResolver.apply(addOperation); for (final Property property : properties) { String key = property.getName(); ModelNode value = property.getValue(); ModelNode propertyAddOperation = Util.createAddOperation(address.append(PathElement.pathElement(PROPERTY, key))); propertyAddOperation.get(VALUE).set(value); operations.add(propertyAddOperation); } return Operations.createCompositeOperation(operations); } return operation; } }
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); } } }
@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); } }
@Override public TransformedOperation transformOperation(TransformationContext context, PathAddress address, ModelNode operation) throws OperationFailedException { if (operation.get(NAME).asString().equals(PROPERTIES)) { ModelNode newValue = context.readResourceFromRoot(resolvedAddress).getModel().get(PROPERTIES).clone(); if (initialValue.equals(newValue) || (initialValue.isDefined() && initialValue.asPropertyList().isEmpty() && !newValue.isDefined())) { if (initialValue.isDefined()) { for (Property property : initialValue.asPropertyList()) { oldMap.put(property.getName(), property.getValue()); if (newValue.isDefined()) { for (Property property : newValue.asPropertyList()) { String key = property.getName(); ModelNode value = property.getValue(); ModelNode addOp = Util.createAddOperation(legacyAddress.append(PathElement.pathElement(PROPERTY, key))); addOp.get(VALUE).set(value); operations.add(addOp); if (!oldPropValue.equals(value)) { ModelNode writeOp = Util.getWriteAttributeOperation(legacyAddress.append(PathElement.pathElement(PROPERTY, key)), VALUE, value); operations.add(writeOp); ModelNode removeOperation = Util.createRemoveOperation(legacyAddress.append(PathElement.pathElement(PROPERTY, prop.getKey()))); operations.add(removeOperation);
protected void installServices(final OperationContext context, final PathAddress address, final ModelNode profileNode) throws OperationFailedException { try { final String profileName = address.getLastElement().getValue(); final ServiceName profileServiceName = RemotingProfileService.BASE_SERVICE_NAME.append(profileName); final ModelNode staticEjbDiscoery = StaticEJBDiscoveryDefinition.INSTANCE.resolveModelAttribute(context, profileNode); final RemotingProfileService profileService = new RemotingProfileService(urls, map); final ServiceBuilder<RemotingProfileService> builder = context.getServiceTarget().addService(profileServiceName, profileService); if (profileNode.hasDefined(EJB3SubsystemModel.REMOTING_EJB_RECEIVER)) { for (final Property receiverProperty : profileNode.get(EJB3SubsystemModel.REMOTING_EJB_RECEIVER) .asPropertyList()) { final ModelNode receiverNode = receiverProperty.getValue(); final String connectionRef = RemotingEjbReceiverDefinition.OUTBOUND_CONNECTION_REF.resolveModelAttribute(context, receiverNode).asString(); final long timeout = RemotingEjbReceiverDefinition.CONNECT_TIMEOUT.resolveModelAttribute(context, receiverNode).asLong(); .resolveModelAttribute(context, profileNode).asBoolean();
public void installRuntimeServices(OperationContext context, ModelNode model, String name) throws OperationFailedException { final ModelNode fullModel = Resource.Tools.readModel(context.readResource(PathAddress.EMPTY_ADDRESS), 2); final SessionCookieConfig config = SessionCookieDefinition.INSTANCE.getConfig(context, fullModel.get(SessionCookieDefinition.INSTANCE.getPathElement().getKeyValuePair())); final CrawlerSessionManagerConfig crawlerSessionManagerConfig = CrawlerSessionManagementDefinition.INSTANCE.getConfig(context, fullModel.get(CrawlerSessionManagementDefinition.INSTANCE.getPathElement().getKeyValuePair())); final boolean persistentSessions = PersistentSessionsDefinition.isEnabled(context, fullModel.get(PersistentSessionsDefinition.INSTANCE.getPathElement().getKeyValuePair())); final boolean allowNonStandardWrappers = ServletContainerDefinition.ALLOW_NON_STANDARD_WRAPPERS.resolveModelAttribute(context, model).asBoolean(); final boolean proactiveAuth = ServletContainerDefinition.PROACTIVE_AUTHENTICATION.resolveModelAttribute(context, model).asBoolean(); final String bufferCache = ServletContainerDefinition.DEFAULT_BUFFER_CACHE.resolveModelAttribute(context, model).asString(); final boolean disableFileWatchService = ServletContainerDefinition.DISABLE_FILE_WATCH_SERVICE.resolveModelAttribute(context, model).asBoolean(); final boolean disableSessionIdReususe = ServletContainerDefinition.DISABLE_SESSION_ID_REUSE.resolveModelAttribute(context, model).asBoolean(); JSPConfig jspConfig = JspDefinition.INSTANCE.getConfig(context, fullModel.get(JspDefinition.INSTANCE.getPathElement().getKeyValuePair())); final String stackTracesString = ServletContainerDefinition.STACK_TRACE_ON_ERROR.resolveModelAttribute(context, model).asString(); final ModelNode defaultEncodingValue = ServletContainerDefinition.DEFAULT_ENCODING.resolveModelAttribute(context, model); final String defaultEncoding = defaultEncodingValue.isDefined()? defaultEncodingValue.asString() : null; if (fullModel.hasDefined(Constants.MIME_MAPPING)) { for (final Property mapping : fullModel.get(Constants.MIME_MAPPING).asPropertyList()) { mimeMappings.put(mapping.getName(), MimeMappingDefinition.VALUE.resolveModelAttribute(context, mapping.getValue()).asString()); if (fullModel.hasDefined(Constants.WELCOME_FILE)) { for (final Property welcome : fullModel.get(Constants.WELCOME_FILE).asPropertyList()) { welcomeFiles.add(welcome.getName()); final CapabilityServiceBuilder<ServletContainerService> builder = context.getCapabilityServiceTarget() .addCapability(ServletContainerDefinition.SERVLET_CONTAINER_CAPABILITY, container); if(bufferCache != null) {
private ModelNode unmaskUsersPasswords(OperationContext context, ModelNode users) throws OperationFailedException { users = users.clone(); for (Property property : users.get(USER).asPropertyList()) { // Don't use the value from property as it is a clone and does not update the returned users ModelNode. ModelNode user = users.get(USER, property.getName()); if (user.hasDefined(PASSWORD)) { //TODO This will be cleaned up once it uses attribute definitions user.set(PASSWORD, context.resolveExpressions(user.get(PASSWORD)).asString()); } } return users; }
public static Map<PathAddress, ModelVersion> resolveVersions(final ModelNode subsystems) { final PathAddress base = PathAddress.EMPTY_ADDRESS; final Map<PathAddress, ModelVersion> versions = new HashMap<PathAddress, ModelVersion>(); for(final Property property : subsystems.asPropertyList()) { final String name = property.getName(); final PathAddress address = base.append(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, name)); versions.put(address, ModelVersion.fromString(property.getValue().asString())); } return versions; }
private OptionMap getChannelCreationOptions(final OperationContext context) throws OperationFailedException { // read the full model of the current resource final ModelNode fullModel = Resource.Tools.readModel(context.readResource(PathAddress.EMPTY_ADDRESS)); final ModelNode channelCreationOptions = fullModel.get(EJB3SubsystemModel.CHANNEL_CREATION_OPTIONS); if (channelCreationOptions.isDefined() && channelCreationOptions.asInt() > 0) { final ClassLoader loader = this.getClass().getClassLoader(); final OptionMap.Builder builder = OptionMap.builder(); for (final Property optionProperty : channelCreationOptions.asPropertyList()) { final String name = optionProperty.getName(); final ModelNode propValueModel = optionProperty.getValue(); final String type = RemoteConnectorChannelCreationOptionResource.CHANNEL_CREATION_OPTION_TYPE.resolveModelAttribute(context,propValueModel).asString(); final String optionClassName = this.getClassNameForChannelOptionType(type); final String fullyQualifiedOptionName = optionClassName + "." + name; final Option option = Option.fromString(fullyQualifiedOptionName, loader); final String value = RemoteConnectorChannelCreationOptionResource.CHANNEL_CREATION_OPTION_VALUE.resolveModelAttribute(context, propValueModel).asString(); builder.set(option, option.parseValue(value, loader)); } return builder.getMap(); } return OptionMap.EMPTY; }
void updateConfig(ModelNode operation, ModelNode config) { PathAddress address = PathAddress.pathAddress(operation.get(ADDRESS)); address = address.subAddress(1); // remove root (subsystem=keycloak-server) ModelNode newConfig = fullConfig.clone(); ModelNode subNode = newConfig; for (PathElement pathElement : address) { subNode = subNode.get(pathElement.getKey(), pathElement.getValue()); } subNode.set(config.clone()); // remove undefined properties for (Property prop : subNode.asPropertyList()) { if (!prop.getValue().isDefined()) { subNode.remove(prop.getName()); } } fullConfig = newConfig; }
private void writeWorkManagers(XMLExtendedStreamWriter writer, ModelNode parentNode) throws XMLStreamException { List<Property> workManagers; if (parentNode.hasDefined(WORKMANAGER) && (workManagers = parentNode.get(WORKMANAGER).asPropertyList()).size() != 0) { List<ModelNode> defaultFirst = new ArrayList<>(); for (Property prop : workManagers) { ModelNode workManager = prop.getValue(); if ("default".equals(workManager.get(NAME).asString())) { defaultFirst.add(0, workManager); ModelNode workManager = defaultFirst.get(i); if (i == 0 && "default".equals(workManager.get(NAME).asString())) { writer.writeStartElement(Element.DEFAULT_WORKMANAGER.getLocalName()); } else { writer.writeStartElement(Element.WORKMANAGER.getLocalName()); JcaWorkManagerDefinition.WmParameters.NAME.getAttribute().marshallAsAttribute(workManager, writer); JcaWorkManagerDefinition.WmParameters.ELYTRON_ENABLED.getAttribute().marshallAsElement(workManager, writer); if (workManager.hasDefined(WORKMANAGER_SHORT_RUNNING)) { ThreadsParser.getInstance().writeBoundedQueueThreadPool(writer, workManager.get(WORKMANAGER_LONG_RUNNING).asProperty(), Element.LONG_RUNNING_THREADS.getLocalName(), false, true); writer.writeEndElement();
@Override protected void executeRuntimeStep(OperationContext operationContext, ModelNode modelNode) throws OperationFailedException { ModelNode result = new ModelNode(); SessionManager sessionManager = getSessionManager(operationContext, modelNode); String name = modelNode.get(OP).asString(); result.add(s); operationContext.getResult().set(result); return; m.set(attribute.toString()); result.add(new Property(s, m)); operationContext.getResult().set(result);
public static void createServerAddOperations(List<ModelNode> addOps, PathAddress loggerAddress, ModelNode logger) { addOps.add(createLoggerAddOperation(loggerAddress, logger)); final String handler = AuditLogHandlerReferenceResourceDefinition.PATH_ELEMENT.getKey(); if (logger.hasDefined(handler)){ for (Property prop : logger.get(handler).asPropertyList()) { addOps.add(Util.createAddOperation(loggerAddress.append(PathElement.pathElement(handler, prop.getName())))); } } }