Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[AS7-6180] allow expressions in remoting subsystem

* allow expressions for connector & generic/remote/local
  outbound-connection property resources (only the value)
* allow expressions for remote-outbound-connection's user-name attribute
* allow expressions for sasl resource's server-auth & reuse-session
  attributes
* allow expressions for sasl policy resource's attributes
* add tests for resource transformation for legacy version
  • Loading branch information...
commit 753ad377b61961cc7f163029d7659aac308d8f18 1 parent a67d223
@jmesnil jmesnil authored bstansberry committed
Showing with 477 additions and 87 deletions.
  1. +119 −3 remoting-test/src/test/java/org/jboss/as/remoting/RemotingSubsystemTransformersTestCase.java
  2. +37 −0 remoting-test/src/test/resources/org/jboss/as/remoting/remoting-with-expressions.xml
  3. +37 −0 remoting-test/src/test/resources/org/jboss/as/remoting/remoting-without-expressions.xml
  4. +1 −1  remoting/src/main/java/org/jboss/as/remoting/ConnectorAdd.java
  5. +44 −32 remoting/src/main/java/org/jboss/as/remoting/ConnectorResource.java
  6. +1 −1  remoting/src/main/java/org/jboss/as/remoting/GenericOutboundConnectionAdd.java
  7. +1 −1  remoting/src/main/java/org/jboss/as/remoting/LocalOutboundConnectionAdd.java
  8. +9 −2 remoting/src/main/java/org/jboss/as/remoting/PropertyResource.java
  9. +44 −0 remoting/src/main/java/org/jboss/as/remoting/PropertyResourceTransformers.java
  10. +1 −1  remoting/src/main/java/org/jboss/as/remoting/RemoteOutboundConnectionAdd.java
  11. +4 −2 remoting/src/main/java/org/jboss/as/remoting/RemoteOutboundConnectionResourceDefinition.java
  12. +17 −0 remoting/src/main/java/org/jboss/as/remoting/RemotingExtension.java
  13. +10 −17 remoting/src/main/java/org/jboss/as/remoting/RemotingSubsystem11Parser.java
  14. +15 −10 remoting/src/main/java/org/jboss/as/remoting/SaslPolicyResource.java
  15. +55 −0 remoting/src/main/java/org/jboss/as/remoting/SaslPolicyResourceTransformers.java
  16. +14 −3 remoting/src/main/java/org/jboss/as/remoting/SaslResource.java
  17. +50 −0 remoting/src/main/java/org/jboss/as/remoting/SaslResourceTransformers.java
  18. +18 −14 ...main/java/org/jboss/as/remoting/{NamedValueAttributeDefinition.java → WrappedAttributeMarshaller.java}
