You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2016/08/22 19:13:50 UTC
[2/2] camel git commit: Fixed spring-security example. Thanks to
Olivier Delobre for the patch.
Fixed spring-security example. Thanks to Olivier Delobre for the patch.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/f28d32e0
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/f28d32e0
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/f28d32e0
Branch: refs/heads/camel-2.17.x
Commit: f28d32e02cbb917ed3b243c5f2d72c81a2e72f70
Parents: 0a186cb
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Aug 22 21:11:51 2016 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Aug 22 21:13:18 2016 +0200
----------------------------------------------------------------------
.../camel-example-spring-security/README.md | 7 ++--
examples/camel-example-spring-security/pom.xml | 36 +++++---------------
.../src/main/resources/camel-context.xml | 11 +++---
3 files changed, 15 insertions(+), 39 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/f28d32e0/examples/camel-example-spring-security/README.md
----------------------------------------------------------------------
diff --git a/examples/camel-example-spring-security/README.md b/examples/camel-example-spring-security/README.md
index 3b15376..eb6d828 100644
--- a/examples/camel-example-spring-security/README.md
+++ b/examples/camel-example-spring-security/README.md
@@ -1,6 +1,7 @@
# Camel Spring Security Example
### Introduction
+
This example shows how to leverage the Spring Security to secure the camel endpoint.
@@ -10,11 +11,7 @@ You will need to compile this example first:
mvn clean install
### Run
-To run the example, you need to start up the server by typing
-
- mvn jetty:run
-
-To stop the server hit <kbd>ctrl</kbd>+<kbd>c</kbd>
+To run the example, you need to start up the server and copy the .war to the application server
The example consumes messages from a servlet endpoint which is secured by Spring Security
with http basic authentication, there are two service:
http://git-wip-us.apache.org/repos/asf/camel/blob/f28d32e0/examples/camel-example-spring-security/pom.xml
----------------------------------------------------------------------
diff --git a/examples/camel-example-spring-security/pom.xml b/examples/camel-example-spring-security/pom.xml
index 698fa46..e03eac9 100755
--- a/examples/camel-example-spring-security/pom.xml
+++ b/examples/camel-example-spring-security/pom.xml
@@ -48,14 +48,14 @@
<artifactId>camel-servlet</artifactId>
</dependency>
<dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-web</artifactId>
- </dependency>
- <!-- logging -->
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- </dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-web</artifactId>
+ </dependency>
+ <!-- logging -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
@@ -70,24 +70,4 @@
</dependencies>
- <build>
- <plugins>
- <!-- so we can run mvn jetty:run -->
- <plugin>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>jetty-maven-plugin</artifactId>
- <version>${jetty-plugin-version}</version>
- <configuration>
- <connectors>
- <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
- <port>8080</port>
- <maxIdleTime>60000</maxIdleTime>
- </connector>
- </connectors>
- </configuration>
- </plugin>
- </plugins>
-
- </build>
-
</project>
http://git-wip-us.apache.org/repos/asf/camel/blob/f28d32e0/examples/camel-example-spring-security/src/main/resources/camel-context.xml
----------------------------------------------------------------------
diff --git a/examples/camel-example-spring-security/src/main/resources/camel-context.xml b/examples/camel-example-spring-security/src/main/resources/camel-context.xml
index d51dc0a..286ca49 100644
--- a/examples/camel-example-spring-security/src/main/resources/camel-context.xml
+++ b/examples/camel-example-spring-security/src/main/resources/camel-context.xml
@@ -26,7 +26,8 @@
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd">
<spring-security:http realm="User Restrict Realm">
- <spring-security:intercept-url pattern="/camel/**" access="ROLE_USER"/>
+ <spring-security:intercept-url pattern="/camel/**"
+ access="hasRole('ROLE_USER') or hasRole('ROLE_ADMIN')"/>
<spring-security:http-basic/>
<spring-security:remember-me/>
</spring-security:http>
@@ -42,12 +43,10 @@
</spring-security:user-service>
<bean id="accessDecisionManager" class="org.springframework.security.access.vote.AffirmativeBased">
+ <constructor-arg>
+ <bean class="org.springframework.security.access.vote.RoleVoter"/>
+ </constructor-arg>
<property name="allowIfAllAbstainDecisions" value="true"/>
- <property name="decisionVoters">
- <list>
- <bean class="org.springframework.security.access.vote.RoleVoter"/>
- </list>
- </property>
</bean>
<!-- The Policy for checking the authentication role of ADMIN -->