Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/security/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 启用/禁用Shiro安全性-Apache Camel_Java_Security_Apache Camel_Shiro_Blueprint Osgi - Fatal编程技术网

Java 启用/禁用Shiro安全性-Apache Camel

Java 启用/禁用Shiro安全性-Apache Camel,java,security,apache-camel,shiro,blueprint-osgi,Java,Security,Apache Camel,Shiro,Blueprint Osgi,我正在使用Apache Camel路由,我想启用/禁用Shiro安全性 这是路线(blueprint.xml): 在这种情况下,启用了安全性。如何禁用它?是否有打开/关闭的选项 我在寻找解决骆驼西罗问题的方法时偶然发现了这个问题。希望回应不会太晚 在apache camel中没有选项/属性来设置shiro安全性的开/关。您也可以通过如下所示在路由设置中包括一个选项,并在注入安全令牌的同时注入on/off选项作为标头属性来实现这一点: <route> <from uri="bea

我正在使用Apache Camel路由,我想启用/禁用Shiro安全性

这是路线(blueprint.xml):


在这种情况下,启用了安全性。如何禁用它?是否有打开/关闭的选项

我在寻找解决骆驼西罗问题的方法时偶然发现了这个问题。希望回应不会太晚

在apache camel中没有选项/属性来设置shiro安全性的开/关。您也可以通过如下所示在路由设置中包括一个选项,并在注入安全令牌的同时注入on/off选项作为标头属性来实现这一点:

<route>
<from uri="bean:com.ngt.secured.ShiroSecurity?method=tokeninject(Exchange)"/>
<choice>
    <when>
        <simple>${in.header.isSecured} == 'true'</simple>
        <policy ref="shiroPolicy">
            <to uri="bean:com.ngt.secured.transform?method=addrip(Exchange)"/>
             ...
             some process..
        </policy>
    </when>
    <otherwise>
        <to uri="bean:com.ngt.secured.transform?method=addrip(Exchange)"/>
         ...
         some process..
    </otherwise>
</choice>            
</route>

public void process(Exchange exchange) throws Exception {
    exchange.getIn().setHeader("SHIRO_SECURITY_TOKEN", encrypt());
    exchange.getIn().setHeader("isSecured", Boolean.FALSE);
    //exchange.getIn().setBody("Beatle Mania");
}

${in.header.isSecured}=='true'
...
一些过程。。
...
一些过程。。
公共作废进程(Exchange)引发异常{
setHeader(“SHIRO_SECURITY_TOKEN”,encrypt());
exchange.getIn().setHeader(“isSecured”,Boolean.FALSE);
//exchange.getIn().setBody(“披头士狂热”);
}
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");
                    }
           }
<route>
<from uri="bean:com.ngt.secured.ShiroSecurity?method=tokeninject(Exchange)"/>
<choice>
    <when>
        <simple>${in.header.isSecured} == 'true'</simple>
        <policy ref="shiroPolicy">
            <to uri="bean:com.ngt.secured.transform?method=addrip(Exchange)"/>
             ...
             some process..
        </policy>
    </when>
    <otherwise>
        <to uri="bean:com.ngt.secured.transform?method=addrip(Exchange)"/>
         ...
         some process..
    </otherwise>
</choice>            
</route>

public void process(Exchange exchange) throws Exception {
    exchange.getIn().setHeader("SHIRO_SECURITY_TOKEN", encrypt());
    exchange.getIn().setHeader("isSecured", Boolean.FALSE);
    //exchange.getIn().setBody("Beatle Mania");
}