View
122 remoting-test/src/test/java/org/jboss/as/remoting/RemotingSubsystemTransformersTestCase.java
@@ -22,7 +22,6 @@
package org.jboss.as.remoting;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.FAILED;
-import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.FAILURE_DESCRIPTION;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.IGNORED;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.NAME;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP;
@@ -32,6 +31,12 @@
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUCCESS;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.VALUE;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.WRITE_ATTRIBUTE_OPERATION;
+import static org.jboss.as.remoting.SaslPolicyResource.FORWARD_SECRECY;
+import static org.jboss.as.remoting.SaslPolicyResource.NO_ACTIVE;
+import static org.jboss.as.remoting.SaslPolicyResource.NO_ANONYMOUS;
+import static org.jboss.as.remoting.SaslPolicyResource.NO_DICTIONARY;
+import static org.jboss.as.remoting.SaslPolicyResource.NO_PLAIN_TEXT;
+import static org.jboss.as.remoting.SaslPolicyResource.PASS_CREDENTIALS;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@@ -39,7 +44,9 @@
import java.io.IOException;
+import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.ModelVersion;
+import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.transform.OperationTransformer;
import org.jboss.as.subsystem.test.AbstractSubsystemBaseTest;
import org.jboss.as.subsystem.test.KernelServices;
@@ -92,7 +99,111 @@ public void testTransformers() throws Exception {
assertTrue(legacyServices.isSuccessfulBoot());
checkSubsystemModelTransformation(mainServices, version_1_1);
+ checkRejectWorkerThreadAttributes(mainServices, version_1_1);
+ checkRejectSASLAttribute(mainServices, version_1_1, CommonAttributes.REUSE_SESSION, "${reuse.session:true}");
+ checkRejectSASLAttribute(mainServices, version_1_1, CommonAttributes.SERVER_AUTH, "${server.auth:true}");
+ checkRejectSASLProperty(mainServices, version_1_1);
+ checkRejectSASLPolicyAttributes(mainServices, version_1_1);
+ checkRejectConnectorProperty(mainServices, version_1_1);
+ checkRejectRemoteOutboundConnectionUsername(mainServices, version_1_1);
+ checkRejectOutboundConnectionProperty(mainServices, version_1_1, CommonAttributes.REMOTE_OUTBOUND_CONNECTION, "remote-conn1");
+ checkRejectOutboundConnectionProperty(mainServices, version_1_1, CommonAttributes.LOCAL_OUTBOUND_CONNECTION, "local-conn1");
+ checkRejectOutboundConnectionProperty(mainServices, version_1_1, CommonAttributes.OUTBOUND_CONNECTION, "generic-conn1");
+ }
+
+ private void checkRejectOutboundConnectionProperty(KernelServices mainServices, ModelVersion version, String type, String name) throws OperationFailedException {
+ ModelNode operation = new ModelNode();
+ operation.get(OP).set(WRITE_ATTRIBUTE_OPERATION);
+ ModelNode address = new ModelNode();
+ address.add(SUBSYSTEM, RemotingExtension.SUBSYSTEM_NAME);
+ address.add(type, name);
+ address.add(CommonAttributes.PROPERTY, "org.xnio.Options.SSL_ENABLED");
+ operation.get(OP_ADDR).set(address);
+ operation.get(NAME).set(CommonAttributes.VALUE);
+ operation.get(VALUE).set("${myprop:true}");
+
+ checkReject(operation, mainServices, version);
+ }
+
+ private void checkRejectSASLAttribute(KernelServices mainServices, ModelVersion version, String name, String value) throws OperationFailedException {
+ ModelNode operation = new ModelNode();
+ operation.get(OP).set(WRITE_ATTRIBUTE_OPERATION);
+ ModelNode address = new ModelNode();
+ address.add(SUBSYSTEM, RemotingExtension.SUBSYSTEM_NAME);
+ address.add(CommonAttributes.CONNECTOR, "remoting-connector");
+ address.add(CommonAttributes.SECURITY, CommonAttributes.SASL);
+ operation.get(OP_ADDR).set(address);
+ operation.get(NAME).set(name);
+ operation.get(VALUE).set(value);
+
+ checkReject(operation, mainServices, version);
+ }
+
+ private void checkRejectSASLProperty(KernelServices mainServices, ModelVersion version) throws OperationFailedException {
+ ModelNode operation = new ModelNode();
+ operation.get(OP).set(WRITE_ATTRIBUTE_OPERATION);
+ ModelNode address = new ModelNode();
+ address.add(SUBSYSTEM, RemotingExtension.SUBSYSTEM_NAME);
+ address.add(CommonAttributes.CONNECTOR, "remoting-connector");
+ address.add(CommonAttributes.SECURITY, CommonAttributes.SASL);
+ address.add(CommonAttributes.PROPERTY, "sasl1");
+ operation.get(OP_ADDR).set(address);
+ operation.get(NAME).set(CommonAttributes.VALUE);
+ operation.get(VALUE).set("${sasl.prop:sasl one}");
+
+ checkReject(operation, mainServices, version);
+ }
+
+ private void checkRejectSASLPolicyAttributes(KernelServices mainServices, ModelVersion version) throws OperationFailedException {
+ for (AttributeDefinition attr: new AttributeDefinition[] {NO_ACTIVE, NO_ANONYMOUS, NO_DICTIONARY, FORWARD_SECRECY,
+ NO_PLAIN_TEXT, PASS_CREDENTIALS}) {
+ checkRejectSASLPolicyAttribute(mainServices, version, attr);
+ }
+ }
+ private void checkRejectSASLPolicyAttribute(KernelServices mainServices, ModelVersion version, AttributeDefinition attr) throws OperationFailedException {
+ ModelNode operation = new ModelNode();
+ operation.get(OP).set(WRITE_ATTRIBUTE_OPERATION);
+ ModelNode address = new ModelNode();
+ address.add(SUBSYSTEM, RemotingExtension.SUBSYSTEM_NAME);
+ address.add(CommonAttributes.CONNECTOR, "remoting-connector");
+ address.add(CommonAttributes.SECURITY, CommonAttributes.SASL);
+ address.add(CommonAttributes.SASL_POLICY, CommonAttributes.POLICY);
+ operation.get(OP_ADDR).set(address);
+ operation.get(NAME).set(attr.getName());
+ operation.get(VALUE).set("${mypolicy:false}");
+
+ checkReject(operation, mainServices, version);
+ }
+
+ private void checkRejectConnectorProperty(KernelServices mainServices, ModelVersion version) throws OperationFailedException {
+ ModelNode operation = new ModelNode();
+ operation.get(OP).set(WRITE_ATTRIBUTE_OPERATION);
+ ModelNode address = new ModelNode();
+ address.add(SUBSYSTEM, RemotingExtension.SUBSYSTEM_NAME);
+ address.add(CommonAttributes.CONNECTOR, "remoting-connector");
+ address.add(CommonAttributes.PROPERTY, "c1");
+ operation.get(OP_ADDR).set(address);
+ operation.get(NAME).set(CommonAttributes.VALUE);
+ operation.get(VALUE).set("${connector.prop:connector one}");
+
+ checkReject(operation, mainServices, version);
+ }
+
+ private void checkRejectRemoteOutboundConnectionUsername(KernelServices mainServices, ModelVersion version) throws OperationFailedException {
+ ModelNode operation = new ModelNode();
+ operation.get(OP).set(WRITE_ATTRIBUTE_OPERATION);
+ ModelNode address = new ModelNode();
+ address.add(SUBSYSTEM, RemotingExtension.SUBSYSTEM_NAME);
+ address.add(CommonAttributes.REMOTE_OUTBOUND_CONNECTION, "remote-conn1");
+ operation.get(OP_ADDR).set(address);
+ operation.get(NAME).set(CommonAttributes.USERNAME);
+ operation.get(VALUE).set("${remoting.user:myuser}");
+
+ checkReject(operation, mainServices, version);
+ }
+
+ private void checkRejectWorkerThreadAttributes(KernelServices mainServices, ModelVersion version) throws OperationFailedException {
ModelNode operation = new ModelNode();
operation.get(OP).set(WRITE_ATTRIBUTE_OPERATION);
ModelNode address = new ModelNode();
@@ -101,6 +212,11 @@ public void testTransformers() throws Exception {
operation.get(NAME).set("worker-read-threads");
operation.get(VALUE).set("${worker.read.threads:5}");
+ checkReject(operation, mainServices, version);
+ }
+
+ private void checkReject(ModelNode operation, KernelServices mainServices, ModelVersion version) throws OperationFailedException {
+
ModelNode mainResult = mainServices.executeOperation(operation);
assertEquals(mainResult.toJSONString(true), SUCCESS, mainResult.get(OUTCOME).asString());
@@ -114,8 +230,8 @@ public void testTransformers() throws Exception {
ignoreResult.get(OUTCOME).set(IGNORED);
ignoreResult.protect();
- final OperationTransformer.TransformedOperation op = mainServices.transformOperation(version_1_1, operation);
- final ModelNode result = mainServices.executeOperation(version_1_1, op);
+ final OperationTransformer.TransformedOperation op = mainServices.transformOperation(version, operation);
+ final ModelNode result = mainServices.executeOperation(version, op);
assertEquals("should reject the expression", FAILED, result.get(OUTCOME).asString());
}
View
37 remoting-test/src/test/resources/org/jboss/as/remoting/remoting-with-expressions.xml
@@ -7,4 +7,41 @@
task-max-threads="${worker.task.max.threads:9}"
write-threads="${worker.write.threads:10}"
/>
+ <connector name="remoting-connector" socket-binding="remoting">
+ <properties>
+ <property name="c1" value="${connector.prop:connector one}"/>
+ </properties>
+ <sasl>
+ <server-auth value="${sasl.server.auth:true}"/>
+ <reuse-session value="${sasl.reuse.session:true}"/>
+ <policy>
+ <forward-secrecy value="${forward.secrecy:true}"/>
+ <no-active value="${no.active:true}"/>
+ <no-anonymous value="${no.anonymous:true}"/>
+ <no-dictionary value="${no.dictionary:true}"/>
+ <no-plain-text value="${no.plain.text:true}"/>
+ <pass-credentials value="${pass.credentials:true}"/>
+ </policy>
+ <properties>
+ <property name="sasl1" value="${sasl.prop:sasl one}"/>
+ </properties>
+ </sasl>
+ </connector>
+ <outbound-connections>
+ <outbound-connection name="generic-conn1" uri="myuri">
+ <properties>
+ <property name="org.xnio.Options.SSL_ENABLED" value="${generic.outbound.connection.prop:false}"/>
+ </properties>
+ </outbound-connection>
+ <remote-outbound-connection name="remote-conn1" outbound-socket-binding-ref="dummy-outbound-socket" username="${remoting.user:myuser}">
+ <properties>
+ <property name="org.xnio.Options.SSL_ENABLED" value="${remote.outbound.connection.prop:false}"/>
+ </properties>
+ </remote-outbound-connection>
+ <local-outbound-connection name="local-conn1" outbound-socket-binding-ref="other-outbound-socket">
+ <properties>
+ <property name="org.xnio.Options.SSL_ENABLED" value="${local.outbound.connection.prop:false}"/>
+ </properties>
+ </local-outbound-connection>
+ </outbound-connections>
</subsystem>
View
37 remoting-test/src/test/resources/org/jboss/as/remoting/remoting-without-expressions.xml
@@ -7,4 +7,41 @@
task-max-threads="9"
write-threads="10"
/>
+ <connector name="remoting-connector" socket-binding="remoting">
+ <properties>
+ <property name="c1" value="connector one"/>
+ </properties>
+ <sasl>
+ <server-auth value="true"/>
+ <reuse-session value="true"/>
+ <policy>
+ <forward-secrecy value="true"/>
+ <no-active value="true"/>
+ <no-anonymous value="true"/>
+ <no-dictionary value="true"/>
+ <no-plain-text value="true"/>
+ <pass-credentials value="true"/>
+ </policy>
+ <properties>
+ <property name="sasl1" value="sasl one"/>
+ </properties>
+ </sasl>
+ </connector>
+ <outbound-connections>
+ <outbound-connection name="generic-conn1" uri="myuri">
+ <properties>
+ <property name="org.xnio.Options.SSL_ENABLED" value="false"/>
+ </properties>
+ </outbound-connection>
+ <remote-outbound-connection name="remote-conn1" outbound-socket-binding-ref="dummy-outbound-socket" username="myuser">
+ <properties>
+ <property name="org.xnio.Options.SSL_ENABLED" value="false"/>
+ </properties>
+ </remote-outbound-connection>
+ <local-outbound-connection name="local-conn1" outbound-socket-binding-ref="other-outbound-socket">
+ <properties>
+ <property name="org.xnio.Options.SSL_ENABLED" value="false"/>
+ </properties>
+ </local-outbound-connection>
+ </outbound-connections>
</subsystem>
View
2  remoting/src/main/java/org/jboss/as/remoting/ConnectorAdd.java
@@ -71,7 +71,7 @@ protected void performRuntime(OperationContext context, ModelNode operation, Mod
}
void launchServices(OperationContext context, String connectorName, ModelNode fullModel, ServiceVerificationHandler verificationHandler, List<ServiceController<?>> newControllers) throws OperationFailedException {
- OptionMap optionMap = ConnectorResource.getFullOptions(fullModel);
+ OptionMap optionMap = ConnectorResource.getFullOptions(context, fullModel);
final ServiceTarget target = context.getServiceTarget();
View
76 remoting/src/main/java/org/jboss/as/remoting/ConnectorResource.java
@@ -22,13 +22,7 @@
package org.jboss.as.remoting;
import static org.jboss.as.remoting.CommonAttributes.CONNECTOR;
-import static org.jboss.as.remoting.CommonAttributes.FORWARD_SECRECY;
import static org.jboss.as.remoting.CommonAttributes.INCLUDE_MECHANISMS;
-import static org.jboss.as.remoting.CommonAttributes.NO_ACTIVE;
-import static org.jboss.as.remoting.CommonAttributes.NO_ANONYMOUS;
-import static org.jboss.as.remoting.CommonAttributes.NO_DICTIONARY;
-import static org.jboss.as.remoting.CommonAttributes.NO_PLAIN_TEXT;
-import static org.jboss.as.remoting.CommonAttributes.PASS_CREDENTIALS;
import static org.jboss.as.remoting.CommonAttributes.POLICY;
import static org.jboss.as.remoting.CommonAttributes.PROPERTY;
import static org.jboss.as.remoting.CommonAttributes.QOP;
@@ -38,6 +32,14 @@
import static org.jboss.as.remoting.CommonAttributes.SECURITY;
import static org.jboss.as.remoting.CommonAttributes.SERVER_AUTH;
import static org.jboss.as.remoting.CommonAttributes.STRENGTH;
+import static org.jboss.as.remoting.SaslPolicyResource.FORWARD_SECRECY;
+import static org.jboss.as.remoting.SaslPolicyResource.NO_ACTIVE;
+import static org.jboss.as.remoting.SaslPolicyResource.NO_ANONYMOUS;
+import static org.jboss.as.remoting.SaslPolicyResource.NO_DICTIONARY;
+import static org.jboss.as.remoting.SaslPolicyResource.NO_PLAIN_TEXT;
+import static org.jboss.as.remoting.SaslPolicyResource.PASS_CREDENTIALS;
+import static org.jboss.as.remoting.SaslResource.REUSE_SESSION_ATTRIBUTE;
+import static org.jboss.as.remoting.SaslResource.SERVER_AUTH_ATTRIBUTE;
import java.util.ArrayList;
import java.util.Collection;
@@ -45,6 +47,8 @@
import java.util.List;
import java.util.Set;
+import org.jboss.as.controller.OperationContext;
+import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.OperationStepHandler;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.ReloadRequiredWriteAttributeHandler;
@@ -70,47 +74,54 @@
*/
public class ConnectorResource extends SimpleResourceDefinition {
+ static final PathElement PATH = PathElement.pathElement(CommonAttributes.CONNECTOR);
+
static final ConnectorResource INSTANCE = new ConnectorResource();
- static final SimpleAttributeDefinition AUTHENTICATION_PROVIDER = new NamedValueAttributeDefinition(CommonAttributes.AUTHENTICATION_PROVIDER, Attribute.NAME, null, ModelType.STRING, true);
+ //FIXME is this attribute still used?
+ static final SimpleAttributeDefinition AUTHENTICATION_PROVIDER = new SimpleAttributeDefinitionBuilder(CommonAttributes.AUTHENTICATION_PROVIDER, ModelType.STRING)
+ .setDefaultValue(null)
+ .setAllowNull(true)
+ .setAttributeMarshaller(new WrappedAttributeMarshaller(Attribute.NAME))
+ .build();
+
static final SimpleAttributeDefinition SOCKET_BINDING = new SimpleAttributeDefinition(CommonAttributes.SOCKET_BINDING, ModelType.STRING, false);
static final SimpleAttributeDefinition SECURITY_REALM = new SimpleAttributeDefinitionBuilder(
CommonAttributes.SECURITY_REALM, ModelType.STRING, true).setValidator(
new StringLengthValidator(1, Integer.MAX_VALUE, true, false)).build();
private ConnectorResource() {
- super(PathElement.pathElement(CommonAttributes.CONNECTOR), RemotingExtension.getResourceDescriptionResolver(CONNECTOR),
+ super(PATH, RemotingExtension.getResourceDescriptionResolver(CONNECTOR),
ConnectorAdd.INSTANCE, ConnectorRemove.INSTANCE);
}
- protected static OptionMap getFullOptions(ModelNode fullModel) {
+ protected static OptionMap getFullOptions(OperationContext context, ModelNode fullModel) throws OperationFailedException {
OptionMap.Builder builder = OptionMap.builder();
ModelNode properties = fullModel.get(PROPERTY);
if (properties.isDefined() && properties.asInt() > 0) {
- addOptions(properties, builder);
+ addOptions(context, properties, builder);
}
if (fullModel.hasDefined(SECURITY)) {
ModelNode security = fullModel.require(SECURITY);
if (security.hasDefined(SASL)) {
ModelNode sasl = security.require(SASL);
- addSasl(sasl, builder);
+ addSasl(context, sasl, builder);
}
}
-
return builder.getMap();
}
- protected static OptionMap getOptions(ModelNode properties) {
+ protected static OptionMap getOptions(OperationContext context, ModelNode properties) throws OperationFailedException {
if (properties.isDefined() && properties.asInt() > 0) {
OptionMap.Builder builder = OptionMap.builder();
- addOptions(properties, builder);
+ addOptions(context, properties, builder);
return builder.getMap();
} else {
return OptionMap.EMPTY;
}
}
- private static void addSasl(ModelNode sasl, OptionMap.Builder builder) {
+ private static void addSasl(OperationContext context, ModelNode sasl, OptionMap.Builder builder) throws OperationFailedException {
if (sasl.hasDefined(INCLUDE_MECHANISMS)) {
builder.set(Options.SASL_MECHANISMS, Sequence.of(asStringSet(sasl.get(INCLUDE_MECHANISMS))));
}
@@ -124,31 +135,31 @@ private static void addSasl(ModelNode sasl, OptionMap.Builder builder) {
}
}
if (sasl.hasDefined(SERVER_AUTH)) {
- builder.set(Options.SASL_SERVER_AUTH, sasl.get(SERVER_AUTH).asBoolean());
+ builder.set(Options.SASL_SERVER_AUTH, SERVER_AUTH_ATTRIBUTE.resolveModelAttribute(context, sasl).asBoolean());
}
if (sasl.hasDefined(REUSE_SESSION)) {
- builder.set(Options.SASL_REUSE, sasl.get(REUSE_SESSION).asBoolean());
+ builder.set(Options.SASL_REUSE, REUSE_SESSION_ATTRIBUTE.resolveModelAttribute(context, sasl).asBoolean());
}
ModelNode saslPolicy;
if (sasl.hasDefined(SASL_POLICY) && (saslPolicy = sasl.get(SASL_POLICY)).hasDefined(POLICY)) {
ModelNode policy = saslPolicy.get(POLICY);
- if (policy.hasDefined(FORWARD_SECRECY)) {
- builder.set(Options.SASL_POLICY_FORWARD_SECRECY, policy.get(FORWARD_SECRECY).asBoolean());
+ if (policy.hasDefined(FORWARD_SECRECY.getName())) {
+ builder.set(Options.SASL_POLICY_FORWARD_SECRECY, FORWARD_SECRECY.resolveModelAttribute(context, policy).asBoolean());
}
- if (policy.hasDefined(NO_ACTIVE)) {
- builder.set(Options.SASL_POLICY_NOACTIVE, policy.get(NO_ACTIVE).asBoolean());
+ if (policy.hasDefined(NO_ACTIVE.getName())) {
+ builder.set(Options.SASL_POLICY_NOACTIVE, NO_ACTIVE.resolveModelAttribute(context, policy).asBoolean());
}
- if (policy.hasDefined(NO_ANONYMOUS)) {
- builder.set(Options.SASL_POLICY_NOANONYMOUS, policy.get(NO_ANONYMOUS).asBoolean());
+ if (policy.hasDefined(NO_ANONYMOUS.getName())) {
+ builder.set(Options.SASL_POLICY_NOANONYMOUS, NO_ANONYMOUS.resolveModelAttribute(context, policy).asBoolean());
}
- if (policy.hasDefined(NO_DICTIONARY)) {
- builder.set(Options.SASL_POLICY_NODICTIONARY, policy.get(NO_DICTIONARY).asBoolean());
+ if (policy.hasDefined(NO_DICTIONARY.getName())) {
+ builder.set(Options.SASL_POLICY_NODICTIONARY, NO_DICTIONARY.resolveModelAttribute(context, policy).asBoolean());
}
- if (policy.hasDefined(NO_PLAIN_TEXT)) {
- builder.set(Options.SASL_POLICY_NOPLAINTEXT, policy.get(NO_PLAIN_TEXT).asBoolean());
+ if (policy.hasDefined(NO_PLAIN_TEXT.getName())) {
+ builder.set(Options.SASL_POLICY_NOPLAINTEXT, NO_PLAIN_TEXT.resolveModelAttribute(context, policy).asBoolean());
}
- if (policy.hasDefined(PASS_CREDENTIALS)) {
- builder.set(Options.SASL_POLICY_PASS_CREDENTIALS, policy.get(PASS_CREDENTIALS).asBoolean());
+ if (policy.hasDefined(PASS_CREDENTIALS.getName())) {
+ builder.set(Options.SASL_POLICY_PASS_CREDENTIALS, PASS_CREDENTIALS.resolveModelAttribute(context, policy).asBoolean());
}
}
@@ -157,13 +168,13 @@ private static void addSasl(ModelNode sasl, OptionMap.Builder builder) {
List<Property> props = property.asPropertyList();
List<org.xnio.Property> converted = new ArrayList<org.xnio.Property>(props.size());
for (Property current : props) {
- converted.add(org.xnio.Property.of(current.getName(), current.getValue().asString()));
+ converted.add(org.xnio.Property.of(current.getName(), PropertyResource.VALUE.resolveModelAttribute(context, current.getValue()).asString()));
}
builder.set(Options.SASL_PROPERTIES, Sequence.of(converted));
}
}
- private static void addOptions(ModelNode properties, OptionMap.Builder builder) {
+ private static void addOptions(OperationContext context, ModelNode properties, OptionMap.Builder builder) throws OperationFailedException {
final ClassLoader loader = SecurityActions.getClassLoader(ConnectorResource.class);
for (Property property : properties.asPropertyList()) {
String name = property.getName();
@@ -171,7 +182,8 @@ private static void addOptions(ModelNode properties, OptionMap.Builder builder)
name = "org.xnio.Options." + name;
}
final Option option = Option.fromString(name, loader);
- builder.set(option, option.parseValue(property.getValue().get(CommonAttributes.VALUE).asString(), loader));
+ String value = PropertyResource.VALUE.resolveModelAttribute(context, property.getValue()).asString();
+ builder.set(option, option.parseValue(value, loader));
}
}
View
2  remoting/src/main/java/org/jboss/as/remoting/GenericOutboundConnectionAdd.java
@@ -91,7 +91,7 @@ ServiceController installRuntimeService(final OperationContext context, final Mo
final PathAddress pathAddress = PathAddress.pathAddress(operation.require(OP_ADDR));
final String connectionName = pathAddress.getLastElement().getValue();
- final OptionMap connectionCreationOptions = ConnectorResource.getOptions(fullModel.get(CommonAttributes.PROPERTY));
+ final OptionMap connectionCreationOptions = ConnectorResource.getOptions(context, fullModel.get(CommonAttributes.PROPERTY));
//final OptionMap connectionCreationOptions = getConnectionCreationOptions(outboundConnection);
View
2  remoting/src/main/java/org/jboss/as/remoting/LocalOutboundConnectionAdd.java
@@ -70,7 +70,7 @@ ServiceController installRuntimeService(final OperationContext context,final Mod
final String outboundSocketBindingRef = LocalOutboundConnectionResourceDefinition.OUTBOUND_SOCKET_BINDING_REF.resolveModelAttribute(context, operation).asString();
final ServiceName outboundSocketBindingDependency = OutboundSocketBinding.OUTBOUND_SOCKET_BINDING_BASE_SERVICE_NAME.append(outboundSocketBindingRef);
// fetch the connection creation options from the model
- final OptionMap connectionCreationOptions = ConnectorResource.getOptions(fullModel.get(CommonAttributes.PROPERTY));
+ final OptionMap connectionCreationOptions = ConnectorResource.getOptions(context, fullModel.get(CommonAttributes.PROPERTY));
// create the service
final LocalOutboundConnectionService outboundConnectionService = new LocalOutboundConnectionService(connectionName, connectionCreationOptions);
final ServiceName serviceName = AbstractOutboundConnectionService.OUTBOUND_CONNECTION_BASE_SERVICE_NAME.append(connectionName);
View
11 remoting/src/main/java/org/jboss/as/remoting/PropertyResource.java
@@ -33,6 +33,7 @@
import org.jboss.as.controller.RestartParentWriteAttributeHandler;
import org.jboss.as.controller.ServiceVerificationHandler;
import org.jboss.as.controller.SimpleAttributeDefinition;
+import org.jboss.as.controller.SimpleAttributeDefinitionBuilder;
import org.jboss.as.controller.SimpleResourceDefinition;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.dmr.ModelNode;
@@ -45,14 +46,20 @@
*/
public class PropertyResource extends SimpleResourceDefinition {
+ static final PathElement PATH = PathElement.pathElement(PROPERTY);
+
static final PropertyResource INSTANCE_CONNECTOR = new PropertyResource(CONNECTOR);
- static final SimpleAttributeDefinition VALUE = new NamedValueAttributeDefinition(CommonAttributes.VALUE, Attribute.VALUE, null, ModelType.STRING, true);
+ static final SimpleAttributeDefinition VALUE = SimpleAttributeDefinitionBuilder.create(CommonAttributes.VALUE, ModelType.STRING)
+ .setDefaultValue(null)
+ .setAllowNull(true)
+ .setAllowExpression(true)
+ .build();
private final String parent;
protected PropertyResource(String parent) {
- super(PathElement.pathElement(PROPERTY),
+ super(PATH,
RemotingExtension.getResourceDescriptionResolver(PROPERTY),
new PropertyAdd(parent),
new PropertyRemove(parent));
View
44 remoting/src/main/java/org/jboss/as/remoting/PropertyResourceTransformers.java
@@ -0,0 +1,44 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2012, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.as.remoting;
+
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.WRITE_ATTRIBUTE_OPERATION;
+
+import org.jboss.as.controller.transform.RejectExpressionValuesTransformer;
+import org.jboss.as.controller.transform.TransformersSubRegistration;
+
+/**
+ *
+ * @author <a href="http://jmesnil.net">Jeff Mesnil</a> (c) 2012 Red Hat, inc
+ */
+public class PropertyResourceTransformers {
+
+ static TransformersSubRegistration registerTransformers(TransformersSubRegistration parent) {
+ TransformersSubRegistration property = parent.registerSubResource(PropertyResource.PATH);
+ RejectExpressionValuesTransformer rejectPropertyExpression = new RejectExpressionValuesTransformer(PropertyResource.VALUE);
+ property.registerOperationTransformer(ADD, rejectPropertyExpression);
+ property.registerOperationTransformer(WRITE_ATTRIBUTE_OPERATION, rejectPropertyExpression.getWriteAttributeTransformer());
+
+ return property;
+ }
+}
View
2  remoting/src/main/java/org/jboss/as/remoting/RemoteOutboundConnectionAdd.java
@@ -75,7 +75,7 @@ ServiceController installRuntimeService(final OperationContext context, final Mo
final String outboundSocketBindingRef = RemoteOutboundConnectionResourceDefinition.OUTBOUND_SOCKET_BINDING_REF.resolveModelAttribute(context, operation).asString();
final ServiceName outboundSocketBindingDependency = OutboundSocketBinding.OUTBOUND_SOCKET_BINDING_BASE_SERVICE_NAME.append(outboundSocketBindingRef);
// fetch the connection creation options from the model
- final OptionMap connectionCreationOptions = ConnectorResource.getOptions(fullModel.get(CommonAttributes.PROPERTY));
+ final OptionMap connectionCreationOptions = ConnectorResource.getOptions(context, fullModel.get(CommonAttributes.PROPERTY));
final String username = fullModel.hasDefined(CommonAttributes.USERNAME) ? fullModel.require(CommonAttributes.USERNAME).asString() : null;
final String securityRealm = fullModel.hasDefined(CommonAttributes.SECURITY_REALM) ? fullModel.require(CommonAttributes.SECURITY_REALM).asString() : null;
View
6 remoting/src/main/java/org/jboss/as/remoting/RemoteOutboundConnectionResourceDefinition.java
@@ -43,8 +43,10 @@
.setAllowExpression(true).setValidator(new StringLengthValidator(1, Integer.MAX_VALUE, false, true))
.setFlags(AttributeAccess.Flag.RESTART_ALL_SERVICES).build();
- public static final SimpleAttributeDefinition USERNAME = new SimpleAttributeDefinitionBuilder(CommonAttributes.USERNAME,
- ModelType.STRING, true).setValidator(new StringLengthValidator(1, Integer.MAX_VALUE, true, false)).build();
+ public static final SimpleAttributeDefinition USERNAME = new SimpleAttributeDefinitionBuilder(CommonAttributes.USERNAME, ModelType.STRING, true)
+ .setAllowExpression(true)
+ .setValidator(new StringLengthValidator(1, Integer.MAX_VALUE, true, true))
+ .build();
public static final SimpleAttributeDefinition SECURITY_REALM = new SimpleAttributeDefinitionBuilder(
CommonAttributes.SECURITY_REALM, ModelType.STRING, true).setValidator(
View
17 remoting/src/main/java/org/jboss/as/remoting/RemotingExtension.java
@@ -155,6 +155,23 @@ private void registerTransformers_1_1(SubsystemRegistration registration) {
final TransformersSubRegistration subsystem = registration.registerModelTransformers(VERSION_1_1, rejectExpression);
subsystem.registerOperationTransformer(ADD, rejectExpression);
subsystem.registerOperationTransformer(WRITE_ATTRIBUTE_OPERATION, rejectExpression.getWriteAttributeTransformer());
+
+ TransformersSubRegistration connector = subsystem.registerSubResource(ConnectorResource.PATH);
+ PropertyResourceTransformers.registerTransformers(connector);
+ SaslResourceTransformers.registerTransformers(connector);
+
+ TransformersSubRegistration remoteOutboundConnection = subsystem.registerSubResource(RemoteOutboundConnectionResourceDefinition.ADDRESS);
+ RejectExpressionValuesTransformer rejectUserNameExpression = new RejectExpressionValuesTransformer(RemoteOutboundConnectionResourceDefinition.USERNAME);
+ remoteOutboundConnection.registerOperationTransformer(ADD, rejectUserNameExpression);
+ remoteOutboundConnection.registerOperationTransformer(WRITE_ATTRIBUTE_OPERATION, rejectUserNameExpression.getWriteAttributeTransformer());
+
+ PropertyResourceTransformers.registerTransformers(remoteOutboundConnection);
+
+ TransformersSubRegistration localOutboundConnection = subsystem.registerSubResource(LocalOutboundConnectionResourceDefinition.ADDRESS);
+ PropertyResourceTransformers.registerTransformers(localOutboundConnection);
+
+ TransformersSubRegistration outboundConnection = subsystem.registerSubResource(GenericOutboundConnectionResourceDefinition.ADDRESS);
+ PropertyResourceTransformers.registerTransformers(outboundConnection);
}
/**
View
27 remoting/src/main/java/org/jboss/as/remoting/RemotingSubsystem11Parser.java
@@ -30,7 +30,6 @@
import static org.jboss.as.controller.parsing.ParseUtils.duplicateNamedElement;
import static org.jboss.as.controller.parsing.ParseUtils.missingRequired;
import static org.jboss.as.controller.parsing.ParseUtils.readArrayAttributeElement;
-import static org.jboss.as.controller.parsing.ParseUtils.readBooleanAttributeElement;
import static org.jboss.as.controller.parsing.ParseUtils.readProperty;
import static org.jboss.as.controller.parsing.ParseUtils.readStringAttributeElement;
import static org.jboss.as.controller.parsing.ParseUtils.requireNoAttributes;
@@ -40,26 +39,18 @@
import static org.jboss.as.controller.parsing.ParseUtils.unexpectedElement;
import static org.jboss.as.remoting.CommonAttributes.AUTHENTICATION_PROVIDER;
import static org.jboss.as.remoting.CommonAttributes.CONNECTOR;
-import static org.jboss.as.remoting.CommonAttributes.FORWARD_SECRECY;
import static org.jboss.as.remoting.CommonAttributes.INCLUDE_MECHANISMS;
import static org.jboss.as.remoting.CommonAttributes.LOCAL_OUTBOUND_CONNECTION;
-import static org.jboss.as.remoting.CommonAttributes.NO_ACTIVE;
-import static org.jboss.as.remoting.CommonAttributes.NO_ANONYMOUS;
-import static org.jboss.as.remoting.CommonAttributes.NO_DICTIONARY;
-import static org.jboss.as.remoting.CommonAttributes.NO_PLAIN_TEXT;
import static org.jboss.as.remoting.CommonAttributes.OUTBOUND_CONNECTION;
import static org.jboss.as.remoting.CommonAttributes.OUTBOUND_SOCKET_BINDING_REF;
-import static org.jboss.as.remoting.CommonAttributes.PASS_CREDENTIALS;
import static org.jboss.as.remoting.CommonAttributes.POLICY;
import static org.jboss.as.remoting.CommonAttributes.PROPERTY;
import static org.jboss.as.remoting.CommonAttributes.QOP;
import static org.jboss.as.remoting.CommonAttributes.REMOTE_OUTBOUND_CONNECTION;
-import static org.jboss.as.remoting.CommonAttributes.REUSE_SESSION;
import static org.jboss.as.remoting.CommonAttributes.SASL;
import static org.jboss.as.remoting.CommonAttributes.SASL_POLICY;
import static org.jboss.as.remoting.CommonAttributes.SECURITY;
import static org.jboss.as.remoting.CommonAttributes.SECURITY_REALM;
-import static org.jboss.as.remoting.CommonAttributes.SERVER_AUTH;
import static org.jboss.as.remoting.CommonAttributes.SOCKET_BINDING;
import static org.jboss.as.remoting.CommonAttributes.STRENGTH;
import static org.jboss.as.remoting.CommonAttributes.URI;
@@ -311,11 +302,13 @@ void parseSaslElement(final XMLExtendedStreamReader reader, final ModelNode addr
break;
}
case REUSE_SESSION: {
- saslElement.get(REUSE_SESSION).set(readBooleanAttributeElement(reader, "value"));
+ String value = readStringAttributeElement(reader, "value");
+ SaslResource.REUSE_SESSION_ATTRIBUTE.parseAndSetParameter(value, saslElement, reader);
break;
}
case SERVER_AUTH: {
- saslElement.get(SERVER_AUTH).set(readBooleanAttributeElement(reader, "value"));
+ String value = readStringAttributeElement(reader, "value");
+ SaslResource.SERVER_AUTH_ATTRIBUTE.parseAndSetParameter(value, saslElement, reader);
break;
}
case STRENGTH: {
@@ -356,27 +349,27 @@ ModelNode parsePolicyElement(XMLExtendedStreamReader reader, final ModelNode add
visited.add(element);
switch (element) {
case FORWARD_SECRECY: {
- policy.get(FORWARD_SECRECY).set(readBooleanAttributeElement(reader, "value"));
+ SaslPolicyResource.FORWARD_SECRECY.parseAndSetParameter(readStringAttributeElement(reader, "value"), policy, reader);
break;
}
case NO_ACTIVE: {
- policy.get(NO_ACTIVE).set(readBooleanAttributeElement(reader, "value"));
+ SaslPolicyResource.NO_ACTIVE.parseAndSetParameter(readStringAttributeElement(reader, "value"), policy, reader);
break;
}
case NO_ANONYMOUS: {
- policy.get(NO_ANONYMOUS).set(readBooleanAttributeElement(reader, "value"));
+ SaslPolicyResource.NO_ANONYMOUS.parseAndSetParameter(readStringAttributeElement(reader, "value"), policy, reader);
break;
}
case NO_DICTIONARY: {
- policy.get(NO_DICTIONARY).set(readBooleanAttributeElement(reader, "value"));
+ SaslPolicyResource.NO_DICTIONARY.parseAndSetParameter(readStringAttributeElement(reader, "value"), policy, reader);
break;
}
case NO_PLAIN_TEXT: {
- policy.get(NO_PLAIN_TEXT).set(readBooleanAttributeElement(reader, "value"));
+ SaslPolicyResource.NO_PLAIN_TEXT.parseAndSetParameter(readStringAttributeElement(reader, "value"), policy, reader);
break;
}
case PASS_CREDENTIALS: {
- policy.get(PASS_CREDENTIALS).set(readBooleanAttributeElement(reader, "value"));
+ SaslPolicyResource.PASS_CREDENTIALS.parseAndSetParameter(readStringAttributeElement(reader, "value"), policy, reader);
break;
}
default: {
View
25 remoting/src/main/java/org/jboss/as/remoting/SaslPolicyResource.java
@@ -28,6 +28,8 @@
import org.jboss.as.controller.OperationStepHandler;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.ReloadRequiredWriteAttributeHandler;
+import org.jboss.as.controller.SimpleAttributeDefinition;
+import org.jboss.as.controller.SimpleAttributeDefinitionBuilder;
import org.jboss.as.controller.SimpleResourceDefinition;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.dmr.ModelNode;
@@ -42,12 +44,12 @@
static final SaslPolicyResource INSTANCE = new SaslPolicyResource();
- static final AttributeDefinition FORWARD_SECRECY = new BooleanValueAttributeDefinition(CommonAttributes.FORWARD_SECRECY);
- static final AttributeDefinition NO_ACTIVE = new BooleanValueAttributeDefinition(CommonAttributes.NO_ACTIVE);
- static final AttributeDefinition NO_ANONYMOUS = new BooleanValueAttributeDefinition(CommonAttributes.NO_ANONYMOUS);
- static final AttributeDefinition NO_DICTIONARY = new BooleanValueAttributeDefinition(CommonAttributes.NO_DICTIONARY);
- static final AttributeDefinition NO_PLAIN_TEXT = new BooleanValueAttributeDefinition(CommonAttributes.NO_PLAIN_TEXT);
- static final AttributeDefinition PASS_CREDENTIALS = new BooleanValueAttributeDefinition(CommonAttributes.PASS_CREDENTIALS);
+ static final SimpleAttributeDefinition FORWARD_SECRECY = createBooleanAttributeDefinition(CommonAttributes.FORWARD_SECRECY);
+ static final SimpleAttributeDefinition NO_ACTIVE = createBooleanAttributeDefinition(CommonAttributes.NO_ACTIVE);
+ static final SimpleAttributeDefinition NO_ANONYMOUS = createBooleanAttributeDefinition(CommonAttributes.NO_ANONYMOUS);
+ static final SimpleAttributeDefinition NO_DICTIONARY = createBooleanAttributeDefinition(CommonAttributes.NO_DICTIONARY);
+ static final SimpleAttributeDefinition NO_PLAIN_TEXT = createBooleanAttributeDefinition(CommonAttributes.NO_PLAIN_TEXT);
+ static final SimpleAttributeDefinition PASS_CREDENTIALS = createBooleanAttributeDefinition(CommonAttributes.PASS_CREDENTIALS);
private SaslPolicyResource() {
super(SASL_POLICY_CONFIG_PATH,
@@ -69,9 +71,12 @@ public void registerAttributes(ManagementResourceRegistration resourceRegistrati
resourceRegistration.registerReadWriteAttribute(PASS_CREDENTIALS, null, writeHandler);
}
- private static class BooleanValueAttributeDefinition extends NamedValueAttributeDefinition {
- public BooleanValueAttributeDefinition(String name) {
- super(name, Attribute.VALUE, new ModelNode().set(true), ModelType.BOOLEAN, true);
- }
+ private static SimpleAttributeDefinition createBooleanAttributeDefinition(String name) {
+ return SimpleAttributeDefinitionBuilder.create(name, ModelType.BOOLEAN)
+ .setDefaultValue(new ModelNode(true))
+ .setAllowNull(true)
+ .setAllowExpression(true)
+ .setAttributeMarshaller(new WrappedAttributeMarshaller(Attribute.VALUE))
+ .build();
}
}
View
55 remoting/src/main/java/org/jboss/as/remoting/SaslPolicyResourceTransformers.java
@@ -0,0 +1,55 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2012, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.as.remoting;
+
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.WRITE_ATTRIBUTE_OPERATION;
+import static org.jboss.as.remoting.SaslPolicyResource.FORWARD_SECRECY;
+import static org.jboss.as.remoting.SaslPolicyResource.NO_ACTIVE;
+import static org.jboss.as.remoting.SaslPolicyResource.NO_ANONYMOUS;
+import static org.jboss.as.remoting.SaslPolicyResource.NO_DICTIONARY;
+import static org.jboss.as.remoting.SaslPolicyResource.NO_PLAIN_TEXT;
+import static org.jboss.as.remoting.SaslPolicyResource.PASS_CREDENTIALS;
+import static org.jboss.as.remoting.SaslPolicyResource.SASL_POLICY_CONFIG_PATH;
+import static org.jboss.as.remoting.SaslResource.REUSE_SESSION_ATTRIBUTE;
+import static org.jboss.as.remoting.SaslResource.SASL_CONFIG_PATH;
+import static org.jboss.as.remoting.SaslResource.SERVER_AUTH_ATTRIBUTE;
+
+import org.jboss.as.controller.transform.RejectExpressionValuesTransformer;
+import org.jboss.as.controller.transform.TransformersSubRegistration;
+
+/**
+ *
+ * @author <a href="http://jmesnil.net">Jeff Mesnil</a> (c) 2012 Red Hat, inc
+ */
+public class SaslPolicyResourceTransformers {
+
+ static TransformersSubRegistration registerTransformers(TransformersSubRegistration parent) {
+ TransformersSubRegistration policy = parent.registerSubResource(SASL_POLICY_CONFIG_PATH);
+ RejectExpressionValuesTransformer rejectExpression = new RejectExpressionValuesTransformer(FORWARD_SECRECY,
+ NO_ACTIVE, NO_ANONYMOUS, NO_DICTIONARY, NO_PLAIN_TEXT, PASS_CREDENTIALS);
+ policy.registerOperationTransformer(ADD, rejectExpression);
+ policy.registerOperationTransformer(WRITE_ATTRIBUTE_OPERATION, rejectExpression.getWriteAttributeTransformer());
+
+ return policy;
+ }
+}
View
17 remoting/src/main/java/org/jboss/as/remoting/SaslResource.java
@@ -40,6 +40,8 @@
import org.jboss.as.controller.ListAttributeDefinition;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.ReloadRequiredWriteAttributeHandler;
+import org.jboss.as.controller.SimpleAttributeDefinition;
+import org.jboss.as.controller.SimpleAttributeDefinitionBuilder;
import org.jboss.as.controller.SimpleResourceDefinition;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.controller.descriptions.ResourceDescriptionResolver;
@@ -64,9 +66,18 @@
static final AttributeDefinition INCLUDE_MECHANISMS_ATTRIBUTE = new SaslListAttributeDefinition(Element.INCLUDE_MECHANISMS, INCLUDE_MECHANISMS, true);
static final AttributeDefinition QOP_ATTRIBUTE = new SaslListAttributeDefinition(Element.QOP, QOP, true, QopParameterValidation.INSTANCE);
static final AttributeDefinition STRENGTH_ATTRIBUTE = new SaslListAttributeDefinition(Element.STRENGTH, STRENGTH, true, StrengthParameterValidation.INSTANCE);
- static final AttributeDefinition REUSE_SESSION_ATTRIBUTE = new NamedValueAttributeDefinition(REUSE_SESSION, Attribute.VALUE, new ModelNode().set(false), ModelType.BOOLEAN, true);
- static final AttributeDefinition SERVER_AUTH_ATTRIBUTE = new NamedValueAttributeDefinition(SERVER_AUTH, Attribute.VALUE, new ModelNode().set(false), ModelType.BOOLEAN, true);
-
+ static final SimpleAttributeDefinition SERVER_AUTH_ATTRIBUTE = SimpleAttributeDefinitionBuilder.create(SERVER_AUTH, ModelType.BOOLEAN)
+ .setDefaultValue(new ModelNode(false))
+ .setAllowNull(true)
+ .setAllowExpression(true)
+ .setAttributeMarshaller(new WrappedAttributeMarshaller(Attribute.VALUE))
+ .build();
+ static final SimpleAttributeDefinition REUSE_SESSION_ATTRIBUTE = SimpleAttributeDefinitionBuilder.create(REUSE_SESSION, ModelType.BOOLEAN)
+ .setDefaultValue(new ModelNode(false))
+ .setAllowNull(true)
+ .setAllowExpression(true)
+ .setAttributeMarshaller(new WrappedAttributeMarshaller(Attribute.VALUE))
+ .build();
private SaslResource() {
super(SASL_CONFIG_PATH,
View
50 remoting/src/main/java/org/jboss/as/remoting/SaslResourceTransformers.java
@@ -0,0 +1,50 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2012, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.as.remoting;
+
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.WRITE_ATTRIBUTE_OPERATION;
+import static org.jboss.as.remoting.SaslResource.REUSE_SESSION_ATTRIBUTE;
+import static org.jboss.as.remoting.SaslResource.SASL_CONFIG_PATH;
+import static org.jboss.as.remoting.SaslResource.SERVER_AUTH_ATTRIBUTE;
+
+import org.jboss.as.controller.transform.RejectExpressionValuesTransformer;
+import org.jboss.as.controller.transform.TransformersSubRegistration;
+
+/**
+ *
+ * @author <a href="http://jmesnil.net">Jeff Mesnil</a> (c) 2012 Red Hat, inc
+ */
+public class SaslResourceTransformers {
+
+ static TransformersSubRegistration registerTransformers(TransformersSubRegistration parent) {
+ TransformersSubRegistration sasl = parent.registerSubResource(SASL_CONFIG_PATH);
+ RejectExpressionValuesTransformer rejectPropertyExpression = new RejectExpressionValuesTransformer(SERVER_AUTH_ATTRIBUTE, REUSE_SESSION_ATTRIBUTE);
+ sasl.registerOperationTransformer(ADD, rejectPropertyExpression);
+ sasl.registerOperationTransformer(WRITE_ATTRIBUTE_OPERATION, rejectPropertyExpression.getWriteAttributeTransformer());
+
+ SaslPolicyResourceTransformers.registerTransformers(sasl);
+ PropertyResourceTransformers.registerTransformers(sasl);
+
+ return sasl;
+ }
+}
View
32 ...moting/NamedValueAttributeDefinition.java → .../remoting/WrappedAttributeMarshaller.java
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
-* Copyright 2011, Red Hat Middleware LLC, and individual contributors
+* Copyright 2012, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
@@ -19,28 +19,32 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
+
package org.jboss.as.remoting;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
-import org.jboss.as.controller.SimpleAttributeDefinition;
+import org.jboss.as.controller.AttributeDefinition;
+import org.jboss.as.controller.AttributeMarshaller;
import org.jboss.dmr.ModelNode;
-import org.jboss.dmr.ModelType;
-class NamedValueAttributeDefinition extends SimpleAttributeDefinition {
- final Attribute attribute;
- public NamedValueAttributeDefinition(final String name, final Attribute attribute, final ModelNode defaultValue, final ModelType type, final boolean allowNull) {
- super(name, defaultValue, type, allowNull);
- this.attribute = attribute;
+/**
+ * <a href="http://jmesnil.net/">Jeff Mesnil</a> (c) 2012 Red Hat, inc
+ */
+public class WrappedAttributeMarshaller extends AttributeMarshaller {
+
+ private final Attribute xmlAttribute;
+
+ WrappedAttributeMarshaller(Attribute xmlAttribute) {
+ this.xmlAttribute = xmlAttribute;
}
@Override
- public void marshallAsElement(ModelNode resourceModel, final boolean marshalDefault, XMLStreamWriter writer)
- throws XMLStreamException {
- if (isMarshallable(resourceModel)) {
- writer.writeEmptyElement(getXmlName());
- writer.writeAttribute(attribute.getLocalName(), resourceModel.get(getName()).asString());
+ public void marshallAsElement(AttributeDefinition attribute, ModelNode resourceModel, boolean marshallDefault, XMLStreamWriter writer) throws XMLStreamException {
+ if (isMarshallable(attribute, resourceModel)) {
+ writer.writeEmptyElement(attribute.getXmlName());
+ writer.writeAttribute(xmlAttribute.getLocalName(), resourceModel.get(attribute.getName()).asString());
}
}
-}
+}
Please sign in to comment.
Something went wrong with that request. Please try again.