1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
| public class MyLoginWebflowConfiger extends DefaultLoginWebflowConfigurer {
public MyLoginWebflowConfiger(FlowBuilderServices flowBuilderServices, FlowDefinitionRegistry flowDefinitionRegistry, ApplicationContext applicationContext, CasConfigurationProperties casProperties) { super(flowBuilderServices, flowDefinitionRegistry, applicationContext, casProperties); }
//登录页面属性和后端绑定 @Override protected void createRememberMeAuthnWebflowConfig(Flow flow){ if (this.casProperties.getTicket().getTgt().getRememberMe().isEnabled()) { this.createFlowVariable(flow, "credential", RememberMeUsernamePasswordCredential.class); ViewState state = (ViewState)this.getState(flow, "viewLoginForm", ViewState.class); BinderConfiguration cfg = this.getViewStateBinderConfiguration(state); cfg.addBinding(new BinderConfiguration.Binding("rememberMe", (String)null, false)); } else { this.createFlowVariable(flow, "credential", LoginUsernamePasswordCredential.class); }
}
//generateServiceTicket后加入验证用户是否进行过二次注册checkUserExist @Override protected void createGenerateServiceTicketAction(Flow flow) { ActionState handler = this.createActionState(flow, "generateServiceTicket", this.createEvaluateAction("generateServiceTicketAction")); this.createTransitionForState(handler, "success", "checkUserExist"); this.createTransitionForState(handler, "warn", "warn"); this.createTransitionForState(handler, "authenticationFailure", "handleAuthenticationFailure"); this.createTransitionForState(handler, "error", "initializeLoginForm"); this.createTransitionForState(handler, "gateway", "gatewayServicesManagementCheck"); createCheckUserExist(flow);
}
//hasServiceCheck后加入验证用户是否进行过二次注册checkUserExist @Override protected void createHasServiceCheckDecisionState(Flow flow) { this.createDecisionState(flow, "hasServiceCheck", "flowScope.service != null", "renewRequestCheck", "checkUserExist"); }
//serviceCheck后加入验证用户是否进行过二次注册checkUserExist @Override protected void createServiceCheckDecisionState(Flow flow) { this.createDecisionState(flow, "serviceCheck", "flowScope.service != null", "generateServiceTicket", "checkUserExist");
}
//创建serviceCheck action private void createCheckUserExist(Flow flow){
ActionState handler = this.createActionState(flow, "checkUserExist", this.createEvaluateAction("checkUserExistAction")); //没有注册添加到注册页面 this.createTransitionForState(handler, "noRegister", "addUser"); //注册过跳转到判断是否有service回调地址 this.createTransitionForState(handler, "register", "checkServiceDecisionState");
createAddUserView(flow); createRegisteredUserView(flow); createCheckServiceDecisionState(flow);
}
//如果有回调地址service则重定向,如果么有则跳转到默认页面 private void createCheckServiceDecisionState(Flow flow){ this.createDecisionState(flow, "checkServiceDecisionState", "flowScope.service != null", "redirect", "registeredUser"); }
private void createAddUserView(Flow flow){ EndState state = this.createEndState(flow, "addUser", "addUser");
}
private void createRegisteredUserView(Flow flow){ EndState state = this.createEndState(flow, "registeredUser", "registeredUser");
}
}
|