303.5. 在 Camel Route 上应用 Shiro 授权
授权可以通过将权限列表与 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"); } }; }