OSGI 上的 Shiro 注解
Shiro annotation on OSGI
我 运行 Karaf 4.0.4 上的 OSGI 应用程序。
此应用程序不是 Web 应用程序。
我配置 Apache Shiro 以便使用自定义 SecurityRealm
登录,该自定义 SecurityRealm
使用存储在 SQL 数据库中的凭据。 SecurityManager
和领域是使用蓝图配置的
这部分工作正常。
我想使用如下注释:
@RequiresPermissions("doSomething")
@RequiresRoles("admin")
public void myMethodToDoSomething() {
...
}
永远不会评估这些注释。 (我的安全领域 protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals)
方法从未被调用。
阅读了一些 Shiro 文档后,我知道它不起作用,因为我没有 Shiro Spring turorial 中定义的所需拦截器:
<!-- Enable Shiro Annotations for Spring-configured beans. Only run after -->
<!-- the lifecycleBeanProcessor has run: -->
<bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator" depends-on="lifecycleBeanPostProcessor"/>
<bean class="org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor">
<property name="securityManager" ref="securityManager"/>
但是由于我没有在我的应用程序中使用 spring,这些行将不起作用。
您可以创建蓝图命名空间模块。然后可以挂接到蓝图 bean 以安装拦截器。作为示例,请参见 blueprint-authz module。
我 运行 Karaf 4.0.4 上的 OSGI 应用程序。 此应用程序不是 Web 应用程序。
我配置 Apache Shiro 以便使用自定义 SecurityRealm
登录,该自定义 SecurityRealm
使用存储在 SQL 数据库中的凭据。 SecurityManager
和领域是使用蓝图配置的
这部分工作正常。
我想使用如下注释:
@RequiresPermissions("doSomething")
@RequiresRoles("admin")
public void myMethodToDoSomething() {
...
}
永远不会评估这些注释。 (我的安全领域 protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals)
方法从未被调用。
阅读了一些 Shiro 文档后,我知道它不起作用,因为我没有 Shiro Spring turorial 中定义的所需拦截器:
<!-- Enable Shiro Annotations for Spring-configured beans. Only run after -->
<!-- the lifecycleBeanProcessor has run: -->
<bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator" depends-on="lifecycleBeanPostProcessor"/>
<bean class="org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor">
<property name="securityManager" ref="securityManager"/>
但是由于我没有在我的应用程序中使用 spring,这些行将不起作用。
您可以创建蓝图命名空间模块。然后可以挂接到蓝图 bean 以安装拦截器。作为示例,请参见 blueprint-authz module。