use of org.jboss.dmr.ModelNode in project wildfly by wildfly.
the class WebExtension method registerTransformers_2_x_0.
//todo, could probably be removed as 2_x was never in EAP 6.x
private void registerTransformers_2_x_0(SubsystemRegistration registration, int minor) {
final ResourceTransformationDescriptionBuilder subsystemRoot = TransformationDescriptionBuilder.Factory.createSubsystemInstance();
subsystemRoot.getAttributeBuilder().addRejectCheck(RejectAttributeChecker.DEFINED, WebDefinition.DEFAULT_SESSION_TIMEOUT).setDiscard(new DiscardAttributeChecker.DiscardAttributeValueChecker(false, true, new ModelNode(30)), WebDefinition.DEFAULT_SESSION_TIMEOUT).end();
final ResourceTransformationDescriptionBuilder hostBuilder = subsystemRoot.addChildResource(HOST_PATH);
final ResourceTransformationDescriptionBuilder ssoBuilder = hostBuilder.addChildResource(SSO_PATH);
ssoBuilder.getAttributeBuilder().addRejectCheck(RejectAttributeChecker.DEFINED, WebSSODefinition.HTTP_ONLY).setDiscard(new DiscardAttributeChecker.DiscardAttributeValueChecker(false, true, new ModelNode(true)), WebSSODefinition.HTTP_ONLY).end();
if (minor == 0) {
final ResourceTransformationDescriptionBuilder connectorBuilder = subsystemRoot.addChildResource(CONNECTOR_PATH);
connectorBuilder.getAttributeBuilder().addRejectCheck(RejectAttributeChecker.DEFINED, WebConnectorDefinition.PROXY_BINDING, WebConnectorDefinition.REDIRECT_BINDING).setDiscard(DiscardAttributeChecker.UNDEFINED, WebSSLDefinition.SSL_PROTOCOL, WebConnectorDefinition.PROXY_BINDING, WebConnectorDefinition.REDIRECT_BINDING).end();
connectorBuilder.addChildResource(SSL_PATH).getAttributeBuilder().addRejectCheck(RejectAttributeChecker.UNDEFINED, WebSSLDefinition.CIPHER_SUITE).end();
}
TransformationDescription.Tools.register(subsystemRoot.build(), registration, ModelVersion.create(2, minor, 0));
}
use of org.jboss.dmr.ModelNode in project wildfly by wildfly.
the class WebExtension method registerTransformers_1_4_0.
private void registerTransformers_1_4_0(SubsystemRegistration registration) {
final ResourceTransformationDescriptionBuilder subsystemRoot = TransformationDescriptionBuilder.Factory.createSubsystemInstance();
subsystemRoot.getAttributeBuilder().addRejectCheck(RejectAttributeChecker.DEFINED, WebDefinition.DEFAULT_SESSION_TIMEOUT).setDiscard(new DiscardAttributeChecker.DiscardAttributeValueChecker(false, true, new ModelNode(30)), WebDefinition.DEFAULT_SESSION_TIMEOUT).end();
final ResourceTransformationDescriptionBuilder hostBuilder = subsystemRoot.addChildResource(HOST_PATH);
final ResourceTransformationDescriptionBuilder ssoBuilder = hostBuilder.addChildResource(SSO_PATH);
ssoBuilder.getAttributeBuilder().addRejectCheck(RejectAttributeChecker.DEFINED, WebSSODefinition.HTTP_ONLY).setDiscard(new DiscardAttributeChecker.DiscardAttributeValueChecker(false, true, new ModelNode(true)), WebSSODefinition.HTTP_ONLY).end();
TransformationDescription.Tools.register(subsystemRoot.build(), registration, ModelVersion.create(1, 4, 0));
}
use of org.jboss.dmr.ModelNode in project wildfly by wildfly.
the class WebMigrateOperation method migrateVirtualHostChildren.
private void migrateVirtualHostChildren(Map<PathAddress, ModelNode> newAddOperations, Set<String> hosts) {
final PathAddress customFilterAddresses = pathAddress(UndertowExtension.SUBSYSTEM_PATH, PATH_FILTERS, pathElement(CustomFilterDefinition.INSTANCE.getPathElement().getKey()));
final PathAddress expressionFilterAddresses = pathAddress(UndertowExtension.SUBSYSTEM_PATH, PATH_FILTERS, pathElement(ExpressionFilterDefinition.INSTANCE.getPathElement().getKey()));
List<PathAddress> filterAddresses = new ArrayList<>();
for (PathAddress a : newAddOperations.keySet()) {
if (wildcardEquals(customFilterAddresses, a) || wildcardEquals(expressionFilterAddresses, a)) {
filterAddresses.add(a);
}
}
boolean hasAccessLogValve = newAddOperations.containsKey(VALVE_ACCESS_LOG_ADDRESS);
if (hasAccessLogValve || !filterAddresses.isEmpty()) {
for (String host : hosts) {
PathAddress hostAddress = pathAddress(UndertowExtension.SUBSYSTEM_PATH, DEFAULT_SERVER_PATH, pathElement(Constants.HOST, host));
for (PathAddress filterAddress : filterAddresses) {
PathAddress filterRefAddress = pathAddress(hostAddress, pathElement(Constants.FILTER_REF, filterAddress.getLastElement().getValue()));
ModelNode filterRefAdd = createAddOperation(filterRefAddress);
newAddOperations.put(filterRefAddress, filterRefAdd);
}
if (hasAccessLogValve) {
PathAddress accessLogAddress = pathAddress(hostAddress, UndertowExtension.PATH_ACCESS_LOG);
if (!newAddOperations.containsKey(accessLogAddress)) {
ModelNode operation = newAddOperations.get(VALVE_ACCESS_LOG_ADDRESS).clone();
operation.get(OP_ADDR).set(accessLogAddress.toModelNode());
newAddOperations.put(accessLogAddress, operation);
}
}
}
}
}
use of org.jboss.dmr.ModelNode in project wildfly by wildfly.
the class WebMigrateOperation method migrateAccessLogValve.
private void migrateAccessLogValve(Map<PathAddress, ModelNode> newAddOperations, ModelNode newAddOp, String valveName, List<String> warnings) {
ModelNode add = createAddOperation(VALVE_ACCESS_LOG_ADDRESS);
final ModelNode params = newAddOp.get(WebValveDefinition.PARAMS.getName());
//TODO: parse the pattern and modify to Undertow version
final ModelNode patternNode = params.get(Constants.PATTERN);
if (patternNode.isDefined()) {
add.get(Constants.PATTERN).set(migrateAccessLogPattern(patternNode.asString()));
}
add.get(Constants.PREFIX).set(params.get(Constants.PREFIX).clone());
add.get(Constants.SUFFIX).set(params.get(Constants.SUFFIX).clone());
add.get(Constants.ROTATE).set(params.get("rotatable").clone());
add.get(Constants.EXTENDED).set(newAddOp.get(Constants.EXTENDED).clone());
if (params.hasDefined(Constants.DIRECTORY)) {
add.get(Constants.DIRECTORY).set(params.get(Constants.DIRECTORY).clone());
}
if (params.hasDefined("conditionIf")) {
add.get(Constants.PREDICATE).set("exists(%{r," + params.get("conditionIf").asString() + "})");
}
if (params.hasDefined("conditionUnless")) {
add.get(Constants.PREDICATE).set("not exists(%{r," + params.get("conditionUnless").asString() + "})");
}
if (params.hasDefined("condition")) {
add.get(Constants.PREDICATE).set("not exists(%{r," + params.get("condition").asString() + "})");
}
final String[] unsupportedConfigParams = new String[] { "resolveHosts", "fileDateFormat", "renameOnRotate", "encoding", "locale", "requestAttributesEnabled", "buffered" };
for (String unsupportedConfigParam : unsupportedConfigParams) {
if (params.hasDefined(unsupportedConfigParam)) {
warnings.add(WebLogger.ROOT_LOGGER.couldNotMigrateValveAttribute(unsupportedConfigParam, valveName));
}
}
newAddOperations.put(VALVE_ACCESS_LOG_ADDRESS, add);
}
use of org.jboss.dmr.ModelNode in project wildfly by wildfly.
the class WebMigrateOperation method createExpressionFilter.
private void createExpressionFilter(Map<PathAddress, ModelNode> newAddOperations, String name, String expression) {
newAddOperations.putIfAbsent(pathAddress(UndertowExtension.SUBSYSTEM_PATH, PATH_FILTERS), createAddOperation(pathAddress(UndertowExtension.SUBSYSTEM_PATH, PATH_FILTERS)));
PathAddress filterAddress = pathAddress(UndertowExtension.SUBSYSTEM_PATH, PATH_FILTERS, pathElement(ExpressionFilterDefinition.INSTANCE.getPathElement().getKey(), name));
ModelNode filterAdd = createAddOperation(filterAddress);
filterAdd.get(ExpressionFilterDefinition.EXPRESSION.getName()).set(expression);
newAddOperations.put(filterAddress, filterAdd);
}
Aggregations