spring整合rmi 如何使用安全策略
2016-12-30 10:01
561 查看
spring整合rmi 后,想要使用安全策略,之后是自己写一个rmi.policy文件,里面写着授权哪些IP有哪些权限,但是我要怎么导入到spring中呢?
这个问题真的木有人会吗?
我要限制连接RMI的IP,要如何限制,结合SPRING配置。如何弄?
不用policy文件,用spring的interceptor试试:
rmisecuritymanager
这个问题真的木有人会吗?
我要限制连接RMI的IP,要如何限制,结合SPRING配置。如何弄?
不用policy文件,用spring的interceptor试试:
<bean class="org.springframework.remoting.rmi.RmiServiceExporter"> <property name="serviceName" value="testService" /> <property name="service" ref="testService" /> <property name="serviceInterface" value="test.ITestService" /> <property name="registryPort" value="1199" /> <property name="interceptors"> <list><ref bean="securityInterceptor"/></list> </property> </bean> <bean id="securityInterceptor" class="test.SecurityInterceptor"> <!-- 这里配置允许访问RMI的客户端IP地址 --> <property name="allowed"> <set> <value>192.168.0.1</value> <value>192.168.0.2</value> </set> </property> </bean>
package test; import java.rmi.server.RemoteServer; import java.util.Set; import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; public class SecurityInterceptor implements MethodInterceptor { private Set allowed; public Object invoke(MethodInvocation methodInvocation) throws Throwable { String clientHost = RemoteServer.getClientHost(); if (allowed != null && allowed.contains(clientHost)) { return methodInvocation.proceed(); } else { throw new SecurityException("非法访问。"); } } public void setAllowed(Set allowed) { this.allowed = allowed; } }
rmisecuritymanager
Using Spring Security in a Swing Desktop
https://sacrephill.wordpress.com/2009/06/12/using-spring-security-in-a-swing-desktop-application/相关文章推荐
- spring 整合 redis,以及spring的RedisTemplate如何使用
- Hibernate整合Spring后,如何使用SchemaExport生成数据库表
- 在使用Spring整合Quartz中,如何关闭不断输出的内容?
- spring 整合 redis,以及spring的RedisTemplate如何使用
- 如何整合Spring和Mybatis的思路分析(使用面向接口的mapper代理,不用再去写Dao的实现类)
- Spring Scope:Web项目中如何安全使用有状态的Bean对象?
- Spring Boot 整合mybatis 如何使用多数据源
- Spring Boot如何使用Spring Security进行安全控制(十一)
- spring 整合 redis,以及spring的RedisTemplate如何使用
- spring 整合 redis,以及spring的RedisTemplate如何使用
- 11.(此处为以上综合精华)如何使用ActiveMQ,以及spring+jms下整合
- spring Boot 整合mybatis 如何使用多数据源
- spring 整合 redis,以及spring的RedisTemplate如何使用
- ssh整合系列博客——(3)在jsp中如何使用spring管理的bean
- Spring Boot如何使用Spring Security进行安全控制
- Spring整合使用RMI-HelloWorld例子
- spring 整合 redis,以及spring的RedisTemplate如何使用
- spring 整合 redis,以及spring的RedisTemplate如何使用
- mybatis3整合spring后如何使用自带连接池
- 使用JSF+Spring整合