Skip to content

Commit

Permalink
[AS7-1831] Make sasl/properties children of connector. Get the remoti…
Browse files Browse the repository at this point in the history
…ng subsystem model set up using ResourceDefinition and AttributeDefinition

Cleanup
  • Loading branch information
kabir authored and n1hility committed Nov 9, 2011
1 parent 983e02a commit 5840744
Show file tree
Hide file tree
Showing 30 changed files with 1,162 additions and 508 deletions.
28 changes: 25 additions & 3 deletions build/src/main/resources/docs/schema/jboss-as-remoting_1_0.xsd
Expand Up @@ -100,8 +100,8 @@
</xs:documentation>
</xs:annotation>
<xs:all>
<xs:element name="include-mechanisms" type="name-list" minOccurs="0"/>
<xs:element name="qop" type="qop" minOccurs="0"/>
<xs:element name="include-mechanisms" type="name-listType" minOccurs="0"/>
<xs:element name="qop" type="qop-listType" minOccurs="0"/>
<xs:element name="strength" type="strength" minOccurs="0"/>
<xs:element name="reuse-session" type="boolean-element" minOccurs="0"/>
<xs:element name="server-auth" type="boolean-element" minOccurs="0"/>
Expand Down Expand Up @@ -158,6 +158,17 @@
<xs:attribute name="value" type="xs:boolean" use="required"/>
</xs:complexType>

<xs:simpleType name="name-listType">
<xs:annotation>
<xs:documentation>
<![CDATA[
An element specifying a string list.
]]>
</xs:documentation>
</xs:annotation>
<xs:attribute name="value" type="name-list" use="required"/>
</xs:simpleType>

<xs:simpleType name="name-list">
<xs:annotation>
<xs:documentation>
Expand All @@ -169,7 +180,18 @@
<xs:list itemType="xs:string"/>
</xs:simpleType>

<xs:simpleType name="qop">
<xs:complexType name="qop-listType">
<xs:annotation>
<xs:documentation>
<![CDATA[
An element specifying a qop list.
]]>
</xs:documentation>
</xs:annotation>
<xs:attribute name="value" type="qop-list" use="required"/>
</xs:complexType>

<xs:simpleType name="qop-list">
<xs:annotation>
<xs:documentation>
<![CDATA[
Expand Down
Expand Up @@ -251,5 +251,4 @@ public void marshallAsElement(final ModelNode resourceModel, final boolean marsh
writer.writeEndElement();
}
}

}
Expand Up @@ -25,15 +25,16 @@
import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
import static org.jboss.as.controller.ControllerMessages.MESSAGES;

import javax.xml.XMLConstants;
import javax.xml.stream.Location;
import javax.xml.stream.XMLStreamException;
import java.lang.reflect.Array;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import javax.xml.XMLConstants;
import javax.xml.stream.Location;
import javax.xml.stream.XMLStreamException;

import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;
import org.jboss.dmr.Property;
Expand Down Expand Up @@ -310,6 +311,9 @@ public static Property readProperty(final XMLExtendedStreamReader reader) throws
if (name == null) {
throw missingRequired(reader, Collections.singleton("name"));
}
if (reader.next() != END_ELEMENT) {
throw unexpectedElement(reader);
}
return new Property(name, new ModelNode().set(value == null ? "" : value));
}

Expand Down
1 change: 1 addition & 0 deletions pom.xml
Expand Up @@ -292,6 +292,7 @@
<module>process-controller</module>
<module>protocol</module>
<module>remoting</module>
<module>remoting-test</module>
<module>sar</module>
<module>security</module>
<module>server</module>
Expand Down
94 changes: 94 additions & 0 deletions remoting-test/pom.xml
@@ -0,0 +1,94 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ JBoss, Home of Professional Open Source.
~ Copyright 2010, Red Hat, Inc., 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.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-parent</artifactId>
<version>7.1.0.Alpha2-SNAPSHOT</version>
</parent>

<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-remoting-test</artifactId>
<version>7.1.0.Alpha2-SNAPSHOT</version>

<name>JBoss Application Server: Remoting Subsystem Test</name>

<properties>
<test.level>INFO</test.level>
</properties>

<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemProperties>
<property>
<name>java.util.logging.manager</name>
<value>org.jboss.logmanager.LogManager</value>
</property>
<property>
<name>jboss.remoting.leakdebugging</name>
<value>false</value>
</property>
<property>
<name>test.level</name>
<value>${test.level}</value>
</property>
</systemProperties>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-remoting</artifactId>
</dependency>

<!-- Test deps -->

<dependency>
<groupId>org.jboss.logmanager</groupId>
<artifactId>jboss-logmanager</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-subsystem-test</artifactId>
<scope>test</scope>
</dependency>

</dependencies>
</project>
@@ -0,0 +1,50 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, 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 java.io.IOException;

import junit.framework.Assert;

import org.jboss.as.subsystem.test.AbstractSubsystemBaseTest;

