Conditions | 1 |
Total Lines | 155 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | package org.apereo.cas.adaptors.duo.web.flow.config; |
||
100 | private void createDuoFlowStates(final DynamicFlowModelBuilder modelBuilder) { |
||
101 | final LinkedList<AbstractStateModel> states = new LinkedList<>(); |
||
102 | |||
103 | /////////////// |
||
104 | |||
105 | ActionStateModel actModel = new ActionStateModel(CasWebflowConstants.STATE_ID_INIT_LOGIN_FORM); |
||
106 | LinkedList<AbstractActionModel> actions = new LinkedList<>(); |
||
107 | actions.add(new EvaluateModel("initializeLoginAction")); |
||
108 | actModel.setActions(actions); |
||
109 | |||
110 | LinkedList<TransitionModel> trans = new LinkedList<>(); |
||
111 | TransitionModel transModel = new TransitionModel(); |
||
112 | transModel.setOn(CasWebflowConstants.TRANSITION_ID_SUCCESS); |
||
113 | transModel.setTo("determineDuoUserAccount"); |
||
114 | trans.add(transModel); |
||
115 | |||
116 | actModel.setTransitions(trans); |
||
117 | states.add(actModel); |
||
118 | |||
119 | /////////////// |
||
120 | |||
121 | actModel = new ActionStateModel("determineDuoUserAccount"); |
||
122 | actions = new LinkedList<>(); |
||
123 | actions.add(new EvaluateModel("determineDuoUserAccountAction")); |
||
124 | actModel.setActions(actions); |
||
125 | |||
126 | trans = new LinkedList<>(); |
||
127 | transModel = new TransitionModel(); |
||
128 | transModel.setOn(CasWebflowConstants.TRANSITION_ID_SUCCESS); |
||
129 | transModel.setTo("determineDuoRequest"); |
||
130 | trans.add(transModel); |
||
131 | |||
132 | transModel = new TransitionModel(); |
||
133 | transModel.setOn(CasWebflowConstants.TRANSITION_ID_ENROLL); |
||
134 | transModel.setTo("redirectToDuoRegistration"); |
||
135 | trans.add(transModel); |
||
136 | |||
137 | actModel.setTransitions(trans); |
||
138 | states.add(actModel); |
||
139 | |||
140 | //////////// |
||
141 | |||
142 | actModel = new ActionStateModel("determineDuoRequest"); |
||
143 | actions = new LinkedList<>(); |
||
144 | actions.add(new EvaluateModel("checkWebAuthenticationRequestAction")); |
||
145 | actModel.setActions(actions); |
||
146 | |||
147 | trans = new LinkedList<>(); |
||
148 | |||
149 | transModel = new TransitionModel(); |
||
150 | transModel.setOn(CasWebflowConstants.TRANSITION_ID_YES); |
||
151 | transModel.setTo(STATE_ID_VIEW_LOGIN_FORM_DUO); |
||
152 | trans.add(transModel); |
||
153 | |||
154 | transModel = new TransitionModel(); |
||
155 | transModel.setOn(CasWebflowConstants.TRANSITION_ID_NO); |
||
156 | transModel.setTo("doNonWebAuthentication"); |
||
157 | trans.add(transModel); |
||
158 | |||
159 | actModel.setTransitions(trans); |
||
160 | states.add(actModel); |
||
161 | |||
162 | /////////////// |
||
163 | |||
164 | actModel = new ActionStateModel("doNonWebAuthentication"); |
||
165 | actions = new LinkedList<>(); |
||
166 | actions.add(new EvaluateModel("duoNonWebAuthenticationAction")); |
||
167 | actModel.setActions(actions); |
||
168 | |||
169 | trans = new LinkedList<>(); |
||
170 | |||
171 | transModel = new TransitionModel(); |
||
172 | transModel.setOn(CasWebflowConstants.TRANSITION_ID_SUCCESS); |
||
173 | transModel.setTo("finalizeAuthentication"); |
||
174 | trans.add(transModel); |
||
175 | |||
176 | actModel.setTransitions(trans); |
||
177 | states.add(actModel); |
||
178 | |||
179 | /////////////// |
||
180 | |||
181 | actModel = new ActionStateModel("finalizeAuthentication"); |
||
182 | actions = new LinkedList<>(); |
||
183 | actions.add(new EvaluateModel("duoAuthenticationWebflowAction")); |
||
184 | actModel.setActions(actions); |
||
185 | |||
186 | trans = new LinkedList<>(); |
||
187 | |||
188 | transModel = new TransitionModel(); |
||
189 | transModel.setOn(CasWebflowConstants.TRANSITION_ID_SUCCESS); |
||
190 | transModel.setTo(CasWebflowConstants.TRANSITION_ID_SUCCESS); |
||
191 | trans.add(transModel); |
||
192 | |||
193 | actModel.setTransitions(trans); |
||
194 | states.add(actModel); |
||
195 | |||
196 | ///////////////// |
||
197 | |||
198 | final ViewStateModel viewState = new ViewStateModel(STATE_ID_VIEW_LOGIN_FORM_DUO); |
||
199 | viewState.setView("casDuoLoginView"); |
||
200 | viewState.setModel(CasWebflowConstants.VAR_ID_CREDENTIAL); |
||
201 | final BinderModel bm = new BinderModel(); |
||
202 | final LinkedList<BindingModel> bindings = new LinkedList<>(); |
||
203 | final BindingModel bme = new BindingModel("signedDuoResponse", null, null); |
||
204 | bindings.add(bme); |
||
205 | bm.setBindings(bindings); |
||
206 | viewState.setBinder(bm); |
||
207 | |||
208 | actions = new LinkedList<>(); |
||
209 | actions.add(new EvaluateModel("prepareDuoWebLoginFormAction")); |
||
210 | viewState.setOnEntryActions(actions); |
||
211 | |||
212 | transModel = new TransitionModel(); |
||
213 | transModel.setOn(CasWebflowConstants.TRANSITION_ID_SUBMIT); |
||
214 | transModel.setTo(CasWebflowConstants.STATE_ID_REAL_SUBMIT); |
||
215 | transModel.setBind(Boolean.TRUE.toString()); |
||
216 | transModel.setValidate(Boolean.FALSE.toString()); |
||
217 | |||
218 | trans.add(transModel); |
||
219 | viewState.setTransitions(trans); |
||
220 | states.add(viewState); |
||
221 | |||
222 | ///////////////// |
||
223 | |||
224 | actModel = new ActionStateModel(CasWebflowConstants.STATE_ID_REAL_SUBMIT); |
||
225 | actions = new LinkedList<>(); |
||
226 | actions.add(new EvaluateModel("duoAuthenticationWebflowAction")); |
||
227 | actModel.setActions(actions); |
||
228 | |||
229 | trans = new LinkedList<>(); |
||
230 | |||
231 | transModel = new TransitionModel(); |
||
232 | transModel.setOn(CasWebflowConstants.TRANSITION_ID_SUCCESS); |
||
233 | transModel.setTo(CasWebflowConstants.TRANSITION_ID_SUCCESS); |
||
234 | trans.add(transModel); |
||
235 | |||
236 | transModel = new TransitionModel(); |
||
237 | transModel.setOn(CasWebflowConstants.TRANSITION_ID_ERROR); |
||
238 | transModel.setTo(CasWebflowConstants.STATE_ID_INIT_LOGIN_FORM); |
||
239 | trans.add(transModel); |
||
240 | |||
241 | actModel.setTransitions(trans); |
||
242 | states.add(actModel); |
||
243 | |||
244 | //////////////////// |
||
245 | |||
246 | final ViewStateModel endModel = new ViewStateModel("redirectToDuoRegistration"); |
||
247 | endModel.setView("externalRedirect:#{flowScope.duoRegistrationUrl}"); |
||
248 | states.add(endModel); |
||
249 | |||
250 | //////////////////// |
||
251 | states.add(new EndStateModel(CasWebflowConstants.TRANSITION_ID_SUCCESS)); |
||
252 | |||
253 | //////////////////// |
||
254 | modelBuilder.setStates(states); |
||
255 | } |
||
269 |