Samjay

spring social xml configuration issue

Nov 17th, 2013
447
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. social.xml
  2.  
  3. <?xml version="1.0" encoding="UTF-8"?>
  4. <beans xmlns="http://www.springframework.org/schema/beans"
  5. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  6. xmlns:context="http://www.springframework.org/schema/context"
  7. xmlns:twitter="http://www.springframework.org/schema/social/twitter"
  8. xmlns:social="http://www.springframework.org/schema/social"
  9. xmlns:facebook="http://www.springframework.org/schema/social/facebook"
  10. xmlns:aop="http://www.springframework.org/schema/aop"
  11. xmlns:util="http://www.springframework.org/schema/util"
  12. xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
  13. http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
  14. http://www.springframework.org/schema/social http://www.springframework.org/schema/social/spring-social.xsd
  15. http://www.springframework.org/schema/social/twitter http://www.springframework.org/schema/social/spring-social-twitter.xsd
  16. http://www.springframework.org/schema/social/facebook http://www.springframework.org/schema/social/spring-social-facebook.xsd
  17. http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
  18. http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd">
  19.  
  20. <bean id="facebookConnectFactory" class="org.springframework.social.facebook.connect.FacebookConnectionFactory">
  21. <constructor-arg value="${facebook.app.id}" />
  22. <constructor-arg value="${facebook.app.secret}" />
  23. </bean>
  24.  
  25. <bean id="connectionFactoryLocator" class="org.springframework.social.connect.support.ConnectionFactoryRegistry">
  26. <property name="connectionFactories">
  27. <list>
  28. <ref bean="facebookConnectFactory" />
  29. </list>
  30. </property>
  31. </bean>
  32.  
  33. <bean id="jdbcConnectionRepository" class="org.springframework.social.connect.jdbc.JdbcUsersConnectionRepository" primary="true" scope="singleton" >
  34. <constructor-arg ref="dataSource" />
  35. <constructor-arg ref="connectionFactoryLocator" />
  36. <constructor-arg ref="textEncryptor" />
  37. </bean>
  38.  
  39. <bean id="usersConnectionRepository" factory-method="createConnectionRepository" factory-bean="jdbcConnectionRepository" scope="request">
  40. <constructor-arg value="#{request.userPrincipal.name}" />
  41. <aop:scoped-proxy proxy-target-class="false" />
  42. </bean>
  43. <!--
  44. request scoped bean for
  45. <bean id="userConnectionRepository" factory-method="createConnectionRepository" factory-bean="jdbcConnectionRepository" scope="request">
  46. <constructor-arg value="#{request.getRequestURI().split('/').length > 3 ? request.getRequestURI().split('/')[3] : 'guest'}" />
  47. <aop:scoped-proxy proxy-target-class="false"/>
  48. </bean> -->
  49. <!--
  50. <facebook:config app-id="${facebook.app.id}" app-secret="${facebook.app.secret}" />
  51. <twitter:config app-id="${twitter.consumer.key}" app-secret="${twitter.consumer.secret}"/>
  52. <social:jdbc-connection-repository/>
  53. -->
  54. <bean id="connectController" class="org.springframework.social.connect.web.ConnectController" autowire="constructor"/>
  55.  
  56. </beans>
  57.  
  58.  
  59. security.xml
  60.  
  61. <?xml version="1.0" encoding="UTF-8"?>
  62. <beans xmlns="http://www.springframework.org/schema/beans"
  63. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
  64. xmlns:mvc="http://www.springframework.org/schema/mvc"
  65. xmlns:security="http://www.springframework.org/schema/security"
  66. xmlns:aop="http://www.springframework.org/schema/aop"
  67. xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
  68. http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
  69. http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
  70. http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
  71. http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd">
  72.  
  73.  
  74. <security:http pattern="/resources/**" security="none"/>
  75.  
  76. <!-- use-expression=true allows you to define access rights using methods from SecurityExpressionRoot ...-->
  77. <security:http auto-config="true" use-expressions="true">
  78. <security:form-login login-page="/login" default-target-url="/" authentication-failure-url="/login?errorLogin"/>
  79. <security:intercept-url pattern="/home" access="hasRole('ADMIN')" />
  80. <security:intercept-url pattern="/admin/**" access="hasRole('ADMIN')" />
  81. <security:logout logout-success-url="/" />
  82. <security:access-denied-handler error-page="/403"/>
  83.  
  84. <!-- Adds social authentication filter to the Spring Security filter chain. -->
  85. <security:custom-filter ref="socialAuthenticationFilter" before="PRE_AUTH_FILTER" />
  86.  
  87. </security:http>
  88.  
  89. <!-- Defining our custom authentication provider -->
  90. <security:authentication-manager alias="authenticationManager">
  91.  
  92. <security:authentication-provider user-service-ref="userDetailsService">
  93. <security:password-encoder ref="passwordEncoder"/>
  94. </security:authentication-provider>
  95.  
  96. <security:authentication-provider ref="socialAuthenticationProvider"/>
  97.  
  98. </security:authentication-manager>
  99.  
  100.  
  101. <!--
  102. Configures the social authentication filter which integrates Spring Social
  103. with Spring Security.
  104. -->
  105. <bean id="socialAuthenticationFilter" class="org.springframework.social.security.SocialAuthenticationFilter">
  106. <constructor-arg index="0" ref="authenticationManager"/>
  107. <constructor-arg index="1" ref="userIdSource"/>
  108. <constructor-arg index="2" ref="usersConnectionRepository"/>
  109. <constructor-arg index="3" ref="connectionFactoryLocator"/>
  110.  
  111. <!-- Sets the url of the registration form. -->
  112. <property name="signupUrl" value="/user/register"/>
  113. </bean>
  114.  
  115. <!--
  116. Configures the social authentication provider which processes authentication requests
  117. made by using supported social authentication services (FB, Twitter and so on).
  118. -->
  119. <bean id="socialAuthenticationProvider" class="org.springframework.social.security.SocialAuthenticationProvider">
  120. <constructor-arg index="0" ref="usersConnectionRepository"/>
  121. <constructor-arg index="1" ref="socialUserDetailsService"/>
  122. </bean>
  123.  
  124. <!--
  125. This bean is used to load the user specific data when social sign in is used.
  126. -->
  127. <bean id="socialUserDetailsService" class="com.eunka.lbs.subscriber.portal.security.LBSSocialUserDetailsService">
  128. <constructor-arg index="0" ref="userDetailsService"/>
  129. </bean>
  130.  
  131. <!-- This bean is load the user specific data when form login is used. -->
  132. <bean id="userDetailsService" class="com.eunka.lbs.subscriber.portal.security.RepositoryUserDetailsService" autowire="constructor"/>
  133.  
  134. <!-- This is used to hash the password of the user. -->
  135. <bean id="passwordEncoder" class="org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder">
  136. <constructor-arg index="0" value="10"/>
  137. </bean>
  138.  
  139. <!--
  140. This bean determines the account ID of the user. The example application
  141. uses the username as the account ID.
  142. -->
  143. <bean id="userIdSource" class="org.springframework.social.security.AuthenticationNameUserIdSource"/>
  144.  
  145. <!--
  146. This bean encrypts the authorization details of the connection. In
  147. our example, the authorization details are stored as plain text.
  148. DO NOT USE THIS IN PRODUCTION.
  149. -->
  150. <bean id="textEncryptor" class="org.springframework.security.crypto.encrypt.Encryptors" factory-method="noOpText" />
  151.  
  152. </beans>
RAW Paste Data