SpringWebflow认证用户的两种类型
SpringWebflow authenticating user of two types
我正在使用,
Spring 安全
Spring 框架。
spring 网络流量。
我想从同一个登录页面验证两种不同类型的用户,即 user1 和 user2。
两者在数据库中都有不同的表,并为它们定义了不同的实体 类
我的登录页面使用 jsf .xhtml 页面。
我使用了 primefaces gui 并在选项卡的帮助下为 user1 和 user2 提供了登录页面。
这是我的 webflow 定义文件。
问题是我想从 ID 为 "welcome" 的同一视图状态中获取 user1 和 user2 的值,但我不知道如何接受他们的凭据,因为我指定的模型只允许使用 1 个模型="student".
<?xml version="1.0" encoding="UTF-8"?>
<flow xmlns="http://www.springframework.org/schema/webflow"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/webflow
http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">
<var name="student" class="be.project.studNtwrk.domain.StudentEntity"/>
<var name="mentor" class="be.project.studNtwrk.domain.MentorEntity"/>
<view-state id="welcome" view="welcome.xhtml" model="student" >
<transition on="ssignUp" to="userType"></transition>
<transition on="msignUp" to="userType"></transition>
<transition on="studentSignIn" to="finish">
<evaluate expression="studentAuthenticationProviderService.processUserAuthentication(student)" />
</transition>
<transition on="mentorSignIn" to="finish">
<evaluate expression="mentorAuthenticationProviderService.processUserAuthentication(student)" />
</transition>
</view-state>
<view-state id="userType" view="ChooseUser.xhtml">
<transition on="student" to="studentsignup" />
<transition on="mentor" to="mentorsignup" />
</view-state>
<view-state id="studentsignup" view="studentregistration.xhtml" model="student">
<transition on="backToSignIn" to="welcome"></transition>
<transition on="backToChoice" to="userType"></transition>
<transition on="confirmSignUp" to="StudentAuthentication">
<evaluate expression="studentService.createUser(student)"></evaluate>
</transition>
</view-state>
<action-state id="StudentAuthentication">
<evaluate expression="studentAuthenticationProviderService.processUserAuthentication(student)" />
<transition on="yes" to="finish"></transition>
<transition on="no" to="welcome"></transition>
</action-state>
<view-state id="mentorsignup" view="mentorregistration.xhtml" model="mentor">
<transition on="backToSignIn" to="welcome"></transition>
<transition on="backToChoice" to="userType"></transition>
<transition on="confirmSignUp" to="MentorAuthentication">
<evaluate expression="mentorService.createUser(mentor)"></evaluate>
</transition>
</view-state>
<action-state id="MentorAuthentication">
<evaluate expression="mentorAuthenticationProviderService.processUserAuthentication(mentor)" />
<transition on="yes" to="finish"></transition>
<transition on="no" to="welcome"></transition>
</action-state>
<end-state id="finish" view="externalRedirect:account" />
</flow>
你应该做的是将 "student" 和 "mentor" 分别放入它们自己的流(文件)中,如果有任何重复的逻辑使用流继承并将重复的逻辑放在抽象流中新的 "student" 和 "mentor" 流程都会扩展。
http://docs.spring.io/spring-webflow/docs/current/reference/html/flow-inheritance.html
我正在使用, Spring 安全 Spring 框架。 spring 网络流量。 我想从同一个登录页面验证两种不同类型的用户,即 user1 和 user2。 两者在数据库中都有不同的表,并为它们定义了不同的实体 类 我的登录页面使用 jsf .xhtml 页面。 我使用了 primefaces gui 并在选项卡的帮助下为 user1 和 user2 提供了登录页面。 这是我的 webflow 定义文件。
问题是我想从 ID 为 "welcome" 的同一视图状态中获取 user1 和 user2 的值,但我不知道如何接受他们的凭据,因为我指定的模型只允许使用 1 个模型="student".
<?xml version="1.0" encoding="UTF-8"?>
<flow xmlns="http://www.springframework.org/schema/webflow"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/webflow
http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">
<var name="student" class="be.project.studNtwrk.domain.StudentEntity"/>
<var name="mentor" class="be.project.studNtwrk.domain.MentorEntity"/>
<view-state id="welcome" view="welcome.xhtml" model="student" >
<transition on="ssignUp" to="userType"></transition>
<transition on="msignUp" to="userType"></transition>
<transition on="studentSignIn" to="finish">
<evaluate expression="studentAuthenticationProviderService.processUserAuthentication(student)" />
</transition>
<transition on="mentorSignIn" to="finish">
<evaluate expression="mentorAuthenticationProviderService.processUserAuthentication(student)" />
</transition>
</view-state>
<view-state id="userType" view="ChooseUser.xhtml">
<transition on="student" to="studentsignup" />
<transition on="mentor" to="mentorsignup" />
</view-state>
<view-state id="studentsignup" view="studentregistration.xhtml" model="student">
<transition on="backToSignIn" to="welcome"></transition>
<transition on="backToChoice" to="userType"></transition>
<transition on="confirmSignUp" to="StudentAuthentication">
<evaluate expression="studentService.createUser(student)"></evaluate>
</transition>
</view-state>
<action-state id="StudentAuthentication">
<evaluate expression="studentAuthenticationProviderService.processUserAuthentication(student)" />
<transition on="yes" to="finish"></transition>
<transition on="no" to="welcome"></transition>
</action-state>
<view-state id="mentorsignup" view="mentorregistration.xhtml" model="mentor">
<transition on="backToSignIn" to="welcome"></transition>
<transition on="backToChoice" to="userType"></transition>
<transition on="confirmSignUp" to="MentorAuthentication">
<evaluate expression="mentorService.createUser(mentor)"></evaluate>
</transition>
</view-state>
<action-state id="MentorAuthentication">
<evaluate expression="mentorAuthenticationProviderService.processUserAuthentication(mentor)" />
<transition on="yes" to="finish"></transition>
<transition on="no" to="welcome"></transition>
</action-state>
<end-state id="finish" view="externalRedirect:account" />
</flow>
你应该做的是将 "student" 和 "mentor" 分别放入它们自己的流(文件)中,如果有任何重复的逻辑使用流继承并将重复的逻辑放在抽象流中新的 "student" 和 "mentor" 流程都会扩展。
http://docs.spring.io/spring-webflow/docs/current/reference/html/flow-inheritance.html