136 lines
6.5 KiB
XML
Executable File
136 lines
6.5 KiB
XML
Executable File
<?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:tx="http://www.springframework.org/schema/tx"
|
|
xmlns:webflow="http://www.springframework.org/schema/webflow-config"
|
|
xmlns:faces="http://www.springframework.org/schema/faces-config"
|
|
xmlns:security="http://www.springframework.org/schema/security"
|
|
xsi:schemaLocation="
|
|
http://www.springframework.org/schema/beans
|
|
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
|
|
http://www.springframework.org/schema/context
|
|
http://www.springframework.org/schema/context/spring-context-2.5.xsd
|
|
http://www.springframework.org/schema/tx
|
|
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
|
|
http://www.springframework.org/schema/webflow-config
|
|
http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.0.xsd
|
|
http://www.springframework.org/schema/faces-config
|
|
http://www.springframework.org/schema/faces-config/spring-faces-config-2.0.xsd
|
|
http://www.springframework.org/schema/security
|
|
http://www.springframework.org/schema/security/spring-security-2.0.xsd">
|
|
|
|
<!-- Activates annotation-based bean configuration -->
|
|
<context:annotation-config />
|
|
|
|
<!-- Scans for application @Components to deploy -->
|
|
<context:component-scan base-package="org.springframework.webflow.samples.booking" />
|
|
|
|
<!-- Maps request URIs to controllers -->
|
|
<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
|
|
<property name="mappings">
|
|
<value>
|
|
/main=flowController
|
|
/booking=flowController
|
|
</value>
|
|
</property>
|
|
<property name="defaultHandler">
|
|
<!-- Handles requests mapped directly to facelet .xhtml view templates -->
|
|
<bean class="org.springframework.web.servlet.mvc.UrlFilenameViewController" />
|
|
</property>
|
|
</bean>
|
|
|
|
<!-- Handles requests mapped to the Spring Web Flow system -->
|
|
<bean id="flowController" class="org.springframework.webflow.mvc.servlet.FlowController">
|
|
<constructor-arg ref="flowExecutor" />
|
|
</bean>
|
|
|
|
<!-- Maps logical view names to Facelet templates (e.g. 'search' to '/WEB-INF/search.xhtml' -->
|
|
<bean id="jsfViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
|
|
<property name="viewClass" value="org.springframework.faces.mvc.JsfView"/>
|
|
<property name="prefix" value="/WEB-INF/" />
|
|
<property name="suffix" value=".xhtml" />
|
|
</bean>
|
|
|
|
<!-- Executes flows: the central entry point into the Spring Web Flow system -->
|
|
<webflow:flow-executor id="flowExecutor" flow-registry="flowRegistry">
|
|
<webflow:flow-execution-listeners>
|
|
<webflow:listener ref="jpaFlowExecutionListener" />
|
|
<webflow:listener ref="securityFlowExecutionListener" />
|
|
</webflow:flow-execution-listeners>
|
|
</webflow:flow-executor>
|
|
|
|
<!-- The registry of executable flow definitions -->
|
|
<webflow:flow-registry id="flowRegistry" flow-builder-services="facesFlowBuilderServices">
|
|
<webflow:flow-location path="/WEB-INF/flows/main/main.xml" />
|
|
<webflow:flow-location path="/WEB-INF/flows/booking/booking.xml" />
|
|
</webflow:flow-registry>
|
|
|
|
<!-- Configures the Spring Web Flow JSF integration -->
|
|
<faces:flow-builder-services id="facesFlowBuilderServices" />
|
|
|
|
<!-- Installs a listener that manages JPA persistence contexts for flows that require them -->
|
|
<bean id="jpaFlowExecutionListener" class="org.springframework.webflow.persistence.JpaFlowExecutionListener">
|
|
<constructor-arg ref="entityManagerFactory" />
|
|
<constructor-arg ref="transactionManager" />
|
|
</bean>
|
|
|
|
<!-- Installs a listener to apply Spring Security authorities -->
|
|
<bean id="securityFlowExecutionListener" class="org.springframework.webflow.security.SecurityFlowExecutionListener" />
|
|
|
|
<!-- Instructs Spring to perfrom declarative transaction managemenet on annotated classes -->
|
|
<tx:annotation-driven />
|
|
|
|
<!-- Drives transactions using local JPA APIs -->
|
|
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
|
|
<property name="entityManagerFactory" ref="entityManagerFactory" />
|
|
</bean>
|
|
|
|
<!-- Creates a EntityManagerFactory for use with the Hibernate JPA provider and a simple in-memory data source populated with test data -->
|
|
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
|
|
<property name="dataSource" ref="dataSource" />
|
|
<property name="jpaVendorAdapter">
|
|
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" />
|
|
</property>
|
|
</bean>
|
|
|
|
<!-- Deploys a in-memory "booking" datasource populated -->
|
|
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
|
|
<property name="driverClassName" value="org.hsqldb.jdbcDriver" />
|
|
<property name="url" value="jdbc:hsqldb:mem:booking" />
|
|
<property name="username" value="sa" />
|
|
<property name="password" value="" />
|
|
</bean>
|
|
|
|
<!-- Configure Spring Security -->
|
|
<security:http auto-config="true">
|
|
<!-- restrict URLs based on role -->
|
|
<security:intercept-url pattern="/spring/login*" access="ROLE_ANONYMOUS" />
|
|
<security:intercept-url pattern="/spring/logout-success*" access="ROLE_ANONYMOUS" />
|
|
<security:intercept-url pattern="/spring/logout*" access="ROLE_USER" />
|
|
|
|
<!-- override default login and logout pages -->
|
|
<security:form-login login-page="/spring/login" login-url="/spring/login-process" default-target-url="/spring/flows/main" authentication-failure-url="/spring/login?login_error=1" />
|
|
<security:logout logout-url="/spring/logout" logout-success-url="/spring/logout-success" />
|
|
</security:http>
|
|
|
|
<!--
|
|
Define local authentication provider, a real app would use an external provider (JDBC, LDAP, CAS, etc)
|
|
|
|
usernames/passwords are:
|
|
keith/melbourne
|
|
erwin/leuven
|
|
jeremy/atlanta
|
|
scott/rochester
|
|
-->
|
|
<security:authentication-provider>
|
|
<security:password-encoder hash="md5" />
|
|
<security:user-service>
|
|
<security:user name="keith" password="417c7382b16c395bc25b5da1398cf076" authorities="ROLE_USER, ROLE_SUPERVISOR" />
|
|
<security:user name="erwin" password="12430911a8af075c6f41c6976af22b09" authorities="ROLE_USER, ROLE_SUPERVISOR" />
|
|
<security:user name="jeremy" password="57c6cbff0d421449be820763f03139eb" authorities="ROLE_USER" />
|
|
<security:user name="scott" password="942f2339bf50796de535a384f0d1af3e" authorities="ROLE_USER" />
|
|
</security:user-service>
|
|
</security:authentication-provider>
|
|
|
|
</beans> |