[jboss-svn-commits] JBL Code SVN: r21054 - in labs/jbossesb/workspace/dbevenius/security/product: rosetta/src/org/jboss/soa/esb/listeners and 2 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Jul 16 10:43:02 EDT 2008
Author: beve
Date: 2008-07-16 10:43:02 -0400 (Wed, 16 Jul 2008)
New Revision: 21054
Added:
labs/jbossesb/workspace/dbevenius/security/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers/SecurityMapper.java
labs/jbossesb/workspace/dbevenius/security/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/mappers/SecurityMapperUnitTest.java
labs/jbossesb/workspace/dbevenius/security/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/mappers/jbossesb_config_security.xml
Modified:
labs/jbossesb/workspace/dbevenius/security/product/etc/schemas/xml/jbossesb-1.0.1.xsd
labs/jbossesb/workspace/dbevenius/security/product/rosetta/src/org/jboss/soa/esb/listeners/ListenerTagNames.java
Log:
Updates to the schema and mappers. Not completed yet.
Modified: labs/jbossesb/workspace/dbevenius/security/product/etc/schemas/xml/jbossesb-1.0.1.xsd
===================================================================
--- labs/jbossesb/workspace/dbevenius/security/product/etc/schemas/xml/jbossesb-1.0.1.xsd 2008-07-16 13:40:48 UTC (rev 21053)
+++ labs/jbossesb/workspace/dbevenius/security/product/etc/schemas/xml/jbossesb-1.0.1.xsd 2008-07-16 14:43:02 UTC (rev 21054)
@@ -394,6 +394,7 @@
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0" ref="jesb:property" />
+ <xsd:element maxOccurs="1" minOccurs="0" ref="jesb:authentication" />
</xsd:sequence>
<xsd:attribute name="runAs" type="xsd:string" use="optional">
<xsd:annotation>
@@ -410,6 +411,33 @@
</xsd:complexType>
</xsd:element>
+ <xsd:element name="authentication">
+ <xsd:annotation>
+ <xsd:documentation xml:lang="en">
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element maxOccurs="unbounded" minOccurs="0" ref="jesb:policy-config" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="policy-config">
+ <xsd:annotation>
+ <xsd:documentation xml:lang="en">
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:complexType>
+ <xsd:complexContent>
+ <xsd:extension base="xsd:anyType">
+ <xsd:attribute name="file" type="xsd:string" use="required" />
+ <xsd:attribute name="moduleName" type="xsd:string" use="optional"/>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+ </xsd:element>
+
<!-- 88888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888
Listener base types.
Modified: labs/jbossesb/workspace/dbevenius/security/product/rosetta/src/org/jboss/soa/esb/listeners/ListenerTagNames.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/security/product/rosetta/src/org/jboss/soa/esb/listeners/ListenerTagNames.java 2008-07-16 13:40:48 UTC (rev 21053)
+++ labs/jbossesb/workspace/dbevenius/security/product/rosetta/src/org/jboss/soa/esb/listeners/ListenerTagNames.java 2008-07-16 14:43:02 UTC (rev 21054)
@@ -72,7 +72,13 @@
public static final String NORMAL_COMPLETION_METHOD_TAG = "okMethod";
public static final String EXCEPTION_METHOD_TAG = "exceptionMethod";
public static final String HTTP_ROUTER_ROUTE_URL = "routeUrl";
+ public static final String SECURITY_TAG = "security";
+ public static final String AUTHENTICATION_TAG = "authentication";
+ public static final String CONFIG_POLICY_TAG = "config-policy";
+ public static final String RUN_AS_TAG = "runAs";
+ public static final String USE_CALLERS_IDENTIDY_TAG = "useCallersIdentity";
+
public static final String MEP_ONE_WAY = "OneWay" ;
public static final String MEP_REQUEST_RESPONSE = "RequestResponse" ;
Added: labs/jbossesb/workspace/dbevenius/security/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers/SecurityMapper.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/security/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers/SecurityMapper.java (rev 0)
+++ labs/jbossesb/workspace/dbevenius/security/product/rosetta/src/org/jboss/soa/esb/listeners/config/mappers/SecurityMapper.java 2008-07-16 14:43:02 UTC (rev 21054)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+
+package org.jboss.soa.esb.listeners.config.mappers;
+
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.dom.YADOMUtil;
+import org.jboss.soa.esb.listeners.ListenerTagNames;
+import org.jboss.soa.esb.listeners.config.xbeanmodel.SecurityDocument.Security;
+import org.jboss.soa.esb.listeners.config.xbeanmodel.ServiceDocument.Service;
+import org.w3c.dom.Element;
+
+/**
+ * Performs the mapping of XSD based configuration service actions onto a
+ * "ConfigTree" style listener configuration.
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ */
+public class SecurityMapper
+{
+ private SecurityMapper() {}
+
+ /**
+ * Perform the mapping.
+ *
+ * @param toConfigTree
+ * The listener ConfigTree to which the actions are to be added.
+ * @param service
+ * The Service to which the listener is bound. The Service defines the actions.
+ * @throws ConfigurationException
+ */
+ public static void map( final Element toConfigTree, final Service service ) throws ConfigurationException
+ {
+ final Security security = service.getSecurity();
+ if ( security != null)
+ {
+ final Element securityElement = YADOMUtil.addElement( toConfigTree, ListenerTagNames.SECURITY_TAG );
+ MapperUtil.serialize( security, securityElement );
+ }
+ YADOMUtil.removeEmptyAttributes( toConfigTree );
+ }
+}
Added: labs/jbossesb/workspace/dbevenius/security/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/mappers/SecurityMapperUnitTest.java
===================================================================
--- labs/jbossesb/workspace/dbevenius/security/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/mappers/SecurityMapperUnitTest.java (rev 0)
+++ labs/jbossesb/workspace/dbevenius/security/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/mappers/SecurityMapperUnitTest.java 2008-07-16 14:43:02 UTC (rev 21054)
@@ -0,0 +1,133 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2006, 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.soa.esb.listeners.config.mappers;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringWriter;
+
+import javax.xml.transform.stream.StreamResult;
+
+import junit.framework.JUnit4TestAdapter;
+
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.dom.YADOMUtil;
+import org.jboss.soa.esb.listeners.config.Generator;
+import org.jboss.soa.esb.listeners.config.Generator.XMLBeansModel;
+import org.jboss.soa.esb.listeners.config.xbeanmodel.ServiceDocument.Service;
+import org.junit.Before;
+import org.junit.Test;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * Unit test for {@link SecurityMapper}
+ * <p/>
+ *
+ * @author Daniel Bevenius
+ *
+ */
+public class SecurityMapperUnitTest
+{
+ private static final String ESB_CONFIG = "jbossesb_config_security.xml";
+
+ private Element root;
+ private XMLBeansModel model;
+
+ private Service service;
+
+ @Test
+ public void mapSecurityProperties() throws ConfigurationException
+ {
+ SecurityMapper.map( root, service );
+
+ Node securityNode = root.getFirstChild();
+ assertEquals( "security", securityNode.getNodeName() );
+
+ Node runAsNode = securityNode.getAttributes().getNamedItem( "runAs" );
+ assertEquals( "runAs", runAsNode.getNodeName() );
+ assertEquals( "MrPoon", runAsNode.getNodeValue() );
+
+ Node authNode = securityNode.getChildNodes().item( 1 );
+ assertEquals( "authentication", authNode.getNodeName() );
+ Node policyNode = authNode.getChildNodes().item( 1 );
+ assertEquals( "policy-config", policyNode.getNodeName() );
+ Node fileNode = policyNode.getAttributes().getNamedItem( "file" );
+ assertEquals( "file", fileNode.getNodeName() );
+ assertEquals( "/jaas.config", fileNode.getNodeValue() );
+ }
+
+ // setup methods
+
+ @Before
+ public void setup() throws ConfigurationException, IOException
+ {
+ root = createRootElement();
+ model = getXmlBeanModel( ESB_CONFIG );
+ service = model.getServices().get( 0 );
+ }
+
+ private XMLBeansModel getXmlBeanModel( String fileName ) throws ConfigurationException, IOException
+ {
+ InputStream inputStream = getClass().getResourceAsStream( ESB_CONFIG );
+ GeneratorMock mock = new GeneratorMock( inputStream );
+ XMLBeansModel model = mock.getModel();
+ return model;
+ }
+
+ private Element createRootElement() throws ConfigurationException
+ {
+ Document doc = YADOMUtil.createDocument();
+ Element root = YADOMUtil.addElement(doc, "jbossesb-gateways");
+ root.setAttribute("parameterReloadSecs", "1000" );
+ return root;
+ }
+
+
+ /**
+ * Just here to get proved access to the XMLBeansModel
+ *
+ */
+ private class GeneratorMock extends Generator
+ {
+
+ public GeneratorMock(InputStream config) throws ConfigurationException, IOException
+ {
+ super( config );
+ }
+
+ @Override
+ public XMLBeansModel getModel()
+ {
+ return super.getModel();
+ }
+ }
+
+ public static junit.framework.Test suite()
+ {
+ return new JUnit4TestAdapter( SecurityMapperUnitTest.class );
+ }
+}
Added: labs/jbossesb/workspace/dbevenius/security/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/mappers/jbossesb_config_security.xml
===================================================================
--- labs/jbossesb/workspace/dbevenius/security/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/mappers/jbossesb_config_security.xml (rev 0)
+++ labs/jbossesb/workspace/dbevenius/security/product/rosetta/tests/src/org/jboss/soa/esb/listeners/config/mappers/jbossesb_config_security.xml 2008-07-16 14:43:02 UTC (rev 21054)
@@ -0,0 +1,36 @@
+<?xml version = "1.0" encoding = "UTF-8"?>
+<jbossesb xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd">
+
+ <providers>
+
+ <jms-provider
+ name="JBossMessaging"
+ connection-factory="XAConnectionFactory"
+ jndi-URL="jnp://127.0.0.1:1099"
+ jndi-context-factory="org.jnp.interfaces.NamingContextFactory"
+ jndi-pkg-prefix="org.jboss.naming:org.jnp.interfaces">
+
+ <jms-bus busid="quickstartEsbChannel">
+ <jms-message-filter
+ dest-type="QUEUE"
+ dest-name="queue/quickstart_jms_transacted_Request_esb"
+ selector="CorrelationID = '13'"/>
+ </jms-bus>
+ </jms-provider>
+
+ </providers>
+ <services>
+ <service category="Test2" name="JMSJCATest" description="JMS JCA Test">
+ <security runAs="MrPoon">
+ <authentication>
+ <policy-config file="/jaas.config"/>
+ </authentication>
+ </security>
+
+ <listeners>
+ <jms-listener name="JMSListener" busidref="quickstartEsbChannel" maxThreads="1"/>
+ </listeners>
+ </service>
+ </services>
+
+</jbossesb>
More information about the jboss-svn-commits
mailing list