302.5. 在 Camel 路由中应用 Shiro 授权
通过将 Permissions List 与 ShiroSecurityPolicy 关联,授权可以在 camel 路由上应用。Permissions List 指定用户执行路由片段所需的权限。如果用户未设置适当的权限,则请求将无法继续。
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"); } }; }