【发布时间】:2016-11-11 03:22:00
【问题描述】:
我正在使用 Apache Camel 路由,我想启用/禁用 Shiro 安全性。
这是路线(blueprint.xml):
<bean id="shiroPolicy" class="org.apache.camel.component.shiro.security.ShiroSecurityPolicy">
<argument value="shiro.ini"/>
</bean>
<route>
<from uri="bean:com.ngt.secured.ShiroSecurity?method=tokeninject(Exchange)"/>
<policy ref="shiroPolicy">
<to uri="bean:com.ngt.secured.transform?method=addrip(Exchange)"/>
...
some process..
</policy>
</route>
这是令牌注入(ShiroSecurity.java):
public void tokeninject(Exchange exchange) throws Exception
{
ShiroSecurityToken shiroSecurityToken = new ShiroSecurityToken(login,password);
TestShiroSecurityTokenInjector shiroSecurityTokenInjector = new TestShiroSecurityTokenInjector(shiroSecurityToken, passPhrase);
shiroSecurityTokenInjector.process(exchange);
}
private static class TestShiroSecurityTokenInjector extends ShiroSecurityTokenInjector {
public TestShiroSecurityTokenInjector(ShiroSecurityToken shiroSecurityToken, byte[] bytes)
{
super(shiroSecurityToken, bytes);
}
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader("SHIRO_SECURITY_TOKEN", encrypt());
//exchange.getIn().setBody("Beatle Mania");
}
}
在这种情况下,启用了安全性。如何禁用它?有设置开/关的选项吗?
【问题讨论】:
标签: java security apache-camel shiro blueprint-osgi