blob: f9e5f25dc0285b9f52603f8d314d024f45d9604d [file] [log] [blame]
Ari Saha89831742015-06-26 10:31:48 -07001/*
Amit Ghoshc9ac1e52017-07-28 12:31:18 +01002 * Copyright 2017-present Open Networking Foundation
Ari Saha89831742015-06-26 10:31:48 -07003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17
Matteo Scandolocf847b82019-04-26 15:00:00 -070018package org.opencord.aaa.impl;
Ari Saha89831742015-06-26 10:31:48 -070019
Jonathan Hart4731dd92018-05-02 17:30:05 -070020import com.google.common.collect.Maps;
Ari Saha89831742015-06-26 10:31:48 -070021import org.onlab.packet.MacAddress;
22import org.onosproject.net.ConnectPoint;
Matteo Scandolocf847b82019-04-26 15:00:00 -070023import org.opencord.aaa.AuthenticationEvent;
24import org.opencord.aaa.StateMachineDelegate;
Ari Saha89831742015-06-26 10:31:48 -070025import org.slf4j.Logger;
Thomas Vachuskae9894202015-07-30 11:59:07 -070026
Jonathan Hart4731dd92018-05-02 17:30:05 -070027import java.util.Map;
Ari Saha89831742015-06-26 10:31:48 -070028
29import static org.slf4j.LoggerFactory.getLogger;
30
31/**
32 * AAA Finite State Machine.
33 */
34
35class StateMachine {
36 //INDEX to identify the state in the transition table
37 static final int STATE_IDLE = 0;
38 static final int STATE_STARTED = 1;
39 static final int STATE_PENDING = 2;
40 static final int STATE_AUTHORIZED = 3;
41 static final int STATE_UNAUTHORIZED = 4;
42
43 //INDEX to identify the transition in the transition table
44 static final int TRANSITION_START = 0; // --> started
45 static final int TRANSITION_REQUEST_ACCESS = 1;
46 static final int TRANSITION_AUTHORIZE_ACCESS = 2;
47 static final int TRANSITION_DENY_ACCESS = 3;
48 static final int TRANSITION_LOGOFF = 4;
49
Amit Ghoshc9ac1e52017-07-28 12:31:18 +010050 private static int identifier = -1;
Ari Saha89831742015-06-26 10:31:48 -070051 private byte challengeIdentifier;
52 private byte[] challengeState;
53 private byte[] username;
54 private byte[] requestAuthenticator;
55
56 // Supplicant connectivity info
Ray Milkeyf61a24e2015-09-24 16:34:02 -070057 private ConnectPoint supplicantConnectpoint;
58 private MacAddress supplicantAddress;
59 private short vlanId;
Amit Ghoshc9ac1e52017-07-28 12:31:18 +010060 private byte priorityCode;
Ari Saha89831742015-06-26 10:31:48 -070061
62 private String sessionId = null;
63
64 private final Logger log = getLogger(getClass());
65
66
67 private State[] states = {
68 new Idle(), new Started(), new Pending(), new Authorized(), new Unauthorized()
69 };
70
71
72 //State transition table
73 /*
74
75 state IDLE | STARTED | PENDING | AUTHORIZED | UNAUTHORIZED
76 ////
77 input
78 ----------------------------------------------------------------------------------------------------
79
ke han04e47f32016-10-28 14:15:43 +080080 START STARTED | _ | _ | STARTED | STARTED
Ari Saha89831742015-06-26 10:31:48 -070081
82 REQUEST_ACCESS _ | PENDING | _ | _ | _
83
84 AUTHORIZE_ACCESS _ | _ | AUTHORIZED | _ | _
85
86 DENY_ACCESS _ | - | UNAUTHORIZED | _ | _
87
88 LOGOFF _ | _ | _ | IDLE | IDLE
89 */
90
91 private int[] idleTransition =
92 {STATE_STARTED, STATE_IDLE, STATE_IDLE, STATE_IDLE, STATE_IDLE};
93 private int[] startedTransition =
94 {STATE_STARTED, STATE_PENDING, STATE_STARTED, STATE_STARTED, STATE_STARTED};
95 private int[] pendingTransition =
96 {STATE_PENDING, STATE_PENDING, STATE_AUTHORIZED, STATE_UNAUTHORIZED, STATE_PENDING};
97 private int[] authorizedTransition =
Qianqian Hu0c349812016-02-15 17:25:22 +080098 {STATE_STARTED, STATE_AUTHORIZED, STATE_AUTHORIZED, STATE_AUTHORIZED, STATE_IDLE};
Ari Saha89831742015-06-26 10:31:48 -070099 private int[] unauthorizedTransition =
ke han04e47f32016-10-28 14:15:43 +0800100 {STATE_STARTED, STATE_UNAUTHORIZED, STATE_UNAUTHORIZED, STATE_UNAUTHORIZED, STATE_IDLE};
Ari Saha89831742015-06-26 10:31:48 -0700101
102 //THE TRANSITION TABLE
103 private int[][] transition =
104 {idleTransition, startedTransition, pendingTransition, authorizedTransition,
105 unauthorizedTransition};
106
107 private int currentState = STATE_IDLE;
108
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700109 // Maps of state machines. Each state machine is represented by an
110 // unique identifier on the switch: dpid + port number
111 private static Map<String, StateMachine> sessionIdMap;
112 private static Map<Integer, StateMachine> identifierMap;
Ari Saha89831742015-06-26 10:31:48 -0700113
Jonathan Hart5db44532018-07-12 18:13:54 -0700114 private static StateMachineDelegate delegate;
115
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700116 public static void initializeMaps() {
117 sessionIdMap = Maps.newConcurrentMap();
118 identifierMap = Maps.newConcurrentMap();
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100119 identifier = -1;
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700120 }
121
122 public static void destroyMaps() {
123 sessionIdMap = null;
124 identifierMap = null;
125 }
126
Matteo Scandolocf847b82019-04-26 15:00:00 -0700127 public static void setDelegate(StateMachineDelegate delegate) {
128 StateMachine.delegate = delegate;
Jonathan Hart5db44532018-07-12 18:13:54 -0700129 }
130
131 public static void unsetDelegate(StateMachineDelegate delegate) {
132 if (StateMachine.delegate == delegate) {
133 StateMachine.delegate = null;
134 }
135 }
136
Qianqian Hu61a6a402016-02-16 15:18:05 +0800137 public static Map<String, StateMachine> sessionIdMap() {
138 return sessionIdMap;
139 }
140
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700141 public static StateMachine lookupStateMachineById(byte identifier) {
142 return identifierMap.get((int) identifier);
143 }
144
145 public static StateMachine lookupStateMachineBySessionId(String sessionId) {
146 return sessionIdMap.get(sessionId);
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100147 }
148
149 public static void deleteStateMachineMapping(StateMachine machine) {
150 identifierMap.entrySet().removeIf(e -> e.getValue().equals(machine));
151 }
152
153 /**
David K. Bainbridge62019492017-07-28 17:02:10 -0700154 * Deletes authentication state machine records for a given MAC address.
155 * @param mac mac address of the suppliant who's state machine should be removed
156 */
157 public static void deleteByMac(MacAddress mac) {
158
159 // Walk the map from session IDs to state machines looking for a MAC match
160 for (Map.Entry<String, StateMachine> e : sessionIdMap.entrySet()) {
161
162 // If a MAC match is found then delete the entry from the session ID
163 // and identifier map as well as call delete identifier to clean up
164 // the identifier bit set.
165 if (e.getValue() != null && e.getValue().supplicantAddress != null &&
166 e.getValue().supplicantAddress.equals(mac)) {
167 sessionIdMap.remove(e.getValue().sessionId);
168 if (e.getValue().identifier != -1) {
169 deleteStateMachineMapping(e.getValue());
170 }
171 break;
172 }
173 }
174 }
175
176 /**
Jonathan Hart932bedc2018-07-12 13:46:09 -0700177 * Creates a new StateMachine with the given session ID.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700178 *
Jonathan Hart932bedc2018-07-12 13:46:09 -0700179 * @param sessionId session Id represented by the switch dpid + port number
Ari Saha89831742015-06-26 10:31:48 -0700180 */
Jonathan Hart932bedc2018-07-12 13:46:09 -0700181 public StateMachine(String sessionId) {
182 log.info("Creating a new state machine for {}", sessionId);
Ari Saha89831742015-06-26 10:31:48 -0700183 this.sessionId = sessionId;
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700184 sessionIdMap.put(sessionId, this);
Ari Saha89831742015-06-26 10:31:48 -0700185 }
186
187 /**
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700188 * Gets the connect point for the supplicant side.
189 *
190 * @return supplicant connect point
191 */
192 public ConnectPoint supplicantConnectpoint() {
193 return supplicantConnectpoint;
194 }
195
196 /**
197 * Sets the supplicant side connect point.
198 *
199 * @param supplicantConnectpoint supplicant select point.
200 */
201 public void setSupplicantConnectpoint(ConnectPoint supplicantConnectpoint) {
202 this.supplicantConnectpoint = supplicantConnectpoint;
203 }
204
205 /**
206 * Gets the MAC address of the supplicant.
207 *
208 * @return supplicant MAC address
209 */
210 public MacAddress supplicantAddress() {
211 return supplicantAddress;
212 }
213
214 /**
215 * Sets the supplicant MAC address.
216 *
217 * @param supplicantAddress new supplicant MAC address
218 */
219 public void setSupplicantAddress(MacAddress supplicantAddress) {
220 this.supplicantAddress = supplicantAddress;
221 }
222
223 /**
224 * Gets the client's Vlan ID.
225 *
226 * @return client vlan ID
227 */
228 public short vlanId() {
229 return vlanId;
230 }
231
232 /**
233 * Sets the client's vlan ID.
234 *
235 * @param vlanId new client vlan ID
236 */
237 public void setVlanId(short vlanId) {
238 this.vlanId = vlanId;
239 }
240
241 /**
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100242 * Gets the client's priority Code.
243 *
244 * @return client Priority code
245 */
246 public byte priorityCode() {
247 return priorityCode;
248 }
249
250 /**
251 * Sets the client's priority Code.
252 *
253 * @param priorityCode new client priority Code
254 */
255 public void setPriorityCode(byte priorityCode) {
256 this.priorityCode = priorityCode;
257 }
258
259 /**
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700260 * Gets the client id that is requesting for access.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700261 *
Ari Saha89831742015-06-26 10:31:48 -0700262 * @return The client id.
263 */
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700264 public String sessionId() {
Ari Saha89831742015-06-26 10:31:48 -0700265 return this.sessionId;
266 }
267
268 /**
Ari Saha89831742015-06-26 10:31:48 -0700269 * Set the challenge identifier and the state issued by the RADIUS.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700270 *
Ari Saha89831742015-06-26 10:31:48 -0700271 * @param challengeIdentifier The challenge identifier set into the EAP packet from the RADIUS message.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700272 * @param challengeState The challenge state from the RADIUS.
Ari Saha89831742015-06-26 10:31:48 -0700273 */
274 protected void setChallengeInfo(byte challengeIdentifier, byte[] challengeState) {
275 this.challengeIdentifier = challengeIdentifier;
276 this.challengeState = challengeState;
277 }
Thomas Vachuskae9894202015-07-30 11:59:07 -0700278
Ari Saha89831742015-06-26 10:31:48 -0700279 /**
280 * Set the challenge identifier issued by the RADIUS on the access challenge request.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700281 *
Ari Saha89831742015-06-26 10:31:48 -0700282 * @param challengeIdentifier The challenge identifier set into the EAP packet from the RADIUS message.
283 */
284 protected void setChallengeIdentifier(byte challengeIdentifier) {
285 log.info("Set Challenge Identifier to {}", challengeIdentifier);
286 this.challengeIdentifier = challengeIdentifier;
287 }
288
289 /**
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700290 * Gets the challenge EAP identifier set by the RADIUS.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700291 *
Ari Saha89831742015-06-26 10:31:48 -0700292 * @return The challenge EAP identifier.
293 */
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700294 protected byte challengeIdentifier() {
Ari Saha89831742015-06-26 10:31:48 -0700295 return this.challengeIdentifier;
296 }
297
298
299 /**
300 * Set the challenge state info issued by the RADIUS.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700301 *
Ari Saha89831742015-06-26 10:31:48 -0700302 * @param challengeState The challenge state from the RADIUS.
303 */
304 protected void setChallengeState(byte[] challengeState) {
305 log.info("Set Challenge State");
306 this.challengeState = challengeState;
307 }
308
309 /**
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700310 * Gets the challenge state set by the RADIUS.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700311 *
Ari Saha89831742015-06-26 10:31:48 -0700312 * @return The challenge state.
313 */
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700314 protected byte[] challengeState() {
Ari Saha89831742015-06-26 10:31:48 -0700315 return this.challengeState;
316 }
317
318 /**
319 * Set the username.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700320 *
Ari Saha89831742015-06-26 10:31:48 -0700321 * @param username The username sent to the RADIUS upon access request.
322 */
323 protected void setUsername(byte[] username) {
324 this.username = username;
325 }
326
Ari Saha89831742015-06-26 10:31:48 -0700327 /**
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700328 * Gets the username.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700329 *
Ari Saha89831742015-06-26 10:31:48 -0700330 * @return The requestAuthenticator.
331 */
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700332 protected byte[] requestAuthenticator() {
Ari Saha89831742015-06-26 10:31:48 -0700333 return this.requestAuthenticator;
334 }
335
336 /**
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700337 * Sets the authenticator.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700338 *
Ari Saha89831742015-06-26 10:31:48 -0700339 * @param authenticator The username sent to the RADIUS upon access request.
340 */
341 protected void setRequestAuthenticator(byte[] authenticator) {
342 this.requestAuthenticator = authenticator;
343 }
344
345
346 /**
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700347 * Gets the username.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700348 *
Ari Saha89831742015-06-26 10:31:48 -0700349 * @return The username.
350 */
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700351 protected byte[] username() {
Ari Saha89831742015-06-26 10:31:48 -0700352 return this.username;
353 }
354
355 /**
356 * Return the identifier of the state machine.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700357 *
Ari Saha89831742015-06-26 10:31:48 -0700358 * @return The state machine identifier.
359 */
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100360 public synchronized byte identifier() {
361 identifier = (identifier + 1) % 255;
362 identifierMap.put(identifier, this);
363 return (byte) identifier;
Ari Saha89831742015-06-26 10:31:48 -0700364 }
365
Ari Saha89831742015-06-26 10:31:48 -0700366 /**
367 * Move to the next state.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700368 *
Ray Milkey78e95a42015-09-24 08:36:45 -0700369 * @param msg message
Ari Saha89831742015-06-26 10:31:48 -0700370 */
Thomas Vachuskae9894202015-07-30 11:59:07 -0700371 private void next(int msg) {
Ari Saha89831742015-06-26 10:31:48 -0700372 currentState = transition[currentState][msg];
373 log.info("Current State " + currentState);
374 }
375
376 /**
377 * Client has requested the start action to allow network access.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700378 *
379 * @throws StateMachineException if authentication protocol is violated
Ari Saha89831742015-06-26 10:31:48 -0700380 */
381 public void start() throws StateMachineException {
Ray Milkey78e95a42015-09-24 08:36:45 -0700382 states[currentState].start();
Jonathan Hart5db44532018-07-12 18:13:54 -0700383
384 delegate.notify(new AuthenticationEvent(
385 AuthenticationEvent.Type.STARTED, supplicantConnectpoint));
386
Ray Milkey78e95a42015-09-24 08:36:45 -0700387 //move to the next state
388 next(TRANSITION_START);
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100389 identifier = this.identifier();
Ari Saha89831742015-06-26 10:31:48 -0700390 }
391
392 /**
393 * An Identification information has been sent by the supplicant.
394 * Move to the next state if possible.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700395 *
396 * @throws StateMachineException if authentication protocol is violated
Ari Saha89831742015-06-26 10:31:48 -0700397 */
398 public void requestAccess() throws StateMachineException {
Ray Milkey78e95a42015-09-24 08:36:45 -0700399 states[currentState].requestAccess();
Jonathan Hart5db44532018-07-12 18:13:54 -0700400
401 delegate.notify(new AuthenticationEvent(
402 AuthenticationEvent.Type.REQUESTED, supplicantConnectpoint));
403
Ray Milkey78e95a42015-09-24 08:36:45 -0700404 //move to the next state
405 next(TRANSITION_REQUEST_ACCESS);
Ari Saha89831742015-06-26 10:31:48 -0700406 }
407
408 /**
409 * RADIUS has accepted the identification.
410 * Move to the next state if possible.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700411 *
412 * @throws StateMachineException if authentication protocol is violated
Ari Saha89831742015-06-26 10:31:48 -0700413 */
414 public void authorizeAccess() throws StateMachineException {
Ray Milkey78e95a42015-09-24 08:36:45 -0700415 states[currentState].radiusAccepted();
416 //move to the next state
417 next(TRANSITION_AUTHORIZE_ACCESS);
Ari Saha89831742015-06-26 10:31:48 -0700418
Jonathan Hart5db44532018-07-12 18:13:54 -0700419 delegate.notify(new AuthenticationEvent(
420 AuthenticationEvent.Type.APPROVED, supplicantConnectpoint));
Ari Saha89831742015-06-26 10:31:48 -0700421
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100422 // Clear mapping
423 deleteStateMachineMapping(this);
Ari Saha89831742015-06-26 10:31:48 -0700424 }
425
426 /**
427 * RADIUS has denied the identification.
428 * Move to the next state if possible.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700429 *
430 * @throws StateMachineException if authentication protocol is violated
Ari Saha89831742015-06-26 10:31:48 -0700431 */
432 public void denyAccess() throws StateMachineException {
Ray Milkey78e95a42015-09-24 08:36:45 -0700433 states[currentState].radiusDenied();
434 //move to the next state
435 next(TRANSITION_DENY_ACCESS);
Jonathan Hart5db44532018-07-12 18:13:54 -0700436
437 delegate.notify(new AuthenticationEvent(
438 AuthenticationEvent.Type.DENIED, supplicantConnectpoint));
439
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100440 // Clear mappings
441 deleteStateMachineMapping(this);
Ari Saha89831742015-06-26 10:31:48 -0700442 }
443
444 /**
445 * Logoff request has been requested.
446 * Move to the next state if possible.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700447 *
448 * @throws StateMachineException if authentication protocol is violated
Ari Saha89831742015-06-26 10:31:48 -0700449 */
450 public void logoff() throws StateMachineException {
Ray Milkey78e95a42015-09-24 08:36:45 -0700451 states[currentState].logoff();
452 //move to the next state
453 next(TRANSITION_LOGOFF);
Ari Saha89831742015-06-26 10:31:48 -0700454 }
455
456 /**
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700457 * Gets the current state.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700458 *
Ari Saha89831742015-06-26 10:31:48 -0700459 * @return The current state. Could be STATE_IDLE, STATE_STARTED, STATE_PENDING, STATE_AUTHORIZED,
460 * STATE_UNAUTHORIZED.
461 */
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700462 public int state() {
Ari Saha89831742015-06-26 10:31:48 -0700463 return currentState;
464 }
465
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700466 @Override
Ari Saha89831742015-06-26 10:31:48 -0700467 public String toString() {
468 return ("sessionId: " + this.sessionId) + "\t" + ("identifier: " + this.identifier) + "\t" +
469 ("state: " + this.currentState);
470 }
Ari Saha89831742015-06-26 10:31:48 -0700471
Ray Milkey78e95a42015-09-24 08:36:45 -0700472 abstract class State {
473 private final Logger log = getLogger(getClass());
Thomas Vachuskae9894202015-07-30 11:59:07 -0700474
Ray Milkey78e95a42015-09-24 08:36:45 -0700475 private String name = "State";
Ari Saha89831742015-06-26 10:31:48 -0700476
Ray Milkey78e95a42015-09-24 08:36:45 -0700477 public void start() throws StateMachineInvalidTransitionException {
478 log.warn("START transition from this state is not allowed.");
479 }
Ari Saha89831742015-06-26 10:31:48 -0700480
Ray Milkey78e95a42015-09-24 08:36:45 -0700481 public void requestAccess() throws StateMachineInvalidTransitionException {
482 log.warn("REQUEST ACCESS transition from this state is not allowed.");
483 }
484
485 public void radiusAccepted() throws StateMachineInvalidTransitionException {
486 log.warn("AUTHORIZE ACCESS transition from this state is not allowed.");
487 }
488
489 public void radiusDenied() throws StateMachineInvalidTransitionException {
490 log.warn("DENY ACCESS transition from this state is not allowed.");
491 }
492
493 public void logoff() throws StateMachineInvalidTransitionException {
494 log.warn("LOGOFF transition from this state is not allowed.");
495 }
Ari Saha89831742015-06-26 10:31:48 -0700496 }
Thomas Vachuskae9894202015-07-30 11:59:07 -0700497
Ray Milkey78e95a42015-09-24 08:36:45 -0700498 /**
499 * Idle state: supplicant is logged of from the network.
500 */
501 class Idle extends State {
502 private final Logger log = getLogger(getClass());
503 private String name = "IDLE_STATE";
504
505 public void start() {
506 log.info("Moving from IDLE state to STARTED state.");
507 }
Ari Saha89831742015-06-26 10:31:48 -0700508 }
Thomas Vachuskae9894202015-07-30 11:59:07 -0700509
Ray Milkey78e95a42015-09-24 08:36:45 -0700510 /**
511 * Started state: supplicant has entered the network and informed the authenticator.
512 */
513 class Started extends State {
514 private final Logger log = getLogger(getClass());
515 private String name = "STARTED_STATE";
516
517 public void requestAccess() {
518 log.info("Moving from STARTED state to PENDING state.");
519 }
Ari Saha89831742015-06-26 10:31:48 -0700520 }
Thomas Vachuskae9894202015-07-30 11:59:07 -0700521
Ray Milkey78e95a42015-09-24 08:36:45 -0700522 /**
523 * Pending state: supplicant has been identified by the authenticator but has not access yet.
524 */
525 class Pending extends State {
526 private final Logger log = getLogger(getClass());
527 private String name = "PENDING_STATE";
528
529 public void radiusAccepted() {
530 log.info("Moving from PENDING state to AUTHORIZED state.");
531 }
532
533 public void radiusDenied() {
534 log.info("Moving from PENDING state to UNAUTHORIZED state.");
535 }
Ari Saha89831742015-06-26 10:31:48 -0700536 }
Thomas Vachuskae9894202015-07-30 11:59:07 -0700537
Ray Milkey78e95a42015-09-24 08:36:45 -0700538 /**
539 * Authorized state: supplicant port has been accepted, access is granted.
540 */
541 class Authorized extends State {
542 private final Logger log = getLogger(getClass());
543 private String name = "AUTHORIZED_STATE";
Ari Saha89831742015-06-26 10:31:48 -0700544
Qianqian Hu0c349812016-02-15 17:25:22 +0800545 public void start() {
546 log.info("Moving from AUTHORIZED state to STARTED state.");
547 }
548
Ray Milkey78e95a42015-09-24 08:36:45 -0700549 public void logoff() {
Ari Saha89831742015-06-26 10:31:48 -0700550
Ray Milkey78e95a42015-09-24 08:36:45 -0700551 log.info("Moving from AUTHORIZED state to IDLE state.");
552 }
Ari Saha89831742015-06-26 10:31:48 -0700553 }
554
Ray Milkey78e95a42015-09-24 08:36:45 -0700555 /**
556 * Unauthorized state: supplicant port has been rejected, access is denied.
557 */
558 class Unauthorized extends State {
559 private final Logger log = getLogger(getClass());
560 private String name = "UNAUTHORIZED_STATE";
561
ke han04e47f32016-10-28 14:15:43 +0800562 public void start() {
563 log.info("Moving from UNAUTHORIZED state to STARTED state.");
564 }
565
Ray Milkey78e95a42015-09-24 08:36:45 -0700566 public void logoff() {
567 log.info("Moving from UNAUTHORIZED state to IDLE state.");
568 }
Ari Saha89831742015-06-26 10:31:48 -0700569 }
Ari Saha89831742015-06-26 10:31:48 -0700570
571
Ari Saha89831742015-06-26 10:31:48 -0700572}