对接oauth,需要再现在shiro.ini里,将下面的形式改造,怎么改造,迷茫了。。。求教
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd">
<bean id="oauth2Settings" class="cn.lamppa.pcloud.auth.client.shiro.oauth2.OAuth2Settings">
<property name="currentApplicationUrl" value="${oauth.current-application.url}"/>
<property name="authzEndpoint" value="${oauth.authz-endpoint}"/>
<property name="tokenEndpoint" value="${oauth.token-endpoint}"/>
<property name="logoutEndpoint" value="${oauth.logout-endpoint}"/>
<property name="clientId" value="${oauth.client-id}"/>
<property name="clientSecret" value="${oauth.client-secret}"/>
<property name="redirectUri" value="${oauth.redirect-uri}"/>
<property name="userInfoUrl" value="${oauth.user-info-url}"/>
<property name="scope" value="${oauth.scope}"/>
<property name="applicationResourcesUrl" value="${oauth.resources-application-url}"/>
<property name="userResourcesUrl" value="${oauth.resources-user-url}"/>
</bean>
<bean id="customSettingsApi20" class="cn.lamppa.pcloud.auth.client.shiro.oauth2.CustomSettingsApi20">
<constructor-arg ref="oauth2Settings"/>
</bean>
<bean id="oauth20Service" class="cn.lamppa.pcloud.auth.client.shiro.oauth2.CustomOAuth20Service">
<constructor-arg ref="customSettingsApi20"/>
</bean>
<!-- 继承自AuthorizingRealm的自定义Realm -->
<bean id="oauth2Realm" class="cn.lamppa.pcloud.auth.client.shiro.oauth2.OAuth2Realm">
<constructor-arg ref="oauth20Service"/>
</bean>
<!-- 定义缓存管理器 -->
<bean id="cacheManager" class="org.apache.shiro.cache.MemoryConstrainedCacheManager"/>
<!-- 会话管理器 -->
<bean id="sessionManager" class="org.apache.shiro.web.session.mgt.ServletContainerSessionManager"/>
<!-- 安全管理器 -->
<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
<property name="realm" ref="oauth2Realm"/>
<property name="sessionManager" ref="sessionManager"/>
<property name="cacheManager" ref="cacheManager"/>
</bean>
<!--Shiro可控制的Web请求必须经过Shiro主过滤器的拦截-->
<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
<!-- Shiro的核心安全接口,这个属性是必须的 -->
<property name="securityManager" ref="securityManager"/>
<!-- 要求登录时的链接(可根据项目的URL进行替换)-->
<property name="loginUrl" value="/login"/>
<!-- 登录成功后要跳转的连接 -->
<property name="successUrl" value="/index.jhtml"/>
<!-- 用户访问未对其授权的资源时页面 -->
<property name="unauthorizedUrl" value="/unauthorized.html"/>
<!-- 自定义shiro 的 Filter -->
<property name="filters">
<map>
<entry key="oauth">
<bean class="cn.lamppa.pcloud.auth.client.shiro.oauth2.OAuth2AuthenticationFilter">
<constructor-arg ref="cacheManager"/>
</bean>
</entry>
<entry key="logout">
<bean class="cn.lamppa.pcloud.auth.client.shiro.oauth2.EnhancedLogoutFilter">
<constructor-arg index="0" ref="oauth2Settings"/>
<constructor-arg index="1" ref="cacheManager"/>
</bean>
</entry>
<entry key="resource">
<bean class="cn.lamppa.pcloud.auth.client.shiro.oauth2.ResourceFilter"/>
</entry>
</map>
</property>
<!-- Shiro连接约束配置(即过滤链定义) -->
<property name="filterChainDefinitions">
<value>
/login = authc
/oauth = oauth
/logout = logout
/** = user,resource
</value>
</property>
</bean>
<!-- 保证实现了Shiro内部lifecycle函数的bean执行 -->
<bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor"/>
</beans>