/**
*
* @author <a href="kabir.khan@jboss.com">Kabir Khan</a>
*/
public class RemotingSubsystemTestCase extends AbstractSubsystemBaseTest {

public RemotingSubsystemTestCase() {
// FIXME RemotingSubsystemTestCase constructor
super(RemotingExtension.SUBSYSTEM_NAME, new RemotingExtension());
}

@Override
protected String getSubsystemXml() throws IOException {
return readResource("remoting.xml");
}

@Override
protected void validateXml(String original, String marshalled) throws Exception {
Assert.assertEquals(original, marshalled);
}
}
@@ -0,0 +1,28 @@
<subsystem xmlns="urn:jboss:domain:remoting:1.0">
<connector name="remoting-connector" socket-binding="remoting">
<authentication-provider name="blah"/>
<properties>
<property name="c1" value="connector one"/>
<property name="c2" value="connector two"/>
</properties>
<sasl>
<include-mechanisms value="one two three"/>
<qop value="auth auth-int"/>
<strength value="low high"/>
<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"/>
<property name="sasl2" value="sasl two"/>
</properties>
</sasl>
</connector>
</subsystem>
Expand Up @@ -34,14 +34,16 @@ interface CommonAttributes {
String NO_ACTIVE = "no-active";
String NO_ANONYMOUS = "no-anonymous";
String NO_DICTIONARY = "no-dictionary";
String NO_PLAINTEXT = "no-plaintext";
String NO_PLAIN_TEXT = "no-plain-text";
String PASS_CREDENTIALS = "pass-credentials";
String POLICY = "policy";
String PROPERTIES = "properties";
String PROPERTY = "property";
String QOP = "qop";
String REUSE_SESSION= "reuse-session";
String SASL = "sasl";
String SASL_POLICY = "sasl-policy";
String SECURITY = "security";
String SERVER_AUTH = "server-auth";
String SOCKET_BINDING = "socket-binding";
String STRENGTH = "strength";
Expand Down
36 changes: 10 additions & 26 deletions remoting/src/main/java/org/jboss/as/remoting/ConnectorAdd.java
Expand Up @@ -23,34 +23,29 @@
package org.jboss.as.remoting;

import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
import static org.jboss.as.remoting.CommonAttributes.AUTHENTICATION_PROVIDER;
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_PLAINTEXT;
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.PROPERTIES;
import static org.jboss.as.remoting.CommonAttributes.QOP;
import static org.jboss.as.remoting.CommonAttributes.SASL;
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 java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;

import org.jboss.as.controller.AbstractAddStepHandler;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.ServiceVerificationHandler;
import org.jboss.as.controller.descriptions.DescriptionProvider;
import org.jboss.as.network.SocketBinding;
import org.jboss.dmr.ModelNode;
import org.jboss.msc.service.ServiceController;
Expand All @@ -67,23 +62,15 @@
*
* @author <a href="mailto:david.lloyd@redhat.com">David M. Lloyd</a>
* @author Emanuel Muckenhuber
* @author Kabir Khan
*/
public class ConnectorAdd extends AbstractAddStepHandler implements DescriptionProvider {
public class ConnectorAdd extends AbstractAddStepHandler {

static final ConnectorAdd INSTANCE = new ConnectorAdd();

protected void populateModel(ModelNode operation, ModelNode model) {
model.get(SOCKET_BINDING).set(operation.require(SOCKET_BINDING));
if (operation.hasDefined(AUTHENTICATION_PROVIDER)) {
model.get(AUTHENTICATION_PROVIDER).set(operation.get(AUTHENTICATION_PROVIDER));
}
//
if (operation.hasDefined(SASL)) {
model.get(SASL).set(operation.get(SASL));
}
if (operation.hasDefined(PROPERTIES)) {
model.get(PROPERTIES).set(operation.get(PROPERTIES));
}
protected void populateModel(ModelNode operation, ModelNode model) throws OperationFailedException{
ConnectorResource.SOCKET_BINDING_ATTRIBUTE.validateAndSet(operation, model);
ConnectorResource.AUTHENTICATION_PROVIER_ATTRIBUTE.validateAndSet(operation, model);
}

protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model, ServiceVerificationHandler verificationHandler, List<ServiceController<?>> newControllers) throws OperationFailedException {
Expand All @@ -93,8 +80,10 @@ protected void performRuntime(OperationContext context, ModelNode operation, Mod

final ServiceTarget target = context.getServiceTarget();

ServiceName socketBindingName = SocketBinding.JBOSS_BINDING_NAME.append(operation.require(SOCKET_BINDING).asString());
ServiceName socketBindingName = SocketBinding.JBOSS_BINDING_NAME.append(ConnectorResource.SOCKET_BINDING_ATTRIBUTE.validateOperation(model).asString());
RemotingServices.installConnectorServicesForSocketBinding(target, RemotingServices.SUBSYSTEM_ENDPOINT, connectorName, socketBindingName, null, null, verificationHandler, newControllers);

//TODO AuthenticationHandler
//
// final ConnectorService connectorService = new ConnectorService();
// connectorService.setOptionMap(createOptionMap(operation));
Expand Down Expand Up @@ -131,7 +120,7 @@ static OptionMap createOptionMap(final ModelNode parameters) {
builder.set(Options.SASL_POLICY_NOACTIVE, policy.get(NO_ACTIVE).asBoolean());
builder.set(Options.SASL_POLICY_NOANONYMOUS, policy.get(NO_ANONYMOUS).asBoolean());
builder.set(Options.SASL_POLICY_NODICTIONARY, policy.get(NO_DICTIONARY).asBoolean());
builder.set(Options.SASL_POLICY_NOPLAINTEXT, policy.get(NO_PLAINTEXT).asBoolean());
builder.set(Options.SASL_POLICY_NOPLAINTEXT, policy.get(NO_PLAIN_TEXT).asBoolean());
builder.set(Options.SASL_POLICY_PASS_CREDENTIALS, policy.get(PASS_CREDENTIALS).asBoolean());
}
}
Expand All @@ -153,9 +142,4 @@ static Collection<SaslQop> asQopSet(final ModelNode node) {
}
return set;
}

public ModelNode getModelDescription(Locale locale) {
return RemotingSubsystemProviders.CONNECTOR_ADD.getModelDescription(locale);
}

}

0 comments on commit 5840744

Please sign in to comment.