Spring Security: WSSecurity (WSSE/SOAP) with SAML token using spring security (by looking-up user into LDAP) - spring

Need help on securing a SOAP WS with WSSE SAML TOKEN by using Spring security.
We are using org.springframework.ws.soap.security.xwss.XwsSecurityInterceptor to intercept the endpoint wsdl.
Exception:
Intercept the wsdl having SAML token and validate the user against
LDAP
Details are as below:
endpoint: http://localhost:8080/swss-soap-example-1.3.0/password/plain/xwss/profileService
input payload:
<soapenv:Header>
<wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<saml:Assertion AssertionID="SAML-pYkHWi487VIpBoT821ysBQ22" IssueInstant="2015-08-18T18:41:28Z"
Issuer="www.oracle.com" MajorVersion="1" MinorVersion="1" xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion">
<saml:AuthenticationStatement AuthenticationInstant="2015-08-18T18:41:28Z" AuthenticationMethod="urn:oasis:names:tc:SAML:1.0:am:password">
<saml:Subject>
<saml:NameIdentifier Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified">admin</saml:NameIdentifier>
<saml:SubjectConfirmation>
<saml:ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:cm:sender-vouches</saml:ConfirmationMethod>
</saml:SubjectConfirmation>
</saml:Subject>
</saml:AuthenticationStatement>
</saml:Assertion>
</wsse:Security>
</soapenv:Header>
applicationContext.xml
<bean id="securityInterceptor" class="org.springframework.ws.soap.security.xwss.XwsSecurityInterceptor">
<property name="policyConfiguration" value="classpath:security/endpoint/security-password-plain-endpoint.xml" />
<property name="callbackHandlers">
<list/>
<!--list>
<ref bean="validationHandler" />
</list-->
</property>
</bean>
securityPolicy.xml
<!DOCTYPE xml>
<xwss:SecurityConfiguration xmlns:xwss="http://java.sun.com/xml/ns/xwss/config">
<!--xwss:RequireUsernameToken
passwordDigestRequired="false" nonceRequired="false" /-->
<xwss:RequireSAMLAssertion type="SV" keyReferenceType="Identifier" />
</xwss:SecurityConfiguration>

Related

Send and receive data using Spring Integration TCP IP socket

I am creating a simple spring boot application(PoC) to send product id's (string) from client to server over socket using Spring integration TCP. If the server is hit with correct product data, the server will respond back with the product details which I need to print. Just need to establish a connection and get the response by sending proper data.
Please tell me what are the classes I am supposed to implement? outbound/inboud gateways,messsage channels, tcplisteners? Should I go with xml configuration or annotations? I am new to SI and would be of great help if you could give me an idea on how to implement it.
Here is my updated integration xml.
<int-ip:tcp-connection-factory id="client" type="client" host="XX.XX.XX.99" port="9XXX" single-use="true" so-timeout="10000" />
<int:channel id="input"/>
<int-ip:tcp-outbound-gateway id="outGateway" request-channel="input" reply-channel="clientBytes2StringChannel" connection-factory="client" request-timeout="10000" reply-timeout="10000"/>
<int:object-to-string-transformer id="clientBytes2String" input-channel="clientBytes2StringChannel"/>
<int:service-activator input-channel="clientBytes2StringChannel" ref="echoService" method="test"/>
<bean id="echoService" class="org.springframework.integration.samples.tcpclientserver.EchoService"/>
<int:channel id="toSA"/>
But this still prints the echoed result. Also, when I call getHost on abstractClientConnectionfactory from main class, its showing "localhost". How can I confirm if the connection is active?
<int:gateway id="gw"
service-interface="org.springframework.integration.samples.tcpclientserver.SimpleGateway"
default-request-channel="input"/>
<int-ip:tcp-connection-factory id="client" type="client" host="xx.xx.xx.99"
port="9xxx"
single-use="false" so-timeout="300000" using-nio="false"
so-keep-alive="true" serializer="byteArrayRawSerializer"
deserializer="byteArrayRawSerializer"/>
<bean id="byteArrayRawSerializer" class="org.springframework.integration.ip.tcp.serializer.ByteArrayRawSerializer" />
<int-ip:tcp-outbound-gateway id="outGateway"
request-channel="input"
reply-channel="responseBytes2StringChannel"
connection-factory="client"
request-timeout="10000"
reply-timeout="10000" />
<int:object-to-string-transformer id="clientBytes2String"
input-channel="responseBytes2StringChannel" output-channel="toSA"/>
<int:service-activator input-channel="toSA" ref="echoService" method="test"/>
<bean id="echoService" class="org.springframework.integration.samples.tcpclientserver.EchoService"/>
<int:channel id="toSA"/>
<int:transformer id="errorHandler" input-channel="errorChannel" expression="payload.failedMessage.payload + ':' + payload.cause.message"/>
<int:channel id="responseBytes2StringChannel"></int:channel>
**** Update SI xml ****
<int:gateway id="gw"
service-interface="org.springframework.integration.samples.tcpclientserver.SimpleGateway"
default-request-channel="objectIn"/>
<int:channel id="objectIn" />
<int-ip:tcp-connection-factory id="client"
type="client"
host="xx.xx.xx.99"
port="9xxx"
single-use="true"
so-timeout="50000"
using-nio="false"
so-keep-alive="true"/>
<!--
serializer="byteArrayLengthSerializer"
deserializer="byteArrayLengthSerializer"
<bean id="byteArrayLengthSerializer" class="org.springframework.integration.ip.tcp.serializer.ByteArrayLengthHeaderSerializer " />
-->
<int:payload-serializing-transformer input-channel="objectIn" output-channel="objectOut"/>
<int-ip:tcp-outbound-gateway id="outGateway"
request-channel="objectOut"
reply-channel="bytesIn"
connection-factory="client"
request-timeout="10000"
reply-timeout="10000"
/>
<int:payload-deserializing-transformer input-channel="bytesIn" output-channel="objectOut" />
<int:object-to-string-transformer id="clientBytes2String"
input-channel="objectOut" output-channel="toSA"/>
<int:service-activator input-channel="toSA" ref="echoService" method="test"/>
<bean id="echoService" class="org.springframework.integration.samples.tcpclientserver.EchoService"/>
<int:channel id="objectOut"/>
<int:channel id="toSA"/>
<int:channel id="bytesIn"/>
I suggest you to go the Documentation route first: https://docs.spring.io/spring-integration/docs/current/reference/html/ip.html to investigate what Spring Integration provides for you in regards of TCP/IP. Then it would be great to jump into samples project to see what we suggest for configuration and usage options: https://github.com/spring-projects/spring-integration-samples

