[jboss-svn-commits] JBL Code SVN: r23547 - in labs/jbossesb/branches/JBESB_4_4_GA_CP/product: samples/quickstarts/security_jbpm and 15 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Oct 22 04:30:50 EDT 2008
Author: beve
Date: 2008-10-22 04:30:50 -0400 (Wed, 22 Oct 2008)
New Revision: 23547
Added:
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/build.xml
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/deployment.xml
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/jbm-queue-service.xml
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/jbmq-queue-service.xml
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/jboss-esb.xml
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/jbossesb-properties.xml
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/jndi.properties
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/juddi.properties
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/log4j.xml
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/processDefinition/
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/processDefinition/processdefinition.xml
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/publicKeyStore
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/readme.txt
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/src/
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/src/org/
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/src/org/jboss/
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/src/org/jboss/soa/
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/src/org/jboss/soa/esb/
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/src/org/jboss/soa/esb/samples/
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/src/org/jboss/soa/esb/samples/quickstart/
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/src/org/jboss/soa/esb/samples/quickstart/securityjbpm/
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/src/org/jboss/soa/esb/samples/quickstart/securityjbpm/MyListenerAction.java
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/src/org/jboss/soa/esb/samples/quickstart/securityjbpm/test/
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/src/org/jboss/soa/esb/samples/quickstart/securityjbpm/test/SendEsbMessage.java
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/BpmProcessorUnitTest.java
Modified:
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/Constants.java
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/JBpmObjectMapper.java
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/BpmProcessor.java
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/JBpmObjectMapperUnitTest.java
labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/jbpm/src/test/resources/log4j.xml
Log:
Work for https://jira.jboss.org/jira/browse/JBESB-2122 "Investigate the jBPM security"
SecurityContext and AuthenticationRequest (both encrypted) are now mapped to jbpm and back to the esb.
Added: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/build.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/build.xml (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/build.xml 2008-10-22 08:30:50 UTC (rev 23547)
@@ -0,0 +1,43 @@
+<project name="Quickstart_security_jbpm" default="run" basedir=".">
+
+ <description>
+ ${ant.project.name}
+ ${line.separator}
+ </description>
+
+ <property name="username" value="esbuser" />
+ <property name="password" value="esbpassword" />
+
+
+ <!-- additional deploys
+ <property name="additional.deploys" value="*.xsd"/>
+ -->
+
+ <!-- Import the base Ant build script... -->
+ <import file="../conf/base-build.xml"/>
+
+ <target name="runtest" depends="compile" description="send esb Message to esb service">
+ <echo>Send esb message to esb service and get response</echo>
+ <java fork="yes" classname="org.jboss.soa.esb.samples.quickstart.securityjbpm.test.SendEsbMessage" failonerror="true">
+ <arg value="ESBServiceSample"/> <!-- service category -->
+ <arg value="HelloWorldStartServiceProcess"/> <!-- service name -->
+ <arg value="Hello Secured World"/> <!-- Message text -->
+ <arg value="${username}"/> <!-- username text -->
+ <arg value="${password}"/> <!-- password text -->
+ <classpath refid="exec-classpath"/>
+ </java>
+ </target>
+
+ <target name="deployProcess" description="deploys the process definition" depends="dependencies">
+ <echo>Deploy the process definition</echo>
+ <taskdef name="deployToServer" classname="org.jbpm.ant.DeployProcessToServerTask">
+ <classpath refid="exec-classpath"/>
+ </taskdef>
+ <deployToServer username="${jbpm.console.username}" password="${jbpm.console.password}" serverDeployer="${org.jboss.esb.jbpm.console.upload.url}">
+ <fileset dir="${basedir}/processDefinition" includes="*"/>
+ </deployToServer>
+ </target>
+
+
+
+</project>
Added: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/deployment.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/deployment.xml (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/deployment.xml 2008-10-22 08:30:50 UTC (rev 23547)
@@ -0,0 +1,9 @@
+<jbossesb-deployment>
+ <depends>jboss.esb:deployment=jbpm.esb</depends>
+ <depends>jboss.esb.quickstart.destination:service=Queue,name=quickstart_security_jbpm_Request_esb</depends>
+ <depends>jboss.esb.quickstart.destination:service=Queue,name=quickstart_security_jbpm_Request_esb_Process</depends>
+ <depends>jboss.esb.quickstart.destination:service=Queue,name=quickstart_security_jbpm_Request_esb_reply</depends>
+ <depends>jboss.esb.quickstart.destination:service=Queue,name=quickstart_security_jbpm_Request_esb_Process_reply</depends>
+ <depends>jboss.esb.quickstart.destination:service=Queue,name=quickstart_security_jbpm_Request_esb2</depends>
+ <depends>jboss.esb.quickstart.destination:service=Queue,name=quickstart_security_jbpm_Request_esb2_reply</depends>
+</jbossesb-deployment>
Added: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/jbm-queue-service.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/jbm-queue-service.xml (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/jbm-queue-service.xml 2008-10-22 08:30:50 UTC (rev 23547)
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<server>
+ <mbean code="org.jboss.jms.server.destination.QueueService"
+ name="jboss.esb.quickstart.destination:service=Queue,name=quickstart_security_jbpm_Request_esb"
+ xmbean-dd="xmdesc/Queue-xmbean.xml">
+ <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+ <depends>jboss.messaging:service=PostOffice</depends>
+ </mbean>
+ <mbean code="org.jboss.jms.server.destination.QueueService"
+ name="jboss.esb.quickstart.destination:service=Queue,name=quickstart_security_jbpm_Request_esb_Process"
+ xmbean-dd="xmdesc/Queue-xmbean.xml">
+ <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+ <depends>jboss.messaging:service=PostOffice</depends>
+ </mbean>
+ <mbean code="org.jboss.jms.server.destination.QueueService"
+ name="jboss.esb.quickstart.destination:service=Queue,name=quickstart_security_jbpm_Request_esb_reply"
+ xmbean-dd="xmdesc/Queue-xmbean.xml">
+ <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+ <depends>jboss.messaging:service=PostOffice</depends>
+ </mbean>
+ <mbean code="org.jboss.jms.server.destination.QueueService"
+ name="jboss.esb.quickstart.destination:service=Queue,name=quickstart_security_jbpm_Request_esb_Process_reply"
+ xmbean-dd="xmdesc/Queue-xmbean.xml">
+ <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+ <depends>jboss.messaging:service=PostOffice</depends>
+ </mbean>
+ <mbean code="org.jboss.jms.server.destination.QueueService"
+ name="jboss.esb.quickstart.destination:service=Queue,name=quickstart_security_jbpm_Request_esb2"
+ xmbean-dd="xmdesc/Queue-xmbean.xml">
+ <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+ <depends>jboss.messaging:service=PostOffice</depends>
+ </mbean>
+ <mbean code="org.jboss.jms.server.destination.QueueService"
+ name="jboss.esb.quickstart.destination:service=Queue,name=quickstart_security_jbpm_Request_esb2_reply"
+ xmbean-dd="xmdesc/Queue-xmbean.xml">
+ <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+ <depends>jboss.messaging:service=PostOffice</depends>
+ </mbean>
+
+</server>
Added: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/jbmq-queue-service.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/jbmq-queue-service.xml (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/jbmq-queue-service.xml 2008-10-22 08:30:50 UTC (rev 23547)
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<server>
+ <mbean code="org.jboss.mq.server.jmx.Queue"
+ name="jboss.esb.quickstart.destination:service=Queue,name=quickstart_security_jbpm_Request_esb">
+ <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
+ <depends optional-attribute-name="SecurityManager">jboss.mq:service=SecurityManager</depends>
+ </mbean>
+
+ <mbean code="org.jboss.mq.server.jmx.Queue"
+ name="jboss.esb.quickstart.destination:service=Queue,name=quickstart_security_jbpm_Request_esb_Process">
+ <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
+ <depends optional-attribute-name="SecurityManager">jboss.mq:service=SecurityManager</depends>
+ </mbean>
+ <mbean code="org.jboss.mq.server.jmx.Queue"
+ name="jboss.esb.quickstart.destination:service=Queue,name=quickstart_security_jbpm_Request_esb_reply">
+ <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
+ <depends optional-attribute-name="SecurityManager">jboss.mq:service=SecurityManager</depends>
+ </mbean>
+ <mbean code="org.jboss.mq.server.jmx.Queue"
+ name="jboss.esb.quickstart.destination:service=Queue,name=quickstart_security_jbpm_Request_esb_Process_reply">
+ <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
+ <depends optional-attribute-name="SecurityManager">jboss.mq:service=SecurityManager</depends>
+ </mbean>
+ <mbean code="org.jboss.mq.server.jmx.Queue"
+ name="jboss.esb.quickstart.destination:service=Queue,name=quickstart_security_jbpm_Request_esb2">
+ <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
+ <depends optional-attribute-name="SecurityManager">jboss.mq:service=SecurityManager</depends>
+ </mbean>
+ <mbean code="org.jboss.mq.server.jmx.Queue"
+ name="jboss.esb.quickstart.destination:service=Queue,name=quickstart_security_jbpm_Request_esb2_reply">
+ <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
+ <depends optional-attribute-name="SecurityManager">jboss.mq:service=SecurityManager</depends>
+ </mbean>
+</server>
Added: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/jboss-esb.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/jboss-esb.xml (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/jboss-esb.xml 2008-10-22 08:30:50 UTC (rev 23547)
@@ -0,0 +1,79 @@
+<?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" parameterReloadSecs="5">
+
+ <providers>
+ <jms-provider name="JBossMQ" connection-factory="ConnectionFactory">
+ <jms-bus busid="quickstartEsbChannelProcess">
+ <jms-message-filter dest-type="QUEUE" dest-name="queue/quickstart_security_jbpm_Request_esb_Process" selector="serviceName='HelloWorldPubService'" />
+ </jms-bus>
+
+ <jms-bus busid="quickstartEsbChannel">
+ <jms-message-filter dest-type="QUEUE" dest-name="queue/quickstart_security_jbpm_Request_esb" selector="serviceName='HelloWorldPubService'" />
+ </jms-bus>
+
+ <jms-bus busid="quickstartEsbChannel2">
+ <jms-message-filter dest-type="QUEUE" dest-name="queue/quickstart_security_jbpm_Request_esb2"/>
+ </jms-bus>
+
+ </jms-provider>
+ </providers>
+
+ <services>
+
+ <service category="ESBServiceSample" name="HelloWorldStartServiceProcess" description="Hello world ESB Service Process">
+ <security moduleName="messaging" runAs="adminRole"/>
+
+ <listeners>
+ <jms-listener name="helloWorldProcess" busidref="quickstartEsbChannelProcess" maxThreads="1" />
+ </listeners>
+
+ <actions mep="OneWay">
+
+ <action name="action" class="org.jboss.soa.esb.samples.quickstart.securityjbpm.MyListenerAction" process="displayMessage"/>
+
+ <action name="create_new_process_instance" class="org.jboss.soa.esb.services.jbpm.actions.BpmProcessor">
+ <property name="command" value="StartProcessInstanceCommand" />
+ <property name="process-definition-name" value="helloWorld"/>
+ <property name="esbToBpmVars">
+ <mapping esb="BODY_CONTENT" bpm="request" />
+ </property>
+ </action>
+ </actions>
+
+ </service>
+
+ <service category="ESBServiceSample" name="HelloWorldService1" description="Hello world ESB Service">
+ <security moduleName="messaging" />
+
+ <listeners>
+ <jms-listener name="helloWorld" busidref="quickstartEsbChannel" maxThreads="1" />
+ </listeners>
+
+ <actions mep="OneWay">
+
+ <action name="action" class="org.jboss.soa.esb.samples.quickstart.securityjbpm.MyListenerAction" process="displayMessage"/>
+
+ <action name="routeAction" class="org.jboss.soa.esb.actions.StaticWiretap">
+ <property name="destinations">
+ <route-to service-category="ESBServiceSample" service-name="HelloWorldService2"/>
+ </property>
+ </action>
+
+ </actions>
+ </service>
+
+ <service category="ESBServiceSample" name="HelloWorldService2" description="Hello world ESB Service">
+ <security moduleName="messaging" />
+
+ <listeners>
+ <jms-listener name="helloWorld2" busidref="quickstartEsbChannel2" maxThreads="1" />
+ </listeners>
+
+ <actions mep="OneWay">
+ <action name="action" class="org.jboss.soa.esb.samples.quickstart.securityjbpm.MyListenerAction" process="displayMessage"/>
+ </actions>
+
+ </service>
+ </services>
+
+</jbossesb>
Added: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/jbossesb-properties.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/jbossesb-properties.xml (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/jbossesb-properties.xml 2008-10-22 08:30:50 UTC (rev 23547)
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ 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.
+-->
+<!-- $Id: jbossesb-unittest-properties.xml $ -->
+<!--
+ These options are described in the JBossESB manual.
+ Defaults are provided here for convenience only.
+
+ Please read through this file prior to using the system, and consider
+ updating the specified entries.
+-->
+<esb
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="jbossesb-1_0.xsd">
+ <properties name="core">
+ <property name="org.jboss.soa.esb.jndi.server.type" value="jboss"/>
+ <property name="org.jboss.soa.esb.jndi.server.url" value="localhost"/>
+ <property name="org.jboss.soa.esb.persistence.connection.factory" value="org.jboss.internal.soa.esb.persistence.format.MessageStoreFactoryImpl"/>
+ <property name="jboss.esb.invm.scope.default" value="NONE"/>
+ </properties>
+ <properties name="security">
+ <property name="org.jboss.soa.esb.services.security.implementationClass" value="org.jboss.internal.soa.esb.services.security.OpenSSOSecuritySerivce"/>
+ <property name="org.jboss.soa.esb.services.security.configUrl" value="/AMConfig.properties"/>
+
+ <property name="org.jboss.soa.esb.services.security.publicKeystore" value="/publicKeyStore"/>
+ <property name="org.jboss.soa.esb.services.security.publicKeystorePassword" value="testKeystorePassword"/>
+ <property name="org.jboss.soa.esb.services.security.publicKeyAlias" value="testAlias"/>
+ <property name="org.jboss.soa.esb.services.security.publicKeyPassword" value="testPassword"/>
+ <property name="org.jboss.soa.esb.services.security.publicKeyTransformation" value="RSA/ECB/PKCS1Padding"/>
+
+ </properties>
+ <properties name="registry">
+ <property name="org.jboss.soa.esb.registry.queryManagerURI"
+ value="jnp://localhost:1099/InquiryService?org.apache.juddi.registry.rmi.Inquiry#inquire"/>
+ <property name="org.jboss.soa.esb.registry.lifeCycleManagerURI"
+ value="jnp://localhost:1099/PublishService?org.apache.juddi.registry.rmi.Publish#publish" />
+ <property name="org.jboss.soa.esb.registry.implementationClass"
+ value="org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl"/>
+ <property name="org.jboss.soa.esb.registry.factoryClass"
+ value="org.apache.ws.scout.registry.ConnectionFactoryImpl"/>
+ <property name="org.jboss.soa.esb.registry.user"
+ value="jbossesb"/>
+ <property name="org.jboss.soa.esb.registry.password"
+ value="password"/>
+ <!-- the following parameter is scout specific to set the type of communication between scout and the UDDI (embedded, rmi, soap) -->
+ <property name="org.jboss.soa.esb.scout.proxy.transportClass"
+ value="org.apache.ws.scout.transport.RMITransport"/>
+ </properties>
+ <properties name="transports" depends="core">
+ <property name="org.jboss.soa.esb.mail.smtp.host" value="localhost"/>
+ <property name="org.jboss.soa.esb.mail.smtp.user" value="jbossesb"/>
+ <property name="org.jboss.soa.esb.mail.smtp.password" value=""/>
+ <property name="org.jboss.soa.esb.mail.smtp.port" value="25"/>
+ </properties>
+ <properties name="connection">
+ <property name="min-pool-size" value="5"/>
+ <property name="max-pool=size" value="10"/>
+ <property name="blocking-timeout-millis" value="5000"/>
+ <property name="abandoned-connection-timeout" value="10000"/>
+ <property name="abandoned-connection-time-interval" value="30000"/>
+ </properties>
+ <properties name="dbstore">
+ <property name="org.jboss.soa.esb.persistence.db.connection.url" value="jdbc:hsqldb:hsql://localhost:9001/"/>
+ <property name="org.jboss.soa.esb.persistence.db.jdbc.driver" value="org.hsqldb.jdbcDriver"/>
+ <property name="org.jboss.soa.esb.persistence.db.user" value="sa"/>
+ <property name="org.jboss.soa.esb.persistence.db.pwd" value=""/>
+ <property name="org.jboss.soa.esb.persistence.db.pool.initial.size" value="2"/>
+ <property name="org.jboss.soa.esb.persistence.db.pool.min.size" value="2"/>
+ <property name="org.jboss.soa.esb.persistence.db.pool.max.size" value="5"/>
+ <!--table managed by pool to test for valid connections - created by pool automatically -->
+ <property name="org.jboss.soa.esb.persistence.db.pool.test.table" value="pooltest"/>
+ <!-- # of milliseconds to timeout waiting for a connection from pool -->
+ <property name="org.jboss.soa.esb.persistence.db.pool.timeout.millis" value="5000"/>
+ <property name="org.jboss.soa.esb.persistence.db.conn.manager" value="org.jboss.internal.soa.esb.persistence.manager.StandaloneConnectionManager"/>
+ </properties>
+ <properties name="messagerouting">
+ <property name="org.jboss.soa.esb.routing.cbrClass" value="org.jboss.internal.soa.esb.services.routing.cbr.JBossRulesRouter"/>
+ </properties>
+</esb>
Added: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/jndi.properties
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/jndi.properties (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/jndi.properties 2008-10-22 08:30:50 UTC (rev 23547)
@@ -0,0 +1,5 @@
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.provider.url=jnp://localhost:1099
+java.naming.factory.url.pkgs=org.jboss.naming
+java.naming.factory.url.pkgs=org.jnp.interfaces
+
Added: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/juddi.properties
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/juddi.properties (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/juddi.properties 2008-10-22 08:30:50 UTC (rev 23547)
@@ -0,0 +1,69 @@
+# jUDDI Registry Properties (used by RegistryServer)
+# see http://www.juddi.org for more information
+
+# The UDDI Operator Name
+juddi.operatorName = jUDDI.org
+
+# The i18n locale default codes
+juddi.i18n.languageCode = en
+juddi.i18n.countryCode = US
+
+# The UDDI DiscoveryURL Prefix
+juddi.discoveryURL = http://localhost:8080/juddi/uddiget.jsp?
+
+# The UDDI Operator Contact Email Address
+juddi.operatorEmailAddress = admin at juddi.org
+
+# The maximum name size and maximum number
+# of name elements allows in several of the
+# FindXxxx and SaveXxxx UDDI functions.
+juddi.maxNameLength=255
+juddi.maxNameElementsAllowed=5
+
+# The maximum number of UDDI artifacts allowed
+# per publisher. A value of '-1' indicates any
+# number of artifacts is valid (These values can be
+# overridden at the individual publisher level).
+juddi.maxBusinessesPerPublisher=25
+juddi.maxServicesPerBusiness=20
+juddi.maxBindingsPerService=10
+juddi.maxTModelsPerPublisher=100
+
+# jUDDI Authentication module to use
+juddi.auth = org.apache.juddi.auth.DefaultAuthenticator
+
+# jUDDI DataStore module currently to use
+juddi.dataStore = org.apache.juddi.datastore.jdbc.JDBCDataStore
+
+# use a dataSource (if set to false a direct
+# jdbc connection will be used.
+juddi.isUseDataSource=false
+juddi.jdbcDriver=com.mysql.jdbc.Driver
+juddi.jdbcUrl=jdbc:mysql://localhost:3306/juddi
+juddi.jdbcUsername=root
+juddi.jdbcPassword=admin
+# jUDDI DataSource to use
+# juddi.dataSource=java:comp/env/jdbc/MySqlDS
+
+# jUDDI UUIDGen implementation to use
+juddi.uuidgen = org.apache.juddi.uuidgen.DefaultUUIDGen
+
+# jUDDI Cryptor implementation to use
+juddi.cryptor = org.apache.juddi.cryptor.DefaultCryptor
+
+# jUDDI Validator to use
+juddi.validator=org.apache.juddi.validator.DefaultValidator
+
+# jUDDI Proxy Properties (used by RegistryProxy)
+juddi.proxy.adminURL = http://localhost:8080/juddi/admin
+juddi.proxy.inquiryURL = http://localhost:8080/juddi/inquiry
+juddi.proxy.publishURL = http://localhost:8080/juddi/publish
+juddi.proxy.transportClass = org.apache.juddi.proxy.AxisTransport
+juddi.proxy.securityProvider = com.sun.net.ssl.internal.ssl.Provider
+juddi.proxy.protocolHandler = com.sun.net.ssl.internal.www.protocol
+
+# JNDI settings (used by RMITransport)
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.provider.url=jnp://localhost:1099
+java.naming.factory.url.pkgs=org.jboss.naming
+
Added: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/log4j.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/log4j.xml (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/log4j.xml 2008-10-22 08:30:50 UTC (rev 23547)
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Log4j Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<!-- $Id: log4j.xml,v 1.26.2.5 2005/09/15 09:31:02 dimitris Exp $ -->
+
+<!--
+ | For more configuration infromation and examples see the Jakarta Log4j
+ | owebsite: http://jakarta.apache.org/log4j
+ -->
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+ <!-- ============================== -->
+ <!-- Append messages to the console -->
+ <!-- ============================== -->
+
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="Target" value="System.out"/>
+ <param name="Threshold" value="INFO"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%t][%c{1}] %m%n"/>
+ </layout>
+ </appender>
+
+ <!-- ================================= -->
+ <!-- Preserve messages in a local file -->
+ <!-- ================================= -->
+
+ <!-- A size based file rolling appender -->
+ <appender name="FILE" class="org.jboss.logging.appender.RollingFileAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="File" value="./listener.log"/>
+ <param name="Append" value="false"/>
+ <param name="MaxFileSize" value="500KB"/>
+ <param name="MaxBackupIndex" value="1"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d %-5p [%t][%c] %m%n"/>
+ </layout>
+ </appender>
+
+ <!-- ================ -->
+ <!-- Limit categories -->
+ <!-- ================ -->
+
+ <category name="org.jboss">
+ <priority value="WARN"/>
+ </category>
+ <category name="org.jboss.soa.esb">
+ <priority value="ERROR"/>
+ </category>
+ <category name="org.jboss.internal.soa.esb">
+ <priority value="ERROR"/>
+ </category>
+ <category name="org.apache">
+ <priority value="ERROR"/>
+ </category>
+ <category name="quickstart">
+ <priority value="DEBUG"/>
+ </category>
+ <!-- ======================= -->
+ <!-- Setup the Root category -->
+ <!-- ======================= -->
+
+ <root>
+ <appender-ref ref="CONSOLE"/>
+ <appender-ref ref="FILE"/>
+ </root>
+
+</log4j:configuration>
Added: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/processDefinition/processdefinition.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/processDefinition/processdefinition.xml (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/processDefinition/processdefinition.xml 2008-10-22 08:30:50 UTC (rev 23547)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process-definition xmlns="urn:jbpm.org:jpdl-3.2" name="helloWorld">
+
+ <start-state name="start-state1">
+ <transition to="HelloWorld"></transition>
+ </start-state>
+
+ <node name="HelloWorld">
+ <action class="org.jboss.soa.esb.services.jbpm.actionhandlers.EsbActionHandler">
+ <esbServiceName>HelloWorldService1</esbServiceName>
+ <esbCategoryName>ESBServiceSample</esbCategoryName>
+ <bpmToEsbVars>
+ <mapping bpm="request" esb="BODY_CONTENT"></mapping>
+ </bpmToEsbVars>
+ <esbToBpmVars>
+ <mapping bpm="response" esb="BODY_CONTENT"></mapping>
+ </esbToBpmVars>
+ </action>
+ <transition to="end-state1"></transition>
+ </node>
+
+ <end-state name="end-state1"></end-state>
+
+</process-definition>
Added: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/publicKeyStore
===================================================================
(Binary files differ)
Property changes on: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/publicKeyStore
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/readme.txt
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/readme.txt (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/readme.txt 2008-10-22 08:30:50 UTC (rev 23547)
@@ -0,0 +1,55 @@
+Overview:
+=========
+ The purpose of the security_jbpm quickstart demonstrate security integration with jBPM and JBossESB.
+ There are three services in this quickstart and a jBPM process to orchestrate these services.
+
+ All of the services print the Subject instance information to show the security Principals.
+
+Running this quickstart:
+========================
+ Please refer to 'ant help-quickstarts' for prerequisites about the quickstarts
+ and a more detailed descripton of the different ways to run the quickstarts.
+
+To Run '.esb' archive mode with jbossesb-server:
+===========================
+ 1. Type 'ant deployProcess' -- Will deploy the jBPM HelloWorld processdefinition.
+ 2. Type 'ant deploy' -- Will deploy the ESB process archive(.esb).
+ 3. Type 'ant runtest' -- Will invoke the service by using the ServiceInvoker.
+
+
+What to look for in this quickstart
+===================================
+ Flow of events:
+ 1. 'ant runtest' invokes the ESB using the ServiceInoker and calls the Service 'HelloWorldStartServiceProcess'.
+ This ESB service prints the following to the server console window:
+ INFO [STDOUT] 'ServiceName 'HelloWorldStartServiceProcess'. Subject:Subject:
+ Principal: esbuser
+ Principal: Roles(members:esbrole)
+ Principal: [groupName=Roles, members=[[roleName=adminRole]]]
+
+ 2. HelloWorldStartServiceProcess start the jBPM process. The process-definition-name is 'helloworld' and
+ can be found in processDefinitions/processdefinition.xml.
+
+ 3. The jBPM process will call out to the ESB service named 'HelloWorldService1'.
+ This ESB service prints the following to the server console window:
+ INFO [STDOUT] 'ServiceName 'HelloWorldService1'. Subject:Subject:
+ Principal: esbuser
+ Principal: Roles(members:esbrole)
+ Principal: [groupName=Roles, members=[[roleName=adminRole]]]
+ Next this service will route to 'HelloWorldService2'
+
+ 4. This ESB service prints the following to the server console window:
+ INFO [STDOUT] 'ServiceName 'HelloWorldService2'. Subject:Subject:
+ Principal: esbuser
+ Principal: Roles(members:esbrole)
+ Principal: [groupName=Roles, members=[[roleName=adminRole]]]
+
+ Things to try:
+ * Try commenting out the security configuration for 'HelloWorldService1'. Notice how the subject is not set for
+ the service in this case, but the following service still works as expected.
+
+
+
+
+
+
Added: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/src/org/jboss/soa/esb/samples/quickstart/securityjbpm/MyListenerAction.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/src/org/jboss/soa/esb/samples/quickstart/securityjbpm/MyListenerAction.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/src/org/jboss/soa/esb/samples/quickstart/securityjbpm/MyListenerAction.java 2008-10-22 08:30:50 UTC (rev 23547)
@@ -0,0 +1,55 @@
+/*
+ * 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.samples.quickstart.securityjbpm;
+
+import javax.xml.namespace.QName;
+
+import org.jboss.soa.esb.actions.AbstractActionLifecycle;
+import org.jboss.soa.esb.actions.ActionProcessingDetailFaultException;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Message;
+
+import java.io.FilePermission;
+import java.security.AccessControlContext;
+import java.security.AccessController;
+import java.security.CodeSource;
+import java.security.Permissions;
+import java.security.PermissionCollection;
+import java.security.Policy;
+import javax.security.auth.Subject;
+
+public final class MyListenerAction extends AbstractActionLifecycle
+{
+ private ConfigTree config;
+ private String serviceName;
+
+ public MyListenerAction(final ConfigTree config)
+ {
+ this.config = config;
+ serviceName = config.getParent().getAttribute("service-name");
+ }
+
+ public Message displayMessage(final Message message) throws Exception
+ {
+ System.out.println("'ServiceName '" + serviceName + "'. Subject:" + Subject.getSubject(AccessController.getContext()));
+ return message;
+ }
+}
Added: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/src/org/jboss/soa/esb/samples/quickstart/securityjbpm/test/SendEsbMessage.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/src/org/jboss/soa/esb/samples/quickstart/securityjbpm/test/SendEsbMessage.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/security_jbpm/src/org/jboss/soa/esb/samples/quickstart/securityjbpm/test/SendEsbMessage.java 2008-10-22 08:30:50 UTC (rev 23547)
@@ -0,0 +1,80 @@
+/*
+ * 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.samples.quickstart.securityjbpm.test;
+
+import java.util.Set;
+import java.io.Serializable;
+import java.util.HashSet;
+import org.jboss.soa.esb.services.security.auth.AuthenticationRequestImpl;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jboss.soa.esb.services.security.SecurityService;
+import org.jboss.soa.esb.services.security.auth.AuthenticationRequest;
+import org.jboss.soa.esb.services.security.principals.User;
+import org.jboss.soa.esb.client.ServiceInvoker;
+import org.jboss.soa.esb.couriers.FaultMessageException;
+import org.jboss.soa.esb.services.security.PublicCryptoUtil;
+
+/**
+ * Standalone class with to send ESB messages to a 'known' [category,name].
+ * <p/> arg0 - service category
+ * <br/>arg1 - service name
+ * <br/>arg2 - Text of message to send
+ * <br/>arg3 - username
+ * <br/>arg4 - password
+ *
+ * @since Version 4.0
+ *
+ */
+public class SendEsbMessage
+{
+ public static void main(String args[]) throws Exception
+ {
+// Setting the ConnectionFactory such that it will use scout
+ System.setProperty("javax.xml.registry.ConnectionFactoryClass","org.apache.ws.scout.registry.ConnectionFactoryImpl");
+
+ if (args.length < 5)
+ {
+ System.out.println("Usage SendEsbMessage <category> <name> <text to send> <username> <password>");
+ }
+ Message esbMessage = MessageFactory.getInstance().getMessage();
+
+ // create an AuthenticationRequest
+ AuthenticationRequest authRequest = new AuthenticationRequestImpl.Builder().username(args[3]).password(args[4].toCharArray()).build();
+
+ // set the authentication request on the message
+ esbMessage.getContext().setContext(SecurityService.AUTH_REQUEST, PublicCryptoUtil.INSTANCE.encrypt((Serializable) authRequest));
+
+ final String message = args[2];
+ esbMessage.getBody().add(message);
+
+ ServiceInvoker invoker = new ServiceInvoker(args[0], args[1]);
+
+ try {
+ invoker.deliverAsync(esbMessage);
+ }catch(Exception ex) {
+ ex.printStackTrace();
+ }
+ System.exit(0);
+ }
+}
Modified: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/Constants.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/Constants.java 2008-10-22 06:05:44 UTC (rev 23546)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/Constants.java 2008-10-22 08:30:50 UTC (rev 23547)
@@ -23,15 +23,15 @@
/**
- *
- * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
*
+ * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
+ *
*/
public class Constants {
-
+
// 'Well known' names for action configuration
public static final String BODY_CONTENT_VARIABLE_NAME ="BODY_CONTENT";
-
+
// Names to be used as keys both in the ESB message and in the Jbpm context (process & token)
public static final String COMMAND_CODE ="jbpmCommandCode";
@@ -66,7 +66,9 @@
public static final String JBPM_LOG_MAP ="jbpmLogMap";
public static final String REPLY_TO ="jbpmReplyTo";
public static final String FAULT_TO ="jbpmFaultTo";
-
+ public static final String SECURITY_CONTEXT ="jbpmSecurityContext";
+ public static final String AUTH_REQUEST ="jbpmAuthenticationRequest";
+
// Possible values of return codes after execution of an action
public static final String RETCODE_OK ="jbpmReturnOK";
public static final String RETCODE_INVALID_OPCODE ="jbpmReturnInvalidOpCode";
@@ -92,7 +94,7 @@
public static final String OVERWRITE_SWIMLANE_TAG ="overwrite-swimlane";
public static final String KEY_TAG ="key";
public static final String REPLY_TO_ORIGINATOR_TAG ="reply-to-originator";
-
+
//tag names for xml configuration of jBPM actions
public static final String BPM_TO_ESB_VARS_TAG = "bpmToEsbVars";
public static final String ESB_TO_BPM_VARS_TAG = "esbToBpmVars";
Modified: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/JBpmObjectMapper.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/JBpmObjectMapper.java 2008-10-22 06:05:44 UTC (rev 23546)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/JBpmObjectMapper.java 2008-10-22 08:30:50 UTC (rev 23547)
@@ -1,5 +1,5 @@
/**
- *
+ *
*/
package org.jboss.soa.esb.services.jbpm;
@@ -9,17 +9,21 @@
import java.util.List;
import java.util.Map;
+import javax.crypto.SealedObject;
+
import org.apache.log4j.Logger;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.tree.DefaultElement;
+import org.jboss.internal.soa.esb.assertion.AssertArgument;
import org.jboss.soa.esb.ConfigurationException;
import org.jboss.soa.esb.message.Message;
import org.jboss.soa.esb.message.format.MessageFactory;
import org.jboss.soa.esb.message.mapping.ObjectMapper;
import org.jboss.soa.esb.message.mapping.ObjectMappingException;
+import org.jboss.soa.esb.services.security.SecurityService;
import org.jbpm.context.exe.ContextInstance;
import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.graph.exe.Token;
@@ -27,38 +31,42 @@
/**
* Mapping glue between jBPM and ESB. Handles setting up the replyTo of the
- * JBpmCallback Service, and is a wrapper around org.jboss.soa.esb.message.mapping.ObjectMapper
+ * JBpmCallback Service, and is a wrapper around org.jboss.soa.esb.message.mapping.ObjectMapper
* to handle jBPM specifics around mapping variables from jBPM to ESB and back.
- *
+ *
* @author kstam
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
*/
public class JBpmObjectMapper {
-
+
public JBpmObjectMapper() {
super();
}
private Logger log = Logger.getLogger(getClass());
private ObjectMapper objectMapper = new ObjectMapper();
-
+
/**
- * Creates an ESB Message, giving the mapping specified in the jbpmToEsbVars Element.
+ * Creates an ESB Message, giving the mapping specified in the jbpmToEsbVars Element.
* This element is defined in the jBPM process-definition.xml as child element
* of either the EsbNotifier ActionHandler, or the EsbActionHandler.
- *
+ *
* @param jbpmToEsbVars - the configuration of the mapping.
* @param isGlobalProcessScope - Variables will be looked up using either the token scope or the process-definition (global) scope
* See the jBPM documentation for more details.
* @param executionContext - the jBPM ExecutionContext.
* @return the newly created ESB message.
- *
+ *
* @throws Exception
*/
public Message mapFromJBpmToEsbMessage (final DefaultElement bpmToEsbVars, final Boolean isGlobalProcessScope, final ExecutionContext executionContext)
{
Message message = MessageFactory.getInstance().getMessage();
boolean gblPrcScope = (null == isGlobalProcessScope) ? false : isGlobalProcessScope;
-
+
+ // Map SecurityContext and AuthRequest if they exist.
+ mapSecurityInfoFromJbpmToEsb(gblPrcScope, executionContext, message);
+
if (bpmToEsbVars==null) {
return message;
}
@@ -83,12 +91,12 @@
/**
* Sets all the Objects in the jBPM VariableMap in the body of the ESB Message using the
* the jBPM object names as the Esb Message body keys.
- *
+ *
* @param gblPrcScope
* @param executionContext
* @param message
*/
- private void setAllOnEsbMessage(final boolean gblPrcScope, final ExecutionContext executionContext, Message message)
+ private void setAllOnEsbMessage(final boolean gblPrcScope, final ExecutionContext executionContext, Message message)
{
Token token = executionContext.getToken();
ContextInstance ctxInstance = token.getProcessInstance().getContextInstance();
@@ -104,7 +112,7 @@
}
/**
* Sets a jBPM object onto the ESB Message. The mapping is defined in the Mapping element.
- *
+ *
* @param mapping - Mapping object, used to extract the object from jBPM and used to set the object on the ESB Message
* @param gblPrcScope - Global setting for the jBPM scope
* @param message - ESB Message
@@ -139,8 +147,8 @@
}
}
/**
- * Obtains an Object from the jBPM variableMap.
- *
+ * Obtains an Object from the jBPM variableMap.
+ *
* @param isPrcScope - if true, within process-instance scope, if false, within token scope, or up the token hierarchy.
* @param expression - MVEL expression String.
* @param ctxInstance - jBPM ContextInstance where the jBPM variableMap lives.
@@ -156,7 +164,7 @@
if (dotPosition > 0) {
objectName = expression.substring(0, dotPosition);
remainingExpression = expression.substring(dotPosition+1);
- }
+ }
if (isPrcScope) {
object = ctxInstance.getVariable(objectName);
} else {
@@ -169,7 +177,7 @@
return object;
}
/**
- *
+ *
* @param message
* @param esbToBpmXml
* @return
@@ -180,7 +188,7 @@
return mapFromEsbMessageToJBpmMap(message, getMappingList(esbToBpmXml));
}
/**
- * This
+ * This
* @param message
* @param token
* @throws Exception
@@ -193,7 +201,7 @@
}
for (Mapping mapping: mappingList) {
if (mapping.getBpm()==null || "".equals(mapping.getBpm())) {
-
+
mapping.setBpm(mapping.getEsb());
}
Object value = null;
@@ -201,15 +209,17 @@
value = getObjectFromMessage(message, mapping);
} catch (ConfigurationException ce) {
log.error(ce.getMessage(), ce);
- }
+ }
// only put it in the map if it's not null
if (null!=value)
map.put(mapping.getBpm(), value);
}
+ map.putAll(mapSecurityContextFromEsbMessageToJBpmMap(message));
+ map.putAll(mapAuthRequestFromEsbMessageToJBpmMap(message));
return map;
}
/**
- *
+ *
* @param message
* @param esbToBpmXml
* @return
@@ -220,7 +230,7 @@
return mapFromEsbMessageToJBpmMapping(message, getMappingList(esbToBpmXml));
}
/**
- * This
+ * This
* @param message
* @param token
* @throws Exception
@@ -233,7 +243,7 @@
}
for (Mapping mapping: mappingList) {
if (mapping.getBpm()==null || "".equals(mapping.getBpm())) {
-
+
mapping.setBpm(mapping.getEsb());
}
Object value = null;
@@ -241,14 +251,14 @@
value = getObjectFromMessage(message, mapping);
} catch (ConfigurationException ce) {
log.error(ce.getMessage(), ce);
- }
+ }
// only put it in the map if it's not null
if (null!=value)
map.put(mapping, value);
}
return map;
}
-
+
private List<Mapping> getMappingList(final String esbToBpmXml)
throws ConfigurationException
{
@@ -269,8 +279,8 @@
}
return mappingList ;
}
-
- private Object getObjectFromMessage(Message message, Mapping mapping)
+
+ private Object getObjectFromMessage(Message message, Mapping mapping)
throws ConfigurationException
{
Object value = null;
@@ -288,4 +298,64 @@
log.debug("value=" + value);
return value;
}
+
+ public HashMap<String, Object> mapSecurityContextFromEsbMessageToJBpmMap(final Message message)
+ {
+ final HashMap<String, Object> map = new HashMap<String, Object>();
+ final SealedObject sealedObject = (SealedObject) message.getContext().getContext(SecurityService.CONTEXT);
+ if (sealedObject !=null)
+ {
+ map.put(Constants.SECURITY_CONTEXT, sealedObject);
+ }
+ return map;
+ }
+
+ public HashMap<String, ?> mapAuthRequestFromEsbMessageToJBpmMap(final Message message)
+ {
+ final HashMap<String, Object> map = new HashMap<String, Object>();
+ final byte[] encryptedAuthRequest = (byte[]) message.getContext().getContext(SecurityService.AUTH_REQUEST);
+ if (encryptedAuthRequest != null)
+ {
+ map.put(Constants.AUTH_REQUEST, encryptedAuthRequest);
+ }
+ return map;
+ }
+
+ /**
+ * Will map the SecurityContext and AuthenticationRequest from a jBPM
+ * variable to ESB Message context.
+ *
+ * @param gblPrcScope True if the process scope is global.
+ * @param executionContext The jBPM execution context.
+ * @param esbMessage The distination ESB message
+ * @return
+ */
+ public Message mapSecurityInfoFromJbpmToEsb(final boolean gblPrcScope, final ExecutionContext executionContext, final Message esbMessage)
+ {
+ AssertArgument.isNotNull(executionContext, "executionContext");
+ AssertArgument.isNotNull(esbMessage, "esbMessage");
+
+ final Token token = executionContext.getToken();
+ final ContextInstance ctxInstance = token.getProcessInstance().getContextInstance();
+ final Map jbpmMap = (gblPrcScope) ? ctxInstance.getVariables() : ctxInstance.getVariables(token);
+
+ if (jbpmMap == null)
+ {
+ return esbMessage;
+ }
+
+ final Object sealedObject = jbpmMap.get(Constants.SECURITY_CONTEXT);
+ if (sealedObject != null)
+ {
+ esbMessage.getContext().setContext(SecurityService.CONTEXT, sealedObject);
+ }
+
+ final Object encrypedAutRequest = jbpmMap.get(Constants.AUTH_REQUEST);
+ if (encrypedAutRequest != null)
+ {
+ esbMessage.getContext().setContext(SecurityService.AUTH_REQUEST, encrypedAutRequest);
+ }
+
+ return esbMessage;
+ }
}
Modified: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/BpmProcessor.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/BpmProcessor.java 2008-10-22 06:05:44 UTC (rev 23546)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/jbpm/src/main/java/org/jboss/soa/esb/services/jbpm/actions/BpmProcessor.java 2008-10-22 08:30:50 UTC (rev 23547)
@@ -22,7 +22,10 @@
package org.jboss.soa.esb.services.jbpm.actions;
+import javax.crypto.SealedObject;
+
import org.apache.log4j.Logger;
+import org.jboss.internal.soa.esb.assertion.AssertArgument;
import org.jboss.soa.esb.ConfigurationException;
import org.jboss.soa.esb.actions.ActionLifecycle;
import org.jboss.soa.esb.actions.ActionLifecycleException;
@@ -32,15 +35,19 @@
import org.jboss.soa.esb.services.jbpm.cmd.Command;
import org.jboss.soa.esb.services.jbpm.cmd.CommandExecutor;
import org.jboss.soa.esb.services.jbpm.cmd.MessageFacade;
+import org.jboss.soa.esb.services.security.SecurityContext;
+import org.jboss.soa.esb.services.security.SecurityService;
+import org.jboss.soa.esb.services.security.auth.AuthenticationRequestImpl;
/**
*
* Processes a single jBPM command.
* Part of the message content will be taken from constructor time configuration
* (from the action configuration XML)
-*
+*
* @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
* @author <a href="mailto:kurt.stam at jboss.com">Kurt Stam</a>
+* @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
*/
public class BpmProcessor implements ActionLifecycle
{
@@ -61,21 +68,60 @@
throw new ActionLifecycleException(ce.getMessage(), ce);
}
}
-
+
public BpmProcessor(ConfigTree configTree) throws ConfigurationException
- {
+ {
this.configTree = configTree;
}
public Message process(Message message) throws ConfigurationException
{
+ // Add security context to message context.
+ addSecurityContext(message);
+ // Add authentication request context to message context.
+ addAuthenticationRequest(message);
+
message.getBody().add(Constants.COMMAND_CODE, messageFacade.getOpCode().toString());
messageFacade.setJBPMContextParameters(message);
+
CommandExecutor commandExecutor = CommandExecutor.getInstance();
String commandString = (String)message.getBody().get(Constants.COMMAND_CODE);
Command command = commandExecutor.getCommand(commandString);
command.execute(message);
return message;
}
-
+
+ /**
+ * Adds the current security context to the passed in message.
+ * The context is added, if set, to the message context keyed by {@link SecurityService#CONTEXT}.
+ *
+ * @param message The ESB message object.
+ */
+ final void addSecurityContext(Message message)
+ {
+ AssertArgument.isNotNull(message, "message");
+
+ SealedObject securityContext = SecurityContext.getSecurityContext();
+ if (securityContext != null)
+ {
+ message.getContext().setContext(SecurityService.CONTEXT, securityContext);
+ }
+ }
+
+ /**
+ * Adds the authentication request to the passed in message.
+ * The context is added, if set, to the message context keyed by {@link SecurityService#AUTH_REQUEST}.
+ *
+ * @param message The ESB message object.
+ */
+ final void addAuthenticationRequest(Message message)
+ {
+ AssertArgument.isNotNull(message, "message");
+
+ byte[] encryptedAuthRequest = AuthenticationRequestImpl.getEncryptedAuthRequest();
+ if (encryptedAuthRequest != null)
+ {
+ message.getContext().setContext(SecurityService.AUTH_REQUEST, encryptedAuthRequest);
+ }
+ }
}
Modified: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/JBpmObjectMapperUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/JBpmObjectMapperUnitTest.java 2008-10-22 06:05:44 UTC (rev 23546)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/JBpmObjectMapperUnitTest.java 2008-10-22 08:30:50 UTC (rev 23547)
@@ -27,6 +27,19 @@
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import java.io.IOException;
+import java.io.Serializable;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.util.HashMap;
+
+import javax.crypto.Cipher;
+import javax.crypto.IllegalBlockSizeException;
+import javax.crypto.KeyGenerator;
+import javax.crypto.NoSuchPaddingException;
+import javax.crypto.SealedObject;
+import javax.crypto.SecretKey;
+
import junit.framework.JUnit4TestAdapter;
import org.apache.log4j.Logger;
@@ -35,6 +48,8 @@
import org.dom4j.io.SAXReader;
import org.dom4j.tree.DefaultElement;
import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jboss.soa.esb.services.security.SecurityService;
import org.jbpm.graph.def.Node;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.def.Transition;
@@ -45,47 +60,51 @@
import org.junit.Test;
/**
* Tests the capabilities of the JBpmObjectMapper.
- *
+ *
* @author kstam
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
*
*/
-public class JBpmObjectMapperUnitTest
+public class JBpmObjectMapperUnitTest
{
private static String PROCESS_DEF_XML = "JBpmObjectMapperTestProcessDefinition.xml";
private static Logger logger = Logger.getLogger(JBpmObjectMapperUnitTest.class);
private static ProcessInstance processInstance = null;
+ private static JBpmObjectMapper mapper;
@BeforeClass
public static void setup()
{
logger.info("Setting up jBPM");
//Extract a process definition from the processdefinition.xml file.
- ProcessDefinition processDefinition
+ ProcessDefinition processDefinition
= ProcessDefinition.parseXmlResource(PROCESS_DEF_XML);
assertNotNull(processDefinition);
//Create an instance of the process definition.
processInstance = new ProcessInstance(processDefinition);
assertTrue(
- "Instance is in start state",
+ "Instance is in start state",
"start".equals(processInstance.getRootToken().getNode().getName()));
+
+ mapper = new JBpmObjectMapper();
}
/**
* Tests obtaining variables from the jBPM variableMap and setting them on the EsbMessage.
* We are making sure the jBPM -> EsbMessage works using
- *
+ *
* <pre>
* <jbpmToEsbVars>
* <mapping jbpm="v1" esb="esbObj1" />
* <mapping jbpm="g2" esb="esbObj2" process-scope="true" />
* </jbpmToEsbVars>
* <pre>
- *
+ *
* @throws Exception
*/
@Test
public void jBpmVariableMap() throws Exception
- {
+ {
SAXReader reader = new SAXReader();
Document document = reader.read(this.getClass().getResourceAsStream("/" + PROCESS_DEF_XML));
Element element = document.getRootElement();
@@ -95,17 +114,17 @@
String helloWorldGlobalScope = "Hello world process-instance scope";
TestJBPMVariable objectTokenScope = new TestJBPMVariable("Object token scope") ;
TestJBPMVariable objectGlobalScope = new TestJBPMVariable("Object global scope") ;
-
+
Token token = processInstance.getRootToken();
processInstance.getContextInstance().setVariable("v1", helloWorldTokenScope, token);
processInstance.getContextInstance().setVariable("g2", helloWorldGlobalScope);
processInstance.getContextInstance().setVariable("h3", objectTokenScope, token);
processInstance.getContextInstance().setVariable("i4", objectGlobalScope);
ExecutionContext executionContext = new ExecutionContext(token);
-
+
JBpmObjectMapper mapper = new JBpmObjectMapper();
Message message = mapper.mapFromJBpmToEsbMessage(bpmToEsbVars, Boolean.FALSE, executionContext);
-
+
assertEquals(helloWorldTokenScope,String.valueOf(message.getBody().get("esbObj1")));
assertEquals(helloWorldGlobalScope,String.valueOf(message.getBody().get("esbObj2")));
assertEquals(objectTokenScope.getInternal(), String.valueOf(message.getBody().get("esbObj3")));
@@ -113,12 +132,12 @@
}
/**
* Tests obtaining *no* variables from the jBPM variableMap.
- *
+ *
* @throws Exception
*/
@Test
public void jBpmCompleteVariableMap() throws Exception
- {
+ {
//Let's NOT give a mapping, this should get us all the variables in the VariableMap.
DefaultElement jbpmToEsbVars = null;
@@ -126,26 +145,26 @@
String helloWorldGlobalScope = "Hello world process-instance scope";
TestJBPMVariable objectTokenScope = new TestJBPMVariable("Object token scope") ;
TestJBPMVariable objectGlobalScope = new TestJBPMVariable("Object global scope") ;
-
+
Token token = processInstance.getRootToken();
processInstance.getContextInstance().createVariable("v1", helloWorldTokenScope, token);
processInstance.getContextInstance().createVariable("g2", helloWorldGlobalScope);
processInstance.getContextInstance().createVariable("h3", objectTokenScope, token);
processInstance.getContextInstance().createVariable("i4", objectGlobalScope);
ExecutionContext executionContext = new ExecutionContext(token);
-
+
JBpmObjectMapper mapper = new JBpmObjectMapper();
Message message = mapper.mapFromJBpmToEsbMessage(jbpmToEsbVars, Boolean.FALSE, executionContext);
assertEquals(message.getBody().getNames().length,0);
}
/**
* Tests obtaining *all* variables from the jBPM variableMap and setting them on the EsbMessage.
- *
+ *
* @throws Exception
*/
@Test
public void jBpmGetNothingFromVariableMap() throws Exception
- {
+ {
SAXReader reader = new SAXReader();
Document document = reader.read(this.getClass().getResourceAsStream("/" + PROCESS_DEF_XML));
Element element = document.getRootElement();
@@ -156,14 +175,14 @@
String helloWorldGlobalScope = "Hello world process-instance scope";
TestJBPMVariable objectTokenScope = new TestJBPMVariable("Object token scope") ;
TestJBPMVariable objectGlobalScope = new TestJBPMVariable("Object global scope") ;
-
+
Token token = processInstance.getRootToken();
processInstance.getContextInstance().createVariable("v1", helloWorldTokenScope, token);
processInstance.getContextInstance().createVariable("g2", helloWorldGlobalScope);
processInstance.getContextInstance().createVariable("h3", objectTokenScope, token);
processInstance.getContextInstance().createVariable("i4", objectGlobalScope);
ExecutionContext executionContext = new ExecutionContext(token);
-
+
JBpmObjectMapper mapper = new JBpmObjectMapper();
Message message = mapper.mapFromJBpmToEsbMessage(bpmToEsbVars, Boolean.FALSE, executionContext);
//We should find 2 variables which are named just like their jBPM counterparts.
@@ -190,21 +209,21 @@
*/
@Test
public void jBpmTokenInfo() throws Exception
- {
+ {
SAXReader reader = new SAXReader();
Document document = reader.read(this.getClass().getResourceAsStream("/" + PROCESS_DEF_XML));
Element element = document.getRootElement();
Element secondMiddleState = (Element) element.elements("state").toArray()[1];
DefaultElement bpmToEsbVars = (DefaultElement) secondMiddleState.element("transition").element("action").element("bpmToEsbVars");
-
+
Token token = processInstance.getRootToken();
ExecutionContext executionContext = new ExecutionContext(token);
Node node = executionContext.getNode();
Transition transition = (Transition) node.getLeavingTransitions().get(0);
-
+
JBpmObjectMapper mapper = new JBpmObjectMapper();
Message message = mapper.mapFromJBpmToEsbMessage(bpmToEsbVars, Boolean.FALSE, executionContext);
-
+
assertEquals(message.getBody().getNames().length,6);
assertEquals(String.valueOf(String.valueOf(message.getBody().get("TokenId"))), String.valueOf(token.getId()));
//The token name is null.
@@ -218,7 +237,43 @@
logger.info("Message=" + message);
}
+ @Test
+ public void ensureSecurityContextWasMappedToJbpmMap() throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, IllegalBlockSizeException, IOException
+ {
+ final SealedObject securityContext = createSealedObject("dummy string");
+ final Message message = MessageFactory.getInstance().getMessage();
+ message.getContext().setContext(SecurityService.CONTEXT, securityContext);
+
+ final HashMap<String,?> map = mapper.mapSecurityContextFromEsbMessageToJBpmMap(message);
+ assertNotNull("Should never return null. Can return an empty map though", map);
+ assertTrue(map.containsKey(Constants.SECURITY_CONTEXT));
+ }
+
+ @Test
+ public void ensureAuthRequestWasMappedToJbpmMap() throws InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, IllegalBlockSizeException, IOException
+ {
+ // Doesn't need to be encrypted as this is only passed along and never descrypted.
+ byte[] encryptedAuthRequest = new byte[100];
+ final Message message = MessageFactory.getInstance().getMessage();
+ message.getContext().setContext(SecurityService.AUTH_REQUEST, encryptedAuthRequest);
+
+ final HashMap<String,?> map = mapper.mapAuthRequestFromEsbMessageToJBpmMap(message);
+ assertNotNull("Should never return null. Can return an empty map though", map);
+ assertTrue(map.containsKey(Constants.AUTH_REQUEST));
+ }
+
public static junit.framework.Test suite(){
return new JUnit4TestAdapter(JBpmObjectMapperUnitTest.class);
}
+
+ private SealedObject createSealedObject(final Serializable ser) throws NoSuchAlgorithmException, NoSuchPaddingException, IllegalBlockSizeException, IOException, InvalidKeyException
+ {
+ final KeyGenerator kpg = KeyGenerator.getInstance("TripleDES");
+ kpg.init(112);
+ final SecretKey secretKey = kpg.generateKey();
+ final Cipher cipher = Cipher.getInstance("TripleDES");
+ cipher.init(Cipher.ENCRYPT_MODE, secretKey);
+
+ return new SealedObject(ser, cipher);
+ }
}
Added: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/BpmProcessorUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/BpmProcessorUnitTest.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/jbpm/src/test/java/org/jboss/soa/esb/services/jbpm/actions/BpmProcessorUnitTest.java 2008-10-22 08:30:50 UTC (rev 23547)
@@ -0,0 +1,126 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2008, Red Hat Middleware
+ * LLC, and individual contributors 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.services.jbpm.actions;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+
+import javax.crypto.Cipher;
+import javax.crypto.IllegalBlockSizeException;
+import javax.crypto.KeyGenerator;
+import javax.crypto.NoSuchPaddingException;
+import javax.crypto.SealedObject;
+import javax.crypto.SecretKey;
+
+import junit.framework.JUnit4TestAdapter;
+
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jboss.soa.esb.services.security.SecurityContext;
+import org.jboss.soa.esb.services.security.SecurityService;
+import org.jboss.soa.esb.services.security.auth.AuthenticationRequestImpl;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Unit test for {@link BpmProcessor}.
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ *
+ */
+public class BpmProcessorUnitTest
+{
+ private BpmProcessor bpmProcessor;
+ private Message message;
+ private ConfigTree configTree;
+
+ @Test
+ public void verifyThatSecurityContextWasAddedToMesssageContext() throws ConfigurationException, InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, IllegalBlockSizeException, IOException
+ {
+ final SealedObject securityContext = createSealedObject("dummy string");
+ SecurityContext.setSecurityContext(securityContext);
+ bpmProcessor.addSecurityContext(message);
+
+ assertNotNull(message.getContext().getContext(SecurityService.CONTEXT));
+ assertEquals(securityContext, message.getContext().getContext(SecurityService.CONTEXT));
+ }
+
+ @Test
+ public void verifyThatNullSecurityContextCanBeAddedToMesssageContext() throws ConfigurationException, InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException, IllegalBlockSizeException, IOException
+ {
+ SecurityContext.setSecurityContext(null);
+ bpmProcessor.addSecurityContext(message);
+
+ assertNull(message.getContext().getContext(SecurityService.CONTEXT));
+ }
+
+ @Test
+ public void verifyThatAuthenticationRequestWasAddedToMessageContext() throws ConfigurationException
+ {
+ // Doesn't need to be encrypted as this is only passed along and never descrypted.
+ byte[] encryptedAuthRequest = new byte[100];
+ AuthenticationRequestImpl.setEncryptedAuthRequest(encryptedAuthRequest);
+ bpmProcessor.addAuthenticationRequest(message);
+
+ assertNotNull(message.getContext().getContext(SecurityService.AUTH_REQUEST));
+ assertEquals(encryptedAuthRequest, message.getContext().getContext(SecurityService.AUTH_REQUEST));
+ }
+
+ @Test
+ public void verifyThatNullAuthenticationRequestCanBeAddedToMessageContext() throws ConfigurationException
+ {
+ AuthenticationRequestImpl.setEncryptedAuthRequest(null);
+ bpmProcessor.addAuthenticationRequest(message);
+ assertNull(message.getContext().getContext(SecurityService.AUTH_REQUEST));
+ }
+
+ @Before
+ public void setup() throws ConfigurationException
+ {
+ configTree = new ConfigTree("junit");
+ bpmProcessor = new BpmProcessor(configTree);
+ message = MessageFactory.getInstance().getMessage();
+ }
+
+ public static junit.framework.Test suite()
+ {
+ return new JUnit4TestAdapter(BpmProcessorUnitTest.class);
+ }
+
+ private SealedObject createSealedObject(final Serializable ser) throws NoSuchAlgorithmException, NoSuchPaddingException, IllegalBlockSizeException, IOException, InvalidKeyException
+ {
+ final KeyGenerator kpg = KeyGenerator.getInstance("TripleDES");
+ kpg.init(112);
+ final SecretKey secretKey = kpg.generateKey();
+ final Cipher cipher = Cipher.getInstance("TripleDES");
+ cipher.init(Cipher.ENCRYPT_MODE, secretKey);
+
+ return new SealedObject(ser, cipher);
+ }
+}
Modified: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/jbpm/src/test/resources/log4j.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/jbpm/src/test/resources/log4j.xml 2008-10-22 06:05:44 UTC (rev 23546)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/jbpm/src/test/resources/log4j.xml 2008-10-22 08:30:50 UTC (rev 23547)
@@ -35,13 +35,13 @@
<!-- ================ -->
<category name="org.jbpm">
- <priority value="DEBUG"/>
+ <priority value="ERROR"/>
</category>
<category name="org.hibernate">
- <priority value="INFO"/>
+ <priority value="ERROR"/>
</category>
<category name="org.jboss">
- <priority value="WARN"/>
+ <priority value="ERROR"/>
</category>
<category name="org.jboss.soa.esb">
<priority value="ERROR"/>
@@ -53,7 +53,7 @@
<priority value="ERROR"/>
</category>
<category name="org.jboss.soa.esb.services.jbpm">
- <priority value="DEBUG"/>
+ <priority value="ERROR"/>
</category>
<!-- ======================= -->
<!-- Setup the Root category -->
More information about the jboss-svn-commits
mailing list