Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?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:security="http://www.springframework.org/schema/security"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
- http://www.springframework.org/schema/security
- http://www.springframework.org/schema/security/spring-security-3.1.xsd">
- <!-- This is where we configure Spring-Security -->
- <security:http auto-config="true" use-expressions="true" access-denied-page="/loginfail" >
- <security:intercept-url pattern="/login**" access="permitAll"/>
- <!-- <security:intercept-url pattern="/krams/main/admin" access="hasRole('ROLE_ADMIN')"/>-->
- <security:intercept-url pattern="/tem/*" access="hasRole('ROLE_USER')"/>
- <security:form-login
- login-page="/login"
- authentication-failure-url="/loginfail?error=true"
- default-target-url="/index"/>
- <security:logout
- invalidate-session="true"
- logout-success-url="/logout"
- logout-url="/logout"/>
- </security:http>
- <!-- Declare an authentication-manager to use a custom userDetailsService -->
- <security:authentication-manager>
- <security:authentication-provider user-service-ref="customUserDetailsService">
- <!-- <security:password-encoder ref="passwordEncoder"/>-->
- </security:authentication-provider>
- </security:authentication-manager>
- <!-- Use a Md5 encoder since the user's passwords are stored as Md5 in the database
- <bean class="org.springframework.security.authentication.encoding.Md5PasswordEncoder" id="passwordEncoder"/>
- -->
- <!-- A custom service where Spring will retrieve users and their corresponding access levels -->
- <bean id="customUserDetailsService" class="web.service.common.CustomUserDetailsService"/>
- </beans>
- ==================
- <?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:mvc="http://www.springframework.org/schema/mvc"
- xmlns:context="http://www.springframework.org/schema/context"
- xmlns:tx="http://www.springframework.org/schema/tx"
- xsi:schemaLocation="
- http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
- http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd"
- >
- <context:component-scan base-package="web" >
- <context:include-filter type="annotation" expression="org.springframework.stereotype.Service" />
- <context:include-filter type="annotation" expression="org.springframework.stereotype.Repository" />
- </context:component-scan>
- <mvc:annotation-driven />
- <!-- <context:annotation-config />-->
- <bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/>
- <!--
- Most controllers will use the ControllerClassNameHandlerMapping above, but
- for the index controller we are using ParameterizableViewController, so we must
- define an explicit mapping for it.
- -->
- <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
- <property name="mappings">
- <props>
- <prop key="index.htm">indexController</prop>
- </props>
- </property>
- </bean>
- <bean id="viewResolver"
- class="org.springframework.web.servlet.view.InternalResourceViewResolver">
- <!-- class="org.springframework.web.servlet.view.InternalResourceViewResolver">-->
- <!-- class="org.springframework.web.servlet.view.UrlBasedViewResolver" >-->
- <property name="prefix" value="/WEB-INF/view/jsp/" />
- <property name="suffix" value=".jsp" />
- </bean>
- <!--
- The index controller.
- -->
- <bean name="indexController"
- class="org.springframework.web.servlet.mvc.ParameterizableViewController">
- <property name="viewName" value="index" />
- </bean>
- <!---
- ##########################################################################
- Hibernate
- -->
- <!-- <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
- <property name="driverClassName" value="org.postgresql.Driver" />
- <property name="url" value="${jdbc.url}jdbc:postgresql://localhost:5432/postgres" />
- <property name="username" value="postgres" />
- <property name="password" value="abc" />
- </bean>
- <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
- <property name="dataSource" ref="dataSource"/>
- <property name="packagesToScan" value="web.entity" />
- </property>
- <property name="hibernateProperties">
- <props>
- <prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
- <prop key="hibernate.show_sql">true</prop>
- <prop key="cache.provider_class">org.hibernate.cache.internal.NoCacheProvider</prop>
- </props>
- </property>
- </bean>
- <tx:annotation-driven transaction-manager="transactionManager"/>
- <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
- <property name="sessionFactory" ref="sessionFactory"/>
- </bean>
- ###########################################################
- -->
- <!--
- JPA based instead of hibernate
- -->
- <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/>
- <!--
- This configures the EntityManagerFactory object used for JPA/Spring managed persistent objects.
- -->
- <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
- <property name="persistenceXmlLocation" value="classpath*:META-INF/persistence.xml" />
- <property name="persistenceUnitName" value="persistence-unit-demo" />
- <property name="dataSource" ref="dataSource" />
- <property name="packagesToScan" value="web.entity" />
- <property name="jpaVendorAdapter">
- <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
- <property name="database" value="POSTGRESQL" />
- <!-- giving errors <property name="databasePlatorm" value="org.hibernate.dialect.PostgreSQLDialect"/>-->
- <!-- <property name="database" value="HSQL" />-->
- <property name="showSql" value="true" />
- <property name="generateDdl" value="true" />
- </bean>
- </property>
- <property name="jpaProperties">
- <props>
- <prop key="hibernate.hbm2ddl.auto">create-drop</prop>
- </props>
- </property>
- </bean>
- <bean id="jpaDialect" class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" />
- <!-- Pulls database connection from the tomcat container's context database pool via JNDI -->
- <!-- <jee:jndi-lookup id="dataSource" jndi-name="jdbc/mssqlserver" resource-ref="true"/>-->
- <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" >
- <property name="driverClassName" value="org.postgresql.Driver" />
- <property name="url" value="jdbc:postgresql://localhost:5432/postgres" />
- <property name="username" value="postgres" />
- <property name="password" value="abc" />
- </bean>
- <!--
- Sets up our transaction manager.
- -->
- <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
- <property name="entityManagerFactory" ref="entityManagerFactory" />
- <property name="jpaDialect" ref="jpaDialect" />
- <property name="dataSource" ref="dataSource" />
- <!-- giving errors <property name="loadTimeWeaver">
- <bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver" />
- </property>-->
- </bean>
- <!--
- Defines our transaction manager for Transactional annotations.
- -->
- <tx:annotation-driven transaction-manager="transactionManager" />
- <bean id="sessionFactory" factory-bean="entityManagerFactory" factory-method="getSessionFactory" />
- </beans>
- ============================
- <?xml version="1.0" encoding="UTF-8"?>
- <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
- <filter>
- <filter-name>springSecurityFilterChain</filter-name>
- <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
- </filter>
- <filter-mapping>
- <filter-name>springSecurityFilterChain</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
- <context-param>
- <param-name>contextConfigLocation</param-name>
- <param-value>
- /WEB-INF/spring-security.xml
- /WEB-INF/applicationContext.xml
- </param-value>
- </context-param>
- <listener>
- <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
- </listener>
- <servlet>
- <servlet-name>springDispatcher</servlet-name>
- <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
- <load-on-startup>1</load-on-startup>
- </servlet>
- <servlet-mapping>
- <servlet-name>springDispatcher</servlet-name>
- <url-pattern>/</url-pattern>
- </servlet-mapping>
- <session-config>
- <session-timeout>
- 30
- </session-timeout>
- </session-config>
- <welcome-file-list>
- <welcome-file>redirect.jsp</welcome-file>
- </welcome-file-list>
- </web-app>
Advertisement
Add Comment
Please, Sign In to add comment