apache-camel apache-cxf IllegalStateException: Could not register object under bean name 'cxf': there is already object bound

Camel Version: 2.12.2,
CXF Version: 2.7,
Apache Tomcat: 7
I have the following camel-cxf.xml :
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:s0="http://www.huawei.com/bme/cbsinterface/cbs/businessmgr"
xmlns:s1="http://www.huawei.com/bme/cbsinterface/cbs/accountmgr"
xmlns:cxf="http://camel.apache.org/schema/cxf"
xmlns:http-conf="http://cxf.apache.org/transports/http/configuration"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd">
<bean id="loggingInInterceptor" class="org.apache.cxf.interceptor.LoggingInInterceptor" />
<bean id="loggingOutInterceptor" class="org.apache.cxf.interceptor.LoggingOutInterceptor" />
<cxf:cxfEndpoint id="oneEndpoint"
address="${endpoint.address}"
serviceName="s1:WebService"
serviceClass="WebserviceClass"
endpointName="s1:WebSericePort_http"
wsdlURL="classpath:wsdl/WebService.wsdl">
<cxf:inInterceptors>
<ref bean="loggingInInterceptor" />
<ref bean="setSoapVersionInterceptor"/>
</cxf:inInterceptors>
<cxf:inFaultInterceptors>
<ref bean="loggingInInterceptor" />
<ref bean="setSoapVersionInterceptor"/>
</cxf:inFaultInterceptors>
<cxf:outInterceptors>
<ref bean="loggingOutInterceptor" />
</cxf:outInterceptors>
<cxf:outFaultInterceptors>
<ref bean="loggingOutInterceptor" />
</cxf:outFaultInterceptors>
</cxf:cxfEndpoint>
<http-conf:conduit name="*.http-conduit">
<http-conf:client
Connection="Keep-Alive"
ConnectionTimeout="60000"
ReceiveTimeout="90000"/>
</http-conf:conduit>
</beans>
In my camel-context I have two processors that use the cxf endpoint to invoke two different operations. To do that I use a producerTemplate which uses "cxf:bean:oneEndpoint" as a uri.
The project is a web application deployed in Tomcat 7.
The processors consume from two different queues. After deployment both queues are propagated with a message. The problem is that one of the processors will throw an exception upon invoking the send method on the producer template. The other will work fine. The exception is:
org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint:
cxf://bean:oneEndpoint due to: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'oneEndpoint': Initialization of bean failed;
nested exception is java.lang.IllegalStateException: Could not register object [org.apache.cxf.bus.spring.SpringBus#4b0af74c] under bean name 'cxf':
there is already object [org.apache.cxf.bus.spring.SpringBus#24c0fe59] bound
Full stacktrace can be found here: http://pastebin.com/cDsQZ9r3
The second time the queues receive a message at the same time, everything works fine.
Any ideas?
PS. My web.xml is:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:/META-INF/spring/*.xml</param-value>
</context-param>
</web-app>
Routes & Processors:
<route id="route1" errorHandlerRef="eh1">
<from uri="{{queue1}}" />
<setHeader headerName="operationName">
<constant>Operation_1</constant>
</setHeader>
<process ref="FirstProcessor" />
<choice>
<when>
<simple>${in.headers.STATUS} == 'OK'</simple>
<inOnly uri="{{result_queue}}" />
</when>
<otherwise>
<inOnly uri="{{nok_result_queue}}" />
</otherwise>
</choice>
</route>
<route id="route2" errorHandlerRef="eh2">
<from uri="{{queue2}}" />
<setHeader headerName="operationName">
<constant>Operation_2</constant>
</setHeader>
<process ref="SecondProcessor" />
<choice>
<when>
<simple>${in.headers.STATUS} == 'OK'</simple>
<inOnly uri="{{result_queue}}" />
</when>
<otherwise>
<inOnly uri="{{nok_result_queue}}" />
</otherwise>
</choice>
</route>
<property name="producerTemplate" ref="firstProcessorTemplate" />
<property name="producerTemplateUri"
value="cxf:bean:oneEndpoint?headerFilterStrategy=#headerFilterStrategy" />
<property name="producerTemplate" ref="secondProcessorTemplate" />
<property name="producerTemplateUri"
value="cxf:bean:oneEndpoint?headerFilterStrategy=#headerFilterStrategy" />
The problem is that both queues are getting a message at the same time so both of them are trying to initialise the SpringBus at the same time.
The problem is that in BusWiringBeanFactoryPostProcessor it this code:
if (!context.containsBean(name) && (create || Bus.DEFAULT_BUS_ID.equals(name))) {
SpringBus b = new SpringBus();
ConfigurableApplicationContext cctx = (ConfigurableApplicationContext)context;
cctx.getBeanFactory().registerSingleton(name, b);
b.setApplicationContext(context);
}
So when two beans both try and initialise the SpringBus in two different threads, they can both enter the if statement at the same time leading to the exception.
The solution is to define a SpringBus in the application context so neither bean will try create a new SpringBus as one already exists.
Please share the routes definition which consumes messages from two different queues. Also you can look for option of using multicasting to have parallel processing in consuming messages from both queues and proceed with further opertion.<route>
<from uri="cxf:bean:oneEndpoint"></from>
<recipientList>
<simple>direct:${header.operationName}</simple>
<log message="Got ${header.operationName}" />
</recipientList>
</route>
Your routes (route1 and route) can be renamed as same as webservice operation name. Our code is also something similar to yours. We haven't faced problem with this approach.

CAS with WebLogic Authenticates then error with 'principal' cannot be null

I am trying to implement CAS with WebLogic 10.3.5 and not having much luck. Everything I read is about CAS with Tomcat. Have tried the exact config with Tomcat and it works like a dream but those in charge wont change to Tomcat. Anyways....
I can bring up the CAS login screen, and after checking the cas.log it authenticates but then seems to lose the principal.
I am using the maven overlay technique which seems good to begin with.
Also had the standard log4j dramas that everyone seems to have.
Have included stacktrace, deployerConfigContext.xml, pom.xml and weblogic.xml.
Here is the stacktrace:
2014-05-09 15:29:32,000 INFO [org.jasig.cas.ticket.registry.support.DefaultTicketRegistryCleaner] - <Beginning ticket cleanup.>
2014-05-09 15:29:32,000 INFO [org.jasig.cas.ticket.registry.support.DefaultTicketRegistryCleaner] - <0 tickets found to be removed.>
2014-05-09 15:29:32,000 INFO [org.jasig.cas.ticket.registry.support.DefaultTicketRegistryCleaner] - <Finished ticket cleanup.>
2014-05-09 15:29:37,443 INFO [org.jasig.cas.authentication.AuthenticationManagerImpl] - <org.jasig.cas.adaptors.generic.AcceptUsersAuthenticationHandler successfully authenticated [username: kwins]>
2014-05-09 15:29:37,445 INFO [org.jasig.cas.authentication.AuthenticationManagerImpl] - <Resolved principal kwins>
2014-05-09 15:29:37,445 INFO [org.jasig.cas.authentication.AuthenticationManagerImpl] - <org.jasig.cas.adaptors.generic.AcceptUsersAuthenticationHandler#120445d authenticated kwins with credential [username: kwins].>
2014-05-09 15:29:37,458 INFO [com.github.inspektr.audit.support.Slf4jLoggingAuditTrailManager] - <Audit trail record BEGIN
=============================================================
WHO: [username: kwins]
WHAT: supplied credentials: [username: kwins]
ACTION: AUTHENTICATION_SUCCESS
APPLICATION: CAS
WHEN: Fri May 09 15:29:37 EST 2014
CLIENT IP ADDRESS: 192.168.1.140
SERVER IP ADDRESS: 192.168.1.140
=============================================================
>
<09/05/2014 3:29:37 PM EST> <Error> <HTTP> <BEA-101017> <[ServletContext#1230935[app:cas module:cas.war path:/cas spec-version:2.5], request: weblogic.servlet.internal.ServletRequestImpl#2eb99e[
POST /cas/login HTTP/1.1
Connection: keep-alive
Content-Length: 114
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Origin: http://lh11-24.custman.com.au:7001
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.131 Safari/537.36
Content-Type: application/x-www-form-urlencoded
Referer: http://lh11-24.custman.com.au:7001/cas/login
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Cookie: ADMINCONSOLESESSION=J5fJTszB6RS91Y50wpZnqpBbPM7fpp12LQTvcPs1tnkP9GLKhhvT!-2133794881; JSESSIONID=sJ92Ts4pPgvtJPRMDT5zNLjbndXRLNPJCfj9B3x1TGX5J03XlpHN!-317454516
]] Root cause of ServletException.
org.springframework.webflow.execution.ActionExecutionException: Exception thrown executing [AnnotatedAction#1b55376 targetAction = [EvaluateAction#17a89ad expression = authenticationViaFormAction.submit(flowRequestContext, flowScope.credentials, messageContext), resultExpression = [null]], attributes = map[[empty]]] in state 'realSubmit' of flow 'login' -- action execution attributes were 'map[[empty]]'
at org.springframework.webflow.execution.ActionExecutor.execute(ActionExecutor.java:60)
at org.springframework.webflow.engine.ActionState.doEnter(ActionState.java:101)
at org.springframework.webflow.engine.State.enter(State.java:194)
at org.springframework.webflow.engine.Transition.execute(Transition.java:227)
at org.springframework.webflow.engine.impl.FlowExecutionImpl.execute(FlowExecutionImpl.java:393)
Truncated. see log file for complete stacktrace
Caused By: org.springframework.binding.expression.EvaluationException: An OgnlException occurred getting the value for expression 'authenticationViaFormAction.submit(flowRequestContext, flowScope.credentials, messageContext)' on context [class org.springframework.webflow.engine.impl.RequestControlContextImpl]
at org.springframework.binding.expression.ognl.OgnlExpression.getValue(OgnlExpression.java:92)
at org.springframework.webflow.action.EvaluateAction.doExecute(EvaluateAction.java:75)
at org.springframework.webflow.action.AbstractAction.execute(AbstractAction.java:188)
at org.springframework.webflow.execution.AnnotatedAction.execute(AnnotatedAction.java:145)
at org.springframework.webflow.execution.ActionExecutor.execute(ActionExecutor.java:51)
Truncated. see log file for complete stacktrace
Caused By: ognl.MethodFailedException: Method "submit" failed for object org.jasig.cas.web.flow.AuthenticationViaFormAction#ea66aa [java.lang.IllegalArgumentException: 'principal' cannot be null.
Check the correctness of #Audit annotation at the following audit point: execution(public abstract java.lang.String org.jasig.cas.CentralAuthenticationService.createTicketGrantingTicket(org.jasig.cas.authentication.principal.Credentials))]
at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1265)
at ognl.ObjectMethodAccessor.callMethod(ObjectMethodAccessor.java:68)
at ognl.OgnlRuntime.callMethod(OgnlRuntime.java:1329)
at ognl.ASTMethod.getValueBody(ASTMethod.java:90)
at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212)
Truncated. see log file for complete stacktrace
Caused By: java.lang.IllegalArgumentException: 'principal' cannot be null.
Check the correctness of #Audit annotation at the following audit point: execution(public abstract java.lang.String org.jasig.cas.CentralAuthenticationService.createTicketGrantingTicket(org.jasig.cas.authentication.principal.Credentials))
at com.github.inspektr.audit.AuditActionContext.assertNotNull(AuditActionContext.java:81)
at com.github.inspektr.audit.AuditActionContext.<init>(AuditActionContext.java:63)
at com.github.inspektr.audit.AuditTrailManagementAspect.executeAuditCode(AuditTrailManagementAspect.java:149)
at com.github.inspektr.audit.AuditTrailManagementAspect.handleAuditTrail(AuditTrailManagementAspect.java:139)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Truncated. see log file for complete stacktrace
>
deployerConfigContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:sec="http://www.springframework.org/schema/security"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd">
<!-- | This bean declares our AuthenticationManager. The CentralAuthenticationService
service bean | declared in applicationContext.xml picks up this AuthenticationManager
by reference to its id, | "authenticationManager". Most deployers will be
able to use the default AuthenticationManager | implementation and so do
not need to change the class of this bean. We include the whole | AuthenticationManager
here in the userConfigContext.xml so that you can see the things you will
| need to change in context. + -->
<bean id="authenticationManager" class="org.jasig.cas.authentication.AuthenticationManagerImpl">
<!-- Uncomment the metadata populator to allow clearpass to capture and
cache the password This switch effectively will turn on clearpass. <property
name="authenticationMetaDataPopulators"> <list> <bean class="org.jasig.cas.extension.clearpass.CacheCredentialsMetaDataPopulator">
<constructor-arg index="0" ref="credentialsCache" /> </bean> </list> </property> -->
<!-- | This is the List of CredentialToPrincipalResolvers that identify
what Principal is trying to authenticate. | The AuthenticationManagerImpl
considers them in order, finding a CredentialToPrincipalResolver which |
supports the presented credentials. | | AuthenticationManagerImpl uses these
resolvers for two purposes. First, it uses them to identify the Principal
| attempting to authenticate to CAS /login . In the default configuration,
it is the DefaultCredentialsToPrincipalResolver | that fills this role. If
you are using some other kind of credentials than UsernamePasswordCredentials,
you will need to replace | DefaultCredentialsToPrincipalResolver with a CredentialsToPrincipalResolver
that supports the credentials you are | using. | | Second, AuthenticationManagerImpl
uses these resolvers to identify a service requesting a proxy granting ticket.
| In the default configuration, it is the HttpBasedServiceCredentialsToPrincipalResolver
that serves this purpose. | You will need to change this list if you are
identifying services by something more or other than their callback URL.
+ -->
<property name="credentialsToPrincipalResolvers">
<list>
<!-- | UsernamePasswordCredentialsToPrincipalResolver supports the UsernamePasswordCredentials
that we use for /login | by default and produces SimplePrincipal instances
conveying the username from the credentials. | | If you've changed your LoginFormAction
to use credentials other than UsernamePasswordCredentials then you will also
| need to change this bean declaration (or add additional declarations) to
declare a CredentialsToPrincipalResolver that supports the | Credentials
you are using. + -->
<bean
class="org.jasig.cas.authentication.principal.UsernamePasswordCredentialsToPrincipalResolver">
<property name="attributeRepository" ref="attributeRepository" />
</bean>
<!-- | HttpBasedServiceCredentialsToPrincipalResolver supports HttpBasedCredentials.
It supports the CAS 2.0 approach of | authenticating services by SSL callback,
extracting the callback URL from the Credentials and representing it as a
| SimpleService identified by that callback URL. | | If you are representing
services by something more or other than an HTTPS URL whereat they are able
to | receive a proxy callback, you will need to change this bean declaration
(or add additional declarations). + -->
<bean
class="org.jasig.cas.authentication.principal.HttpBasedServiceCredentialsToPrincipalResolver" />
</list>
</property>
<!-- | Whereas CredentialsToPrincipalResolvers identify who it is some
Credentials might authenticate, | AuthenticationHandlers actually authenticate
credentials. Here we declare the AuthenticationHandlers that | authenticate
the Principals that the CredentialsToPrincipalResolvers identified. CAS will
try these handlers in turn | until it finds one that both supports the Credentials
presented and succeeds in authenticating. + -->
<property name="authenticationHandlers">
<list>
<!-- | This is the authentication handler that authenticates services
by means of callback via SSL, thereby validating | a server side SSL certificate.
+ -->
<bean
class="org.jasig.cas.adaptors.generic.AcceptUsersAuthenticationHandler">
<property name="users">
<map>
<entry>
<key>
<value>kwins</value>
</key>
<value>welcome</value>
</entry>
<entry>
<key>
<value>weblogic</value>
</key>
<value>welcome1</value>
</entry>
</map>
</property>
</bean>
<!-- | This is the authentication handler declaration that every CAS
deployer will need to change before deploying CAS | into production. The
default SimpleTestUsernamePasswordAuthenticationHandler authenticates UsernamePasswordCredentials
| where the username equals the password. You will need to replace this with
an AuthenticationHandler that implements your | local authentication strategy.
You might accomplish this by coding a new such handler and declaring | edu.someschool.its.cas.MySpecialHandler
here, or you might use one of the handlers provided in the adaptors modules.
+ -->
<bean
class="org.jasig.cas.authentication.handler.support.SimpleTestUsernamePasswordAuthenticationHandler" />
</list>
</property>
</bean>
<!-- This bean defines the security roles for the Services Management application.
Simple deployments can use the in-memory version. More robust deployments
will want to use another option, such as the Jdbc version. The name of this
should remain "userDetailsService" in order for Spring Security to find it. -->
<!-- <sec:user name="##THIS SHOULD BE REPLACED##" password="notused" authorities="ROLE_ADMIN"
/> -->
<sec:user-service id="userDetailsService">
<sec:user name="weblogic" password="welcome1"
authorities="ROLE_ADMIN" />
</sec:user-service>
<!-- Bean that defines the attributes that a service may return. This example
uses the Stub/Mock version. A real implementation may go against a database
or LDAP server. The id should remain "attributeRepository" though. -->
<bean id="attributeRepository"
class="org.jasig.services.persondir.support.StubPersonAttributeDao">
<property name="backingMap">
<map>
<entry key="uid" value="uid" />
<entry key="eduPersonAffiliation" value="eduPersonAffiliation" />
<entry key="groupMembership" value="groupMembership" />
</map>
</property>
</bean>
<!-- Sample, in-memory data store for the ServiceRegistry. A real implementation
would probably want to replace this with the JPA-backed ServiceRegistry DAO
The name of this bean should remain "serviceRegistryDao". -->
<bean id="serviceRegistryDao" class="org.jasig.cas.services.InMemoryServiceRegistryDaoImpl">
<property name="registeredServices">
<list>
<bean class="org.jasig.cas.services.RegexRegisteredService">
<property name="id" value="0" />
<property name="name" value="HTTP and IMAP" />
<property name="description" value="Allows HTTP(S) and IMAP(S) protocols" />
<property name="serviceId" value="^(https?|imaps?)://.*" />
<property name="evaluationOrder" value="10000001" />
</bean>
<!-- Use the following definition instead of the above to further restrict
access to services within your domain (including subdomains). Note that example.com
must be replaced with the domain you wish to permit. -->
<!-- <bean class="org.jasig.cas.services.RegexRegisteredService"> <property
name="id" value="1" /> <property name="name" value="HTTP and IMAP on example.com"
/> <property name="description" value="Allows HTTP(S) and IMAP(S) protocols
on example.com" /> <property name="serviceId" value="^(https?|imaps?)://([A-Za-z0-9_-]+\.)*example\.com/.*"
/> <property name="evaluationOrder" value="0" /> </bean> -->
</list>
</property>
</bean>
<bean id="auditTrailManager"
class="com.github.inspektr.audit.support.Slf4jLoggingAuditTrailManager" />
<bean id="healthCheckMonitor" class="org.jasig.cas.monitor.HealthCheckMonitor">
<property name="monitors">
<list>
<bean class="org.jasig.cas.monitor.MemoryMonitor"
p:freeMemoryWarnThreshold="10" />
<!-- NOTE The following ticket registries support SessionMonitor: * DefaultTicketRegistry
* JpaTicketRegistry Remove this monitor if you use an unsupported registry. -->
<bean class="org.jasig.cas.monitor.SessionMonitor"
p:ticketRegistry-ref="ticketRegistry"
p:serviceTicketCountWarnThreshold="5000"
p:sessionCountWarnThreshold="100000" />
</list>
</property>
</bean>
</beans>
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>portal</groupId>
<artifactId>cas-portal</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>cas-portal</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<warName>cas</warName>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.jasig.cas</groupId>
<artifactId>cas-server-webapp</artifactId>
<version>${cas.version}</version>
<type>war</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>1.0.b2</version>
<scope>provided</scope>
</dependency>
<!-- <dependency> <groupId>org.jasig.cas</groupId> <artifactId>cas-server-support-ldap</artifactId>
<version>${cas.version}</version> <exclusions> <exclusion> <artifactId>xml-apis</artifactId>
<groupId>xml-apis</groupId> </exclusion> <exclusion> <artifactId>opensaml</artifactId>
<groupId>org.opensaml</groupId> </exclusion> </exclusions> </dependency> -->
<dependency>
<groupId>org.jasig.cas</groupId>
<artifactId>cas-server-support-generic</artifactId>
<version>${cas.version}</version>
<type>jar</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
<scope>runtime</scope>
</dependency>
</dependencies>
<properties>
<cas.version>3.5.2.1</cas.version>
</properties>
<repositories>
<repository>
<id>ja-sig</id>
<url>http://oss.sonatype.org/content/repositories/releases/ </url>
</repository>
</repositories>
</project>
weblogic.xml
<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-web-app xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.2/weblogic-web-app.xsd">
<wls:context-root>cas</wls:context-root>
<wls:weblogic-version>10.3.5.0</wls:weblogic-version>
<wls:container-descriptor>
<wls:prefer-application-packages>
<wls:package-name>javax.xml.parsers.SAXParserFactory</wls:package-name>
<wls:package-name>org.opensaml.*</wls:package-name>
</wls:prefer-application-packages>
</wls:container-descriptor>
</wls:weblogic-web-app>

Transforming HL7 v2 to XML using apache camel routes

I am new to HL7 .I have to convert the HL7v2 to XML using apache camel routes.I am extracting the HL7 message from file.
Can any one help me how to convert HL7 to XML
There is an HL7 component for unmarshalling the file into a HAPI message. The HAPI api also includes an XMLParser that will convert the message into xml. So you should be able to combine the two into a simple camel route like the following:
<bean id="hl7XmlConverter" class="example.Hl7XmlConverter" />
<bean id="hl7FileFilter"
class="org.apache.camel.component.file.AntPathMatcherGenericFileFilter">
<property name="includes" value="*.hl7" />
</bean>
<camelContext xmlns="http://camel.apache.org/schema/spring">
<route id="hl7FileRoute">
<from
uri="file:///tmp/test/?delete=true&moveFailed=.error&filter=#hl7FileFilter" />
<convertBodyTo type="java.lang.String" />
<log message="HL7 Request: ${body}" />
<unmarshal>
<hl7 validate="true" />
</unmarshal>
<bean ref="hl7XmlConverter"/>
<log message="HL7 Response: ${body}" />
</route>
</camelContext>
Where the bean is just a simple method:
public String convertMessage(Message message) throws HL7Exception{
XMLParser parser = new DefaultXMLParser();
return parser.encode(message);
}
Depending on your desired xml format, you could also add an xslt after the bean.

Having trouble with content based routing in Camel with a CXFRS endpoint and xPath

I am trying to create a route that is determined by the content in the REST payload using xPath. I have been successful in using routing based on the message header:
<when>
<simple>${headers.operationName} == 'createContainerOutput'</simple>
<bean ref="containerOutputProcessor"/>
</when>
which properly invokes the containerOutputProcessor...
but for this xPath route:
<when>
<xpath>/*[local-name()='order-request']/#type='TrayOutput'</xpath>
<bean ref="containerOutputProcessor"/>
</when>
I get the the exception:
org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert from type: org.apache.cxf.message.MessageContentsList to the required type: org.w3c.dom.Document with value [com.mmi.ws.ContainerOutputOrderRequest#6290dc]
for this payload
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<order-request type="TrayOutput">
<parameter name="orderName">Example Tray Output Order</parameter>
<parameter name="enableScan">true</parameter>
<parameter name="autoStart">false</parameter>
<parameter name="priority">3</parameter>
<item barcode="23990001"/>
<item barcode="23990002"/>
</order-request>
Is this type of routing a good idea? Is there a better way to route based on what type of order-request is being submitted?
Thanks for any help/guidance you may have for me!
Here is the complete context
<?xml version='1.0' encoding='UTF-8'?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xmlns:cxf="http://camel.apache.org/schema/cxf"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd">
<!-- enable Spring #Component scan -->
<context:component-scan base-package="com.mmi.ws"/>
<!-- web service beans -->
<bean id="containerOutputWS" class="com.mmi.ws.service.impl.ContainerOutputWSImpl" />
<bean id="containerTypesWS" class="com.mmi.ws.service.impl.ContainerTypesWSImpl" />
<!-- processor beans -->
<bean id="containerOutputProcessor" class="com.mmi.ws.service.ContainerOutputProcessor" />
<bean id="containerTypesProcessor" class="com.mmi.ws.service.ContainerTypesProcessor" />
<bean id="unsupportedPathProcessor" class="com.mmi.ws.service.UnsupportedPathProcessor" />
<!-- Define the real JAXRS back end service -->
<jaxrs:server id="restService"
address="http://localhost:9998/sc"
staticSubresourceResolution="true">
<jaxrs:serviceBeans>
<ref bean="containerOutputWS"/>
<ref bean="containerTypesWS"/>
</jaxrs:serviceBeans>
</jaxrs:server>
<!-- define the restful server and client endpoints -->
<cxf:rsServer id="rsServer" address="http://localhost:9999/sc" loggingFeatureEnabled="true" loggingSizeLimit="20">
<cxf:serviceBeans >
<ref bean="containerOutputWS"/>
<ref bean="containerTypesWS"/>
</cxf:serviceBeans>
</cxf:rsServer>
<cxf:rsServer id="rsClient" address="http://localhost:9998/sc" loggingFeatureEnabled="true" loggingSizeLimit="20">
<cxf:serviceBeans >
<ref bean="containerOutputWS"/>
<ref bean="containerTypesWS"/>
</cxf:serviceBeans>
</cxf:rsServer>
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<!--
any classes in the below 'packageScan'packages that extends RouteBuilder
will be added as a camel route. At least one route is required to start the cxf web service
-->
<packageScan>
<package>com.mmi.ws</package>
</packageScan>
<dataFormats>
<xstream id="xstream-utf8" encoding="UTF-8"/>
<xstream id="xstream-default"/>
</dataFormats>
<!-- route starts from the cxf webservice -->
<route streamCache="true">
<from uri="cxfrs://bean://rsServer"/>
<log message="XML payload to send to REST WS:${body}" />
<setHeader headerName="CamelCxfRsUsingHttpAPI"><constant>True</constant> </setHeader>
<choice>
<when>
<simple>${headers.operationName} == 'getContainers'</simple>
<bean ref="containerTypesProcessor"/>
</when>
<when>
<xpath>/*[local-name()='order-request']/#type='TrayOutput'</xpath>
<bean ref="containerOutputProcessor"/>
</when>
<otherwise>
<bean ref="unsupportedPathProcessor"/>
<to uri="cxfrs://bean://rsClient"/>
</otherwise>
</choice>
</route>
</camelContext>
</beans>
and the web service class:
#Path("/container/output/")
public class ContainerOutputWSImpl
{
#POST
#Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
#Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public ContainerOutputView createContainerOutput(ContainerOutputOrderRequest containerOutput) {
// TODO Auto-generated method stub
return new ContainerOutputView();
}
}
and finally, the xml payload and error stack:
Address: http://localhost:9999/sc/container/output/
Encoding: ISO-8859-1
Http-Method: POST
Content-Type: application/xml
Headers: {accept-encoding=[gzip,deflate], connection=[keep-alive], Content-Length=[384], content-type=[application/xml], Host=[localhost:9999], User-Agent=[Apache-HttpClient/4.1.1 (java 1.5)]}
Payload: <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<order-request type="TrayOutput">
<parameter name="orderName">Example Tray Output Order</parameter>
<parameter name="enableScan">true</parameter>
<parameter name="autoStart">false</parameter>
<parameter name="priority">3</parameter>
<item barcode="23990001"/>
<item barcode="23990002"/>
</order-request>
--------------------------------------
[ERROR] 2013-02-07 17:53:37.059 [qtp27633254-28: DefaultErrorHandler] Failed delivery for (MessageId: ID-PWY-EHANSEN-3070-1360288389778-0-2 on ExchangeId: ID-PWY-EHANSEN-3070-1360288389778-0-1). Exhausted after delivery attempt: 1 caught: org.apache.camel.RuntimeCamelException: org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert from type: org.apache.cxf.message.MessageContentsList to the required type: org.w3c.dom.Document with value [com.mmi.ws.ContainerOutputOrderRequest#9fbbe5]
org.apache.camel.RuntimeCamelException: org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert from type: org.apache.cxf.message.MessageContentsList to the required type: org.w3c.dom.Document with value [com.mmi.ws.ContainerOutputOrderRequest#9fbbe5]
at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1271)
at org.apache.camel.builder.xml.XPathBuilder.getDocument(XPathBuilder.java:1027)
at org.apache.camel.builder.xml.XPathBuilder.doInEvaluateAs(XPathBuilder.java:850)
at org.apache.camel.builder.xml.XPathBuilder.evaluateAs(XPathBuilder.java:757)
at org.apache.camel.builder.xml.XPathBuilder.matches(XPathBuilder.java:145)
at org.apache.camel.processor.ChoiceProcessor.process(ChoiceProcessor.java:66)
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:73)
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
at org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:91)
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
at org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:334)
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:220)
at org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:52)
at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
at org.apache.camel.processor.interceptor.DefaultChannel.process(DefaultChannel.java:303)
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:117)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)
at org.apache.camel.processor.RouteContextProcessor.processNext(RouteContextProcessor.java:45)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
at org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:150)
at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:117)
at org.apache.camel.processor.RouteInflightRepositoryProcessor.processNext(RouteInflightRepositoryProcessor.java:48)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)
at org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:99)
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:90)
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:73)
at org.apache.camel.component.cxf.jaxrs.CxfRsInvoker.asyncInvoke(CxfRsInvoker.java:87)
at org.apache.camel.component.cxf.jaxrs.CxfRsInvoker.performInvocation(CxfRsInvoker.java:57)
at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96)
at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:201)
at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:102)
at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:94)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.serviceRequest(JettyHTTPDestination.java:355)
at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(JettyHTTPDestination.java:319)
at org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(JettyHTTPHandler.java:72)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1074)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1010)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:365)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:485)
at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:937)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:998)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:856)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:627)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:51)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Thread.java:722)
Before the content based router, you can convert the message to take out the payload from the internal CXF list. There is a trick with the simple language to grab the first index from the list:
<transform>
<simple>${body[0]}</simple>
</transform>
<choice>
...
Do you have camel-jaxb on the classpath. If so it may work out of the box without that trick. Not sure though, as CXF is a bit special. Also dependes on what version of Camel / CXF you use. You should really mention this when you ask questions!

Resources