Authentication and authorization using Spring Security

This recipe will show how using the Spring Security framework you can authenticate credentials passed into a route on an exchange, and determine whether that user/system (Principal in security terms) is authorized to access the route based on their role.

Getting ready

The Java code for this recipe is located in the org.camelcookbook.security.springsecurity package. The Spring XML files are located under src/main/resources/META-INF/spring and prefixed with springSecurity.

To use Camel's Spring Security Component, add the following to the dependencies section of your Maven POM:

<dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-spring-security</artifactId> <version>${camel-version}</version> ...

Get Apache Camel Developer's Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.