303.5. 在 Camel 路由中应用 Shiro 授权
通过将一个 Permissions 列表与 ShiroSecurityPolicy 关联,可以将授权应用到 camel 路由。Permissions 列表指定执行路由片段的用户所需的权限。如果用户没有设置正确的权限,则请求不会被授权来进一步继续。
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"); } }; }