How do I access username and password in a Camel processor when using Spring Security with Camel on EAP?
Issue
- I used a reference example
camel-example-spring-securitylisted in: http://camel.apache.org/spring-security-example.html - Now I am wondering how I pass username and password in my client code so that my Camel processor can access it:
- In code below, however,
username,passwordare coming asnull:
String username = exchange.getIn().getHeader("username", String.class);
String password = exchange.getIn().getHeader("password", String.class);
Authentication authToken = new UsernamePasswordAuthenticationToken(username, password);
SecurityContextHolder.getContext().setAuthentication(authToken);
- When I call
setAuthentication()method everything seems to be working except I just need a way to collect username and password fromExchanges's header. - If I do not call
setAuthentication(), I get an errororg.apache.camel.Camel.AuthorizationException: Cannot find the Authentication instance. I believe the cause is, it cannot findExchange.AUTHENTICATIONin the message header. - How can I access username and password from the message header?
Environment
- Red Hat JBoss Enterprise Application Platform (EAP)
- 6.x
- Red Hat JBoss Fuse Service Works (FSW)
- 6.x
- Red Hat JBoss Fuse (Fuse)
- 6.x
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
