Author: david.lloyd(a)jboss.com
Date: 2010-03-09 09:53:10 -0500 (Tue, 09 Mar 2010)
New Revision: 5812
Added:
remoting-mc-int/trunk/src/main/java/org/jboss/remoting3/metadata/SimpleAuthenticationServiceManager.java
remoting-mc-int/trunk/src/main/java/org/jboss/remoting3/metadata/SimpleServerAuthenticationMetaData.java
Modified:
remoting-mc-int/trunk/src/main/java/org/jboss/remoting3/metadata/EndpointMetaData.java
remoting-mc-int/trunk/src/main/java/org/jboss/remoting3/metadata/RefMetaData.java
remoting-mc-int/trunk/src/main/java/org/jboss/remoting3/metadata/RemotingHelper.java
remoting-mc-int/trunk/src/main/java/org/jboss/remoting3/metadata/RemotingMetaData.java
remoting-mc-int/trunk/src/main/java/org/jboss/remoting3/metadata/ServerMetaData.java
remoting-mc-int/trunk/src/main/java/org/jboss/remoting3/metadata/ServiceMetaData.java
remoting-mc-int/trunk/src/main/java/org/jboss/remoting3/metadata/UserEntryMetaData.java
remoting-mc-int/trunk/src/main/resources/META-INF/jboss-remoting_3_1.xsd
Log:
Move authentication to the network server provider interface
Modified:
remoting-mc-int/trunk/src/main/java/org/jboss/remoting3/metadata/EndpointMetaData.java
===================================================================
---
remoting-mc-int/trunk/src/main/java/org/jboss/remoting3/metadata/EndpointMetaData.java 2010-03-09
03:59:17 UTC (rev 5811)
+++
remoting-mc-int/trunk/src/main/java/org/jboss/remoting3/metadata/EndpointMetaData.java 2010-03-09
14:53:10 UTC (rev 5812)
@@ -24,6 +24,7 @@
import java.util.ArrayList;
import java.util.List;
+import org.jboss.util.StringPropertyReplacer;
import org.jboss.xnio.metadata.OptionMetaData;
import javax.xml.bind.annotation.XmlAttribute;
@@ -83,7 +84,7 @@
@XmlAttribute(required = true)
public void setName(final String name) {
- this.name = name;
+ this.name = StringPropertyReplacer.replaceProperties(name);
}
public boolean isDefaultFlag() {
Modified:
remoting-mc-int/trunk/src/main/java/org/jboss/remoting3/metadata/RefMetaData.java
===================================================================
---
remoting-mc-int/trunk/src/main/java/org/jboss/remoting3/metadata/RefMetaData.java 2010-03-09
03:59:17 UTC (rev 5811)
+++
remoting-mc-int/trunk/src/main/java/org/jboss/remoting3/metadata/RefMetaData.java 2010-03-09
14:53:10 UTC (rev 5812)
@@ -22,6 +22,8 @@
package org.jboss.remoting3.metadata;
+import org.jboss.util.StringPropertyReplacer;
+
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlType;
@@ -35,6 +37,6 @@
@XmlAttribute(required = true)
public void setName(final String name) {
- this.name = name;
+ this.name = StringPropertyReplacer.replaceProperties(name);
}
}
Modified:
remoting-mc-int/trunk/src/main/java/org/jboss/remoting3/metadata/RemotingHelper.java
===================================================================
---
remoting-mc-int/trunk/src/main/java/org/jboss/remoting3/metadata/RemotingHelper.java 2010-03-09
03:59:17 UTC (rev 5811)
+++
remoting-mc-int/trunk/src/main/java/org/jboss/remoting3/metadata/RemotingHelper.java 2010-03-09
14:53:10 UTC (rev 5812)
@@ -30,6 +30,7 @@
import org.jboss.remoting3.Remoting;
import org.jboss.remoting3.UnknownURISchemeException;
import org.jboss.remoting3.remote.RemoteProtocol;
+import org.jboss.remoting3.security.ServerAuthenticationProvider;
import org.jboss.remoting3.spi.ConnectionProvider;
import org.jboss.remoting3.spi.ConnectionProviderContext;
import org.jboss.remoting3.spi.ConnectionProviderFactory;
@@ -47,8 +48,8 @@
public final class RemotingHelper {
private RemotingHelper() {}
- public static ChannelListener<ConnectedStreamChannel<InetSocketAddress>>
createServer(Endpoint endpoint, String protocol, OptionMap optionMap) throws
UnknownURISchemeException {
- return endpoint.getConnectionProviderInterface(protocol,
NetworkServerProvider.class).getServerListener(optionMap);
+ public static ChannelListener<ConnectedStreamChannel<InetSocketAddress>>
createServer(Endpoint endpoint, String protocol, OptionMap optionMap, final
ServerAuthenticationProvider authHandler) throws UnknownURISchemeException {
+ return endpoint.getConnectionProviderInterface(protocol,
NetworkServerProvider.class).getServerListener(optionMap, authHandler);
}
public static Endpoint createEndpoint(final String name, final TcpConnector
tcpConnector, final SslTcpConnector sslConnector, final Executor executor, final OptionMap
optionMap) throws IOException {
Modified:
remoting-mc-int/trunk/src/main/java/org/jboss/remoting3/metadata/RemotingMetaData.java
===================================================================
---
remoting-mc-int/trunk/src/main/java/org/jboss/remoting3/metadata/RemotingMetaData.java 2010-03-09
03:59:17 UTC (rev 5811)
+++
remoting-mc-int/trunk/src/main/java/org/jboss/remoting3/metadata/RemotingMetaData.java 2010-03-09
14:53:10 UTC (rev 5812)
@@ -8,13 +8,17 @@
import org.jboss.beans.metadata.spi.BeanMetaData;
import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.beans.metadata.spi.builder.ParameterMetaDataBuilder;
import org.jboss.remoting3.Client;
import org.jboss.remoting3.Connection;
import org.jboss.remoting3.Endpoint;
import org.jboss.remoting3.Remoting;
import org.jboss.remoting3.RemotingOptions;
import org.jboss.remoting3.RequestListener;
+import org.jboss.remoting3.security.ServerAuthenticationProvider;
import org.jboss.remoting3.security.SimpleClientCallbackHandler;
+import org.jboss.remoting3.security.SimpleServerAuthenticationProvider;
+import org.jboss.util.StringPropertyReplacer;
import org.jboss.xb.annotations.JBossXmlSchema;
import org.jboss.xnio.ChannelListener;
import org.jboss.xnio.Option;
@@ -49,6 +53,7 @@
private List<ServerMetaData> servers = new ArrayList<ServerMetaData>();
private List<ConnectionMetaData> connections = new
ArrayList<ConnectionMetaData>();
private List<EndpointMetaData> endpoints = new
ArrayList<EndpointMetaData>();
+ private List<SimpleServerAuthenticationMetaData> simpleServerAuthentications =
new ArrayList<SimpleServerAuthenticationMetaData>();
public String getEndpoint() {
return endpoint;
@@ -56,7 +61,7 @@
@XmlAttribute(name = "endpoint")
public void setEndpoint(final String endpoint) {
- this.endpoint = endpoint;
+ this.endpoint = StringPropertyReplacer.replaceProperties(endpoint);
}
public List<ServiceMetaData> getServices() {
@@ -99,11 +104,20 @@
return endpoints;
}
- @XmlElement(name = "endpoint")
+ @XmlElement(name = "endpoint", required = true)
public void setEndpoints(final List<EndpointMetaData> endpoints) {
this.endpoints = endpoints;
}
+ public List<SimpleServerAuthenticationMetaData>
getSimpleServerAuthentications() {
+ return simpleServerAuthentications;
+ }
+
+ @XmlElement(name = "simple-server-authentication")
+ public void setSimpleServerAuthentications(final
List<SimpleServerAuthenticationMetaData> simpleServerAuthentications) {
+ this.simpleServerAuthentications = simpleServerAuthentications;
+ }
+
/**
* Get the metadata items that this deployment produces.
*
@@ -111,7 +125,7 @@
*/
@XmlTransient
public List<BeanMetaData> getBeans() {
- final String endpoint = this.endpoint == null ?
"Remoting:DEFAULT-ENDPOINT" : "Remoting:ENDPOINT:" + this.endpoint;
+ final String endpoint = "Remoting:ENDPOINT:" + this.endpoint;
final List<BeanMetaData> metaDataList = new
ArrayList<BeanMetaData>();
for (ServiceMetaData service : services) {
final String type = service.getType();
@@ -158,6 +172,11 @@
builder.addConstructorParameter(Endpoint.class.getName(),
builder.createInject(endpoint));
builder.addConstructorParameter(String.class.getName(),
server.getProtocol());
builder.addConstructorParameter(OptionMap.class.getName(),
createOptionMap(server.getOptions()));
+ final RefMetaData handlerRef = server.getAuthenticationHandler();
+ if (handlerRef == null) {
+ throw new IllegalArgumentException("No authentication-provider
specified for server " + name);
+ }
+ builder.addConstructorParameter(ServerAuthenticationProvider.class.getName(),
builder.createInject("Remoting:AUTH:" + handlerRef.getName()));
metaDataList.add(builder.getBeanMetaData());
}
for (ConnectionMetaData connection : connections) {
@@ -179,9 +198,7 @@
} else {
final UserEntryMetaData entry = auth.getUserEntry();
final String password = entry.getPassword();
- builder.addConstructorParameter(CallbackHandler.class.getName(), new
SimpleClientCallbackHandler(
- entry.getUserName(), entry.getUserRealm(), password == null ?
null : password.toCharArray()
- ));
+ builder.addConstructorParameter(CallbackHandler.class.getName(), new
SimpleClientCallbackHandler(entry.getUserName(), entry.getRealmName(), password == null ?
null : password.toCharArray()));
}
}
metaDataList.add(builder.getBeanMetaData());
@@ -189,9 +206,6 @@
for (EndpointMetaData endpointMetaData : endpoints) {
final String name = endpointMetaData.getName();
final BeanMetaDataBuilder builder =
BeanMetaDataBuilder.createBuilder("Remoting:ENDPOINT:" + name,
Endpoint.class.getName());
- if (endpointMetaData.isDefaultFlag()) {
- builder.addAlias("Remoting:DEFAULT-ENDPOINT");
- }
builder.ignoreCreate();
builder.ignoreDestroy();
builder.ignoreStart();
@@ -206,6 +220,22 @@
builder.addConstructorParameter(OptionMap.class.getName(),
createOptionMap(endpointMetaData.getOptions()));
metaDataList.add(builder.getBeanMetaData());
}
+ for (SimpleServerAuthenticationMetaData metaData : simpleServerAuthentications)
{
+ final String name = metaData.getName();
+ final BeanMetaDataBuilder builder =
BeanMetaDataBuilder.createBuilder("Remoting:AUTH:" + name,
SimpleServerAuthenticationProvider.class.getName());
+ builder.ignoreCreate();
+ builder.ignoreDestroy();
+ builder.ignoreStart();
+ builder.ignoreStop();
+ for (UserEntryMetaData entry : metaData.getUsers()) {
+ final ParameterMetaDataBuilder paramBuilder =
builder.addInstallWithParameters("addUser");
+ paramBuilder.addParameterMetaData(String.class.getName(),
entry.getUserName());
+ paramBuilder.addParameterMetaData(String.class.getName(),
entry.getRealmName());
+ final String password = entry.getPassword();
+ paramBuilder.addParameterMetaData(char[].class.getName(), password ==
null ? null : password.toCharArray());
+ }
+ metaDataList.add(builder.getBeanMetaData());
+ }
return metaDataList;
}
Modified:
remoting-mc-int/trunk/src/main/java/org/jboss/remoting3/metadata/ServerMetaData.java
===================================================================
---
remoting-mc-int/trunk/src/main/java/org/jboss/remoting3/metadata/ServerMetaData.java 2010-03-09
03:59:17 UTC (rev 5811)
+++
remoting-mc-int/trunk/src/main/java/org/jboss/remoting3/metadata/ServerMetaData.java 2010-03-09
14:53:10 UTC (rev 5812)
@@ -24,6 +24,7 @@
import java.util.ArrayList;
import java.util.List;
+import org.jboss.util.StringPropertyReplacer;
import org.jboss.xnio.metadata.OptionMetaData;
import javax.xml.bind.annotation.XmlAttribute;
@@ -34,6 +35,7 @@
@XmlType(name = "server", propOrder = {})
public final class ServerMetaData {
private List<OptionMetaData> options = new ArrayList<OptionMetaData>();
+ private RefMetaData authenticationHandler;
private String protocol = "remote";
private String name;
@@ -47,13 +49,22 @@
this.options = options;
}
+ public RefMetaData getAuthenticationHandler() {
+ return authenticationHandler;
+ }
+
+ @XmlElement(name = "authentication-handler", required = true)
+ public void setAuthenticationHandler(final RefMetaData authenticationHandler) {
+ this.authenticationHandler = authenticationHandler;
+ }
+
public String getProtocol() {
return protocol;
}
@XmlAttribute
public void setProtocol(final String protocol) {
- this.protocol = protocol;
+ this.protocol = StringPropertyReplacer.replaceProperties(protocol);
}
public String getName() {
@@ -62,6 +73,6 @@
@XmlAttribute(required = true)
public void setName(final String name) {
- this.name = name;
+ this.name = StringPropertyReplacer.replaceProperties(name);
}
}
Modified:
remoting-mc-int/trunk/src/main/java/org/jboss/remoting3/metadata/ServiceMetaData.java
===================================================================
---
remoting-mc-int/trunk/src/main/java/org/jboss/remoting3/metadata/ServiceMetaData.java 2010-03-09
03:59:17 UTC (rev 5811)
+++
remoting-mc-int/trunk/src/main/java/org/jboss/remoting3/metadata/ServiceMetaData.java 2010-03-09
14:53:10 UTC (rev 5812)
@@ -24,6 +24,7 @@
import java.util.ArrayList;
import java.util.List;
+import org.jboss.util.StringPropertyReplacer;
import org.jboss.xnio.metadata.OptionMetaData;
import javax.xml.bind.annotation.XmlElement;
@@ -97,7 +98,7 @@
@XmlAttribute(name = "type", required = true)
public void setType(final String type) {
- this.type = type;
+ this.type = StringPropertyReplacer.replaceProperties(type);
}
public String getGroupName() {
@@ -106,6 +107,6 @@
@XmlAttribute(name = "group-name")
public void setGroupName(final String groupName) {
- this.groupName = groupName;
+ this.groupName = StringPropertyReplacer.replaceProperties(groupName);
}
}
Added:
remoting-mc-int/trunk/src/main/java/org/jboss/remoting3/metadata/SimpleAuthenticationServiceManager.java
===================================================================
---
remoting-mc-int/trunk/src/main/java/org/jboss/remoting3/metadata/SimpleAuthenticationServiceManager.java
(rev 0)
+++
remoting-mc-int/trunk/src/main/java/org/jboss/remoting3/metadata/SimpleAuthenticationServiceManager.java 2010-03-09
14:53:10 UTC (rev 5812)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.remoting3.metadata;
+
+import org.jboss.remoting3.Endpoint;
+import org.jboss.remoting3.Registration;
+import org.jboss.remoting3.security.SimpleServerAuthenticationProvider;
+import org.jboss.remoting3.spi.ProtocolServiceType;
+import org.jboss.xnio.IoUtils;
+
+public final class SimpleAuthenticationServiceManager {
+
+ private final String name;
+ private final Endpoint endpoint;
+
+ private Registration serviceRegistration;
+ private SimpleServerAuthenticationProvider provider;
+
+ public SimpleAuthenticationServiceManager(final Endpoint endpoint, final String name)
{
+ this.endpoint = endpoint;
+ this.name = name;
+ }
+
+ public void start() {
+ }
+
+ public void addUser(final String userName, final String userRealm, final char[]
password) {
+ provider.addUser(userName, userRealm, password);
+ }
+
+ public void stop() {
+ }
+}
Added:
remoting-mc-int/trunk/src/main/java/org/jboss/remoting3/metadata/SimpleServerAuthenticationMetaData.java
===================================================================
---
remoting-mc-int/trunk/src/main/java/org/jboss/remoting3/metadata/SimpleServerAuthenticationMetaData.java
(rev 0)
+++
remoting-mc-int/trunk/src/main/java/org/jboss/remoting3/metadata/SimpleServerAuthenticationMetaData.java 2010-03-09
14:53:10 UTC (rev 5812)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.remoting3.metadata;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlType(name = "simple-server-authentication", propOrder = {})
+public final class SimpleServerAuthenticationMetaData {
+ private List<UserEntryMetaData> users;
+ private String name;
+
+ public List<UserEntryMetaData> getUsers() {
+ return users;
+ }
+
+ @XmlElement(name = "entry")
+ public void setUsers(final List<UserEntryMetaData> users) {
+ this.users = users;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ @XmlAttribute(required = true)
+ public void setName(final String name) {
+ this.name = name;
+ }
+}
Modified:
remoting-mc-int/trunk/src/main/java/org/jboss/remoting3/metadata/UserEntryMetaData.java
===================================================================
---
remoting-mc-int/trunk/src/main/java/org/jboss/remoting3/metadata/UserEntryMetaData.java 2010-03-09
03:59:17 UTC (rev 5811)
+++
remoting-mc-int/trunk/src/main/java/org/jboss/remoting3/metadata/UserEntryMetaData.java 2010-03-09
14:53:10 UTC (rev 5812)
@@ -22,13 +22,15 @@
package org.jboss.remoting3.metadata;
+import org.jboss.util.StringPropertyReplacer;
+
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlType;
@XmlType(name = "user-entry", propOrder = {})
public final class UserEntryMetaData {
private String userName;
- private String userRealm;
+ private String realmName;
private String password;
public String getUserName() {
@@ -37,23 +39,23 @@
@XmlAttribute(name = "user-name", required = true)
public void setUserName(final String userName) {
- this.userName = userName;
+ this.userName = StringPropertyReplacer.replaceProperties(userName);
}
- public String getUserRealm() {
- return userRealm;
+ public String getRealmName() {
+ return realmName;
}
- @XmlAttribute(name = "user-realm")
- public void setUserRealm(final String userRealm) {
- this.userRealm = userRealm;
+ @XmlAttribute(name = "realm-name", required = true)
+ public void setRealmName(final String realmName) {
+ this.realmName = StringPropertyReplacer.replaceProperties(realmName);
}
public String getPassword() {
return password;
}
- @XmlAttribute
+ @XmlAttribute(required = true)
public void setPassword(final String password) {
this.password = password;
}
Modified: remoting-mc-int/trunk/src/main/resources/META-INF/jboss-remoting_3_1.xsd
===================================================================
--- remoting-mc-int/trunk/src/main/resources/META-INF/jboss-remoting_3_1.xsd 2010-03-09
03:59:17 UTC (rev 5811)
+++ remoting-mc-int/trunk/src/main/resources/META-INF/jboss-remoting_3_1.xsd 2010-03-09
14:53:10 UTC (rev 5812)
@@ -29,6 +29,8 @@
version="1.0"
+ <xs:import namespace="urn:jboss:xnio:2.1"/>
+
<xs:complexType name="remoting">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="service" type="service"/>
@@ -36,6 +38,7 @@
<xs:element name="server" type="server"/>
<xs:element name="connection" type="connection"/>
<xs:element name="endpoint" type="endpoint"/>
+ <xs:element name="simple-server-authentication"
type="simple-server-authentication"/>
</xs:choice>
<xs:attribute name="endpoint" type="xs:string"
use="optional"/>
</xs:complexType>
@@ -43,6 +46,7 @@
<xs:complexType name="server">
<xs:all>
<xs:element name="options" type="xnio:optionsType"
minOccurs="0"/>
+ <xs:element name="authentication-handler"
type="ref"/>
</xs:all>
<xs:attribute name="protocol" type="xs:string"
default="remote" use="optional"/>
<xs:attribute name="name" type="xs:string"
use="required"/>
@@ -78,8 +82,8 @@
<xs:complexType name="user-entry">
<xs:attribute name="user-name" type="xs:string"
use="required"/>
- <xs:attribute name="realm-name" type="xs:string"
use="optional"/>
- <xs:attribute name="password" type="xs:string"
use="optional"/>
+ <xs:attribute name="realm-name" type="xs:string"
use="required"/>
+ <xs:attribute name="password" type="xs:string"
use="required"/>
</xs:complexType>
<xs:complexType name="local-client">
@@ -102,6 +106,13 @@
<xs:attribute name="default" type="xs:boolean"
use="optional" default="false"/>
</xs:complexType>
+ <xs:complexType name="simple-server-authentication">
+ <xs:sequence minOccurs="0" maxOccurs="unbounded">
+ <xs:element name="entry" type="user-entry"/>
+ </xs:sequence>
+ <xs:attribute name="name" type="xs:string"
use="required"/>
+ </xs:complexType>
+
<xs:complexType name="ref">
<xs:attribute name="name" type="xs:string"
use="required"/>
</xs:complexType>