}
private void registerTransformers_1_1_x(SubsystemRegistration registration, int micro) {
final int defaultRedirectPort = 443;
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();
// Discard valve
subsystemRoot.rejectChildResource(VALVE_PATH);
// Reject expressions for configuration
subsystemRoot.addChildResource(JSP_CONFIGURATION_PATH).getAttributeBuilder()
.addRejectCheck(RejectAttributeChecker.SIMPLE_EXPRESSIONS, WebJSPDefinition.JSP_ATTRIBUTES);
subsystemRoot.addChildResource(STATIC_RESOURCES_PATH).getAttributeBuilder()
.addRejectCheck(RejectAttributeChecker.SIMPLE_EXPRESSIONS, WebStaticResources.STATIC_ATTRIBUTES);
subsystemRoot.addChildResource(CONTAINER_PATH).getAttributeBuilder()
.addRejectCheck(RejectAttributeChecker.SIMPLE_EXPRESSIONS, WebContainerDefinition.CONTAINER_ATTRIBUTES);
final ResourceTransformationDescriptionBuilder connectorBuilder = subsystemRoot.addChildResource(CONNECTOR_PATH);
connectorBuilder.getAttributeBuilder()
.addRejectCheck(RejectAttributeChecker.SIMPLE_EXPRESSIONS, WebConnectorDefinition.CONNECTOR_ATTRIBUTES)
.setValueConverter(new AttributeConverter.DefaultAttributeConverter() {
@Override
protected void convertAttribute(PathAddress address, String attributeName, ModelNode attributeValue, TransformationContext context) {
if (!attributeValue.isDefined()) {
attributeValue.set(defaultRedirectPort);
}
}
}, WebConnectorDefinition.REDIRECT_PORT.getName())
.end()
.addOperationTransformationOverride(UNDEFINE_ATTRIBUTE_OPERATION)
.inheritResourceAttributeDefinitions() // although probably not necessary
.setCustomOperationTransformer(new OperationTransformer() {
@Override
public TransformedOperation transformOperation(TransformationContext context, PathAddress address, ModelNode operation) throws OperationFailedException {
final String attributeName = operation.require(NAME).asString();
if (WebConnectorDefinition.REDIRECT_PORT.getName().equals(attributeName)) {
final ModelNode transformed = new ModelNode();
transformed.get(OP).set(WRITE_ATTRIBUTE_OPERATION);
transformed.get(OP_ADDR).set(address.toModelNode());
transformed.get(NAME).set(attributeName);
transformed.get(VALUE).set(defaultRedirectPort);
return new TransformedOperation(transformed, OperationResultTransformer.ORIGINAL_RESULT);
}
return new TransformedOperation(operation, OperationResultTransformer.ORIGINAL_RESULT);
}
});
if (micro == 0) {
connectorBuilder.getAttributeBuilder().addRejectCheck(new RejectAttributeChecker.DefaultRejectAttributeChecker() {
@Override
protected boolean rejectAttribute(PathAddress address, String attributeName, ModelNode attributeValue, TransformationContext context) {
return attributeValue.isDefined();
}
@Override
public String getRejectionLogMessage(Map<String, ModelNode> attributes) {
return WebMessages.MESSAGES.transformationVersion_1_1_0_JBPAPP_9314();
}
}, Constants.VIRTUAL_SERVER);
}
//
connectorBuilder.addChildRedirection(SSL_PATH, SSL_ALIAS).getAttributeBuilder()
.addRejectCheck(RejectAttributeChecker.SIMPLE_EXPRESSIONS, WebSSLDefinition.SSL_ATTRIBUTES)
.addRejectCheck(RejectAttributeChecker.DEFINED, WebSSLDefinition.SSL_PROTOCOL)
.addRejectCheck(RejectAttributeChecker.UNDEFINED, WebSSLDefinition.CIPHER_SUITE)
.setDiscard(DiscardAttributeChecker.UNDEFINED, WebSSLDefinition.SSL_PROTOCOL)
.setValueConverter(new AttributeConverter.DefaultAttributeConverter() {
@Override
protected void convertAttribute(PathAddress address, String attributeName, ModelNode attributeValue, TransformationContext context) {
if (attributeValue.isDefined() && attributeValue.asString().equals(address.getLastElement().getKey())) {
attributeValue.clear();
}
}
}, WebSSLDefinition.NAME)
.end();
final ResourceTransformationDescriptionBuilder hostBuilder = subsystemRoot.addChildResource(HOST_PATH).getAttributeBuilder()
.addRejectCheck(RejectAttributeChecker.SIMPLE_EXPRESSIONS, WebVirtualHostDefinition.DEFAULT_WEB_MODULE)
.end();
final ResourceTransformationDescriptionBuilder rewriteBuilder = hostBuilder.addChildResource(REWRITE_PATH).getAttributeBuilder()
.addRejectCheck(RejectAttributeChecker.SIMPLE_EXPRESSIONS, WebReWriteDefinition.FLAGS, WebReWriteDefinition.PATTERN, WebReWriteDefinition.SUBSTITUTION)
.end();
rewriteBuilder.addChildResource(REWRITECOND_PATH).getAttributeBuilder()
.addRejectCheck(RejectAttributeChecker.SIMPLE_EXPRESSIONS, WebReWriteConditionDefinition.ATTRIBUTES)
.addRejectCheck(RejectAttributeChecker.UNDEFINED, WebReWriteConditionDefinition.FLAGS);
hostBuilder.addChildRedirection(SSO_PATH, SSO_ALIAS).getAttributeBuilder()
.addRejectCheck(RejectAttributeChecker.SIMPLE_EXPRESSIONS, WebSSODefinition.SSO_ATTRIBUTES)
.addRejectCheck(RejectAttributeChecker.DEFINED, WebSSODefinition.HTTP_ONLY)
.setDiscard(new DiscardAttributeChecker.DiscardAttributeValueChecker(false, true, new ModelNode(true)), WebSSODefinition.HTTP_ONLY)
.end();
final ResourceTransformationDescriptionBuilder accessLogBuilder = hostBuilder.addChildRedirection(ACCESS_LOG_PATH, ACCESS_LOG_ALIAS).getAttributeBuilder()
.addRejectCheck(RejectAttributeChecker.SIMPLE_EXPRESSIONS, WebAccessLogDefinition.ACCESS_LOG_ATTRIBUTES)
.end();
accessLogBuilder.addChildRedirection(DIRECTORY_PATH, DIRECTORY_ALIAS);
// Register
TransformationDescription.Tools.register(subsystemRoot.build(), registration, ModelVersion.create(1, 1, micro));
}