2016-11-29 6 views
-1

Apache Shiro와 Stormpath를 사용하여 Spring Web MVC 프로젝트를 보호하려고합니다. 웹 튜토리얼을 통해 shiro.ini 파일 예제를 통해 예제 구성을 얻었고 Shiro를 Spring의 applicationContext.xml을 통해 구성했습니다. 두 방법 모두에서 동일한 결과를 얻으려고합니다. 여기 shiro.ini 파일이다 :Stormpath API를 통해 사용자 관리가 이루어지는 Apache Shiro를 사용하여 Spring Web MVC를 보호하려고합니다.

[주]

shiro.loginUrl = 관리/login.htm

authc.successUrl = /admin/index.htm

cacheManager = org.apache.shiro.cache.MemoryConstrainedCacheManager

securityManager.cacheManager = $ cacheManager

stormpathClient = com.stormpath.shiro.client.ClientFactory

stormpathClient.cacheManager = $ cacheManager

stormpathClient.apiKeyFileLocation = $ HOME/.stormpath/apiKey.properties

stormpathRealm = com.stormpath .shiro.realm.ApplicationRealm

stormpathRealm.client = $ stormpathClient

stormpathRealm.applicationRestUrl =https://api.stormpath.com/v1/applications/

stormpathRealm.groupRoleResolver.modeNames = 이름

securityManager.realm = $ stormpathRealm

[URL을]

/관리/** = authc

/logout.htm = 로그 아웃

여기에 applicationContext.xml 파일에 콩 definations :

[com.stormpath.shiro.client.ClientFactory] 필요한 유형 유형의 값을 변환 할 수 없습니다 [com.stormpath을 :

<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean"> 
    <property name="securityManager" ref="securityManager"/> 
    <property name="loginUrl" value="/admin/login.htm"/> 
    <property name="successUrl" value="/admin/index.htm"/> 
    <!-- override these for application-specific URLs if you like: 
    <property name="unauthorizedUrl" value="/unauthorized.jsp"/> --> 
    <!-- The 'filters' property is not necessary since any declared javax.servlet.Filter bean --> 
    <!-- defined will be automatically acquired and available via its beanName in chain  --> 
    <!-- definitions, but you can perform instance overrides or name aliases here if you like: --> 
    <!-- <property name="filters"> 
     <util:map> 
      <entry key="anAlias" value-ref="someFilter"/> 
     </util:map> 
    </property> --> 
    <property name="filterChainDefinitions"> 
     <value>   
      /admin/** = authc, roles[admin] 
      /logout.htm = logout 
      # some example chain definitions: 
      #/docs/** = authc, perms[document:read] 
      #/** = authc 
      # more URL-to-FilterChain definitions here 
     </value> 
    </property> 
</bean> 

<!-- Define any javax.servlet.Filter beans you want anywhere in this application context. --> 
<!-- They will automatically be acquired by the 'shiroFilter' bean above and made available --> 
<!-- to the 'filterChainDefinitions' property. Or you can manually/explicitly add them  --> 
<!-- to the shiroFilter's 'filters' Map if desired. See its JavaDoc for more details.  --> 
<!--<bean id="someFilter" class="..."/> 
<bean id="anotherFilter" class="..."> ... </bean> 
--> 

<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager"> 
    <!-- Single realm app. If you have multiple realms, use the 'realms' property instead. --> 
    <property name="realm" ref="myRealm"/> 
    <property name="cacheManager" ref="cacheManager"/> 

    <!-- By default the servlet container sessions will be used. Uncomment this line 
    to use shiro's native sessions (see the JavaDoc for more): --> 
    <!-- <property name="sessionMode" value="native"/> --> 
</bean> 
<bean id="stormpathClient" class="com.stormpath.shiro.client.ClientFactory"> 
    <!-- Single realm app. If you have multiple realms, use the 'realms' property instead. --> 
    <property name="cacheManager" ref="cacheManager"/> 
    <property name="apiKeyFileLocation" value="$HOME/.stormpath/apiKey.properties"/> 
    <!-- By default the servlet container sessions will be used. Uncomment this line 
    to use shiro's native sessions (see the JavaDoc for more): --> 
    <!-- <property name="sessionMode" value="native"/> --> 
</bean> 
<bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor"/> 

<!-- Define the Shiro Realm implementation you want to use to connect to your back-end --> 
<!-- security datasource: --> 
<bean id="myRealm" class="com.stormpath.shiro.realm.ApplicationRealm"> 
    <property name="applicationRestUrl" value="https://api.stormpath.com/v1/applications/<my app key here removed for privacy>"/> 
    <property name="client" ref="stormpathClient"/> 

</bean> 

<bean id="cacheManager" class="org.apache.shiro.cache.MemoryConstrainedCacheManager" /> 

내 말은 점점 오류를 유지 .sdk.client.Client] 부동산 '클라이언트'에 대한 :

<!-- https://mvnrepository.com/artifact/org.apache.shiro/shiro-spring --> 
<dependency> 
    <groupId>org.apache.shiro</groupId> 
    <artifactId>shiro-spring</artifactId> 
    <version>1.4.0-RC2</version> 
</dependency> 
<!-- https://mvnrepository.com/artifact/com.stormpath.shiro/stormpath-shiro-core --> 
<dependency> 
    <groupId>com.stormpath.shiro</groupId> 
    <artifactId>stormpath-shiro-core</artifactId> 
    <version>0.8.0-RC1</version> 
</dependency> 
,369 : 일치 편집자 또는 전환 전략

이 어쩌면 때문에 불완전 받는다는 의존성의 발견

누군가가이를 수행하는 데 필요한 종속성을 제안 할 수 있습니까?

답변

0

XML에 factory-bean/factory-method 요소가 누락되었을 수 있습니다.보조 노트에

, 가장 쉬운 방법은 아파치 시로와 Stormpath 시작하는 것은 아마도 spring-boot-web 하나 귀하의 경우에 examples 중 하나 살펴 보는 것입니다.

shiro-spring-boot-starter을 통해 Spring의 자동 구성을 사용하면 method annotations에 대해서만 신경 써야합니다.

+0

이 문제를 살펴보실 수 없습니까? https://stackoverflow.com/questions/44584523/apache-shiro-xml-based-configuration-gives-null-pointer-exception-for-dao –