Sending Messages to routes secured by a ShiroSecurityPolicy

Talend ESB Mediation Developer Guide

EnrichVersion
6.2
EnrichProdName
Talend ESB
task
Installation and Upgrade
Design and Development
EnrichPlatform
Talend ESB

Messages and Message Exchanges sent along the Camel route where the security policy is applied need to be accompanied by a SecurityToken in the Exchange Header. The SecurityToken is an encrypted object that holds a Username and Password. The SecurityToken is encrypted using AES 128 bit security by default and can be changed to any cipher of your choice.

Given below is an example of how a request may be sent using a ProducerTemplate in Camel along with a SecurityToken

@Test
public void testSuccessfulShiroAuthenticationWithNoAuthorization() 
   throws Exception {        

   //Incorrect password
   ShiroSecurityToken shiroSecurityToken = 
      new ShiroSecurityToken("ringo", "stirr");

   // TestShiroSecurityTokenInjector extends ShiroSecurityTokenInjector
   TestShiroSecurityTokenInjector shiroSecurityTokenInjector = 
      new TestShiroSecurityTokenInjector(shiroSecurityToken, passPhrase);

   successEndpoint.expectedMessageCount(1);
   failureEndpoint.expectedMessageCount(0);

   template.send("direct:secureEndpoint", shiroSecurityTokenInjector);

   successEndpoint.assertIsSatisfied();
   failureEndpoint.assertIsSatisfied();
}