Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- social.xml
- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:context="http://www.springframework.org/schema/context"
- xmlns:twitter="http://www.springframework.org/schema/social/twitter"
- xmlns:social="http://www.springframework.org/schema/social"
- xmlns:facebook="http://www.springframework.org/schema/social/facebook"
- xmlns:aop="http://www.springframework.org/schema/aop"
- xmlns:util="http://www.springframework.org/schema/util"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
- http://www.springframework.org/schema/social http://www.springframework.org/schema/social/spring-social.xsd
- http://www.springframework.org/schema/social/twitter http://www.springframework.org/schema/social/spring-social-twitter.xsd
- http://www.springframework.org/schema/social/facebook http://www.springframework.org/schema/social/spring-social-facebook.xsd
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
- http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd">
- <bean id="facebookConnectFactory" class="org.springframework.social.facebook.connect.FacebookConnectionFactory">
- <constructor-arg value="${facebook.app.id}" />
- <constructor-arg value="${facebook.app.secret}" />
- </bean>
- <bean id="connectionFactoryLocator" class="org.springframework.social.connect.support.ConnectionFactoryRegistry">
- <property name="connectionFactories">
- <list>
- <ref bean="facebookConnectFactory" />
- </list>
- </property>
- </bean>
- <bean id="jdbcConnectionRepository" class="org.springframework.social.connect.jdbc.JdbcUsersConnectionRepository" primary="true" scope="singleton" >
- <constructor-arg ref="dataSource" />
- <constructor-arg ref="connectionFactoryLocator" />
- <constructor-arg ref="textEncryptor" />
- </bean>
- <bean id="usersConnectionRepository" factory-method="createConnectionRepository" factory-bean="jdbcConnectionRepository" scope="request">
- <constructor-arg value="#{request.userPrincipal.name}" />
- <aop:scoped-proxy proxy-target-class="false" />
- </bean>
- <!--
- request scoped bean for
- <bean id="userConnectionRepository" factory-method="createConnectionRepository" factory-bean="jdbcConnectionRepository" scope="request">
- <constructor-arg value="#{request.getRequestURI().split('/').length > 3 ? request.getRequestURI().split('/')[3] : 'guest'}" />
- <aop:scoped-proxy proxy-target-class="false"/>
- </bean> -->
- <!--
- <facebook:config app-id="${facebook.app.id}" app-secret="${facebook.app.secret}" />
- <twitter:config app-id="${twitter.consumer.key}" app-secret="${twitter.consumer.secret}"/>
- <social:jdbc-connection-repository/>
- -->
- <bean id="connectController" class="org.springframework.social.connect.web.ConnectController" autowire="constructor"/>
- </beans>
- security.xml
- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
- xmlns:mvc="http://www.springframework.org/schema/mvc"
- xmlns:security="http://www.springframework.org/schema/security"
- xmlns:aop="http://www.springframework.org/schema/aop"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
- http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
- http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd">
- <security:http pattern="/resources/**" security="none"/>
- <!-- use-expression=true allows you to define access rights using methods from SecurityExpressionRoot ...-->
- <security:http auto-config="true" use-expressions="true">
- <security:form-login login-page="/login" default-target-url="/" authentication-failure-url="/login?errorLogin"/>
- <security:intercept-url pattern="/home" access="hasRole('ADMIN')" />
- <security:intercept-url pattern="/admin/**" access="hasRole('ADMIN')" />
- <security:logout logout-success-url="/" />
- <security:access-denied-handler error-page="/403"/>
- <!-- Adds social authentication filter to the Spring Security filter chain. -->
- <security:custom-filter ref="socialAuthenticationFilter" before="PRE_AUTH_FILTER" />
- </security:http>
- <!-- Defining our custom authentication provider -->
- <security:authentication-manager alias="authenticationManager">
- <security:authentication-provider user-service-ref="userDetailsService">
- <security:password-encoder ref="passwordEncoder"/>
- </security:authentication-provider>
- <security:authentication-provider ref="socialAuthenticationProvider"/>
- </security:authentication-manager>
- <!--
- Configures the social authentication filter which integrates Spring Social
- with Spring Security.
- -->
- <bean id="socialAuthenticationFilter" class="org.springframework.social.security.SocialAuthenticationFilter">
- <constructor-arg index="0" ref="authenticationManager"/>
- <constructor-arg index="1" ref="userIdSource"/>
- <constructor-arg index="2" ref="usersConnectionRepository"/>
- <constructor-arg index="3" ref="connectionFactoryLocator"/>
- <!-- Sets the url of the registration form. -->
- <property name="signupUrl" value="/user/register"/>
- </bean>
- <!--
- Configures the social authentication provider which processes authentication requests
- made by using supported social authentication services (FB, Twitter and so on).
- -->
- <bean id="socialAuthenticationProvider" class="org.springframework.social.security.SocialAuthenticationProvider">
- <constructor-arg index="0" ref="usersConnectionRepository"/>
- <constructor-arg index="1" ref="socialUserDetailsService"/>
- </bean>
- <!--
- This bean is used to load the user specific data when social sign in is used.
- -->
- <bean id="socialUserDetailsService" class="com.eunka.lbs.subscriber.portal.security.LBSSocialUserDetailsService">
- <constructor-arg index="0" ref="userDetailsService"/>
- </bean>
- <!-- This bean is load the user specific data when form login is used. -->
- <bean id="userDetailsService" class="com.eunka.lbs.subscriber.portal.security.RepositoryUserDetailsService" autowire="constructor"/>
- <!-- This is used to hash the password of the user. -->
- <bean id="passwordEncoder" class="org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder">
- <constructor-arg index="0" value="10"/>
- </bean>
- <!--
- This bean determines the account ID of the user. The example application
- uses the username as the account ID.
- -->
- <bean id="userIdSource" class="org.springframework.social.security.AuthenticationNameUserIdSource"/>
- <!--
- This bean encrypts the authorization details of the connection. In
- our example, the authorization details are stored as plain text.
- DO NOT USE THIS IN PRODUCTION.
- -->
- <bean id="textEncryptor" class="org.springframework.security.crypto.encrypt.Encryptors" factory-method="noOpText" />
- </beans>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement