Applying Shiro Authorization on a Camel Route - 6.3

Talend ESB Mediation Developer Guide

EnrichVersion
6.3
EnrichProdName
Talend Data Fabric
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for ESB
Talend Real-Time Big Data Platform
task
Design and Development
EnrichPlatform
Talend ESB

Authorization can be applied on a Camel route by associating a Permissions List with the ShiroSecurityPolicy. The Permissions List specifies the permissions necessary for the user to proceed with the execution of the route segment. If the user does not have the proper permission set, the request is not authorized to continue any further.

protected RouteBuilder createRouteBuilder() throws Exception {
   final ShiroSecurityPolicy securityPolicy = 
      new ShiroSecurityPolicy("./src/test/resources/securityconfig.ini", 
      passPhrase);
        
   return new RouteBuilder() {
      public void configure() {
         onException(UnknownAccountException.class)
            .to("mock:authenticationException");
         onException(IncorrectCredentialsException.class)
            .to("mock:authenticationException");
         onException(LockedAccountException.class)
            .to("mock:authenticationException");
         onException(AuthenticationException.class)
            .to("mock:authenticationException");
             
         from("direct:secureEndpoint")
            .to("log:incoming payload")
            .policy(securityPolicy)
            .to("mock:success");
      }
   };
}