blob: d888c9883b16bdaf658e1a6a8e612c2cf1083ad8 [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
alshabib6d527452016-06-01 18:00:47 -070018package org.opencord.aaa;
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;
Ari Saha89831742015-06-26 10:31:48 -070023import org.slf4j.Logger;
Thomas Vachuskae9894202015-07-30 11:59:07 -070024
Jonathan Hart4731dd92018-05-02 17:30:05 -070025import java.util.Map;
Ari Saha89831742015-06-26 10:31:48 -070026
27import static org.slf4j.LoggerFactory.getLogger;
28
29/**
30 * AAA Finite State Machine.
31 */
32
33class StateMachine {
34 //INDEX to identify the state in the transition table
35 static final int STATE_IDLE = 0;
36 static final int STATE_STARTED = 1;
37 static final int STATE_PENDING = 2;
38 static final int STATE_AUTHORIZED = 3;
39 static final int STATE_UNAUTHORIZED = 4;
40
41 //INDEX to identify the transition in the transition table
42 static final int TRANSITION_START = 0; // --> started
43 static final int TRANSITION_REQUEST_ACCESS = 1;
44 static final int TRANSITION_AUTHORIZE_ACCESS = 2;
45 static final int TRANSITION_DENY_ACCESS = 3;
46 static final int TRANSITION_LOGOFF = 4;
47
Amit Ghoshc9ac1e52017-07-28 12:31:18 +010048 private static int identifier = -1;
Ari Saha89831742015-06-26 10:31:48 -070049 private byte challengeIdentifier;
50 private byte[] challengeState;
51 private byte[] username;
52 private byte[] requestAuthenticator;
53
54 // Supplicant connectivity info
Ray Milkeyf61a24e2015-09-24 16:34:02 -070055 private ConnectPoint supplicantConnectpoint;
56 private MacAddress supplicantAddress;
57 private short vlanId;
Amit Ghoshc9ac1e52017-07-28 12:31:18 +010058 private byte priorityCode;
Ari Saha89831742015-06-26 10:31:48 -070059
60 private String sessionId = null;
61
62 private final Logger log = getLogger(getClass());
63
64
65 private State[] states = {
66 new Idle(), new Started(), new Pending(), new Authorized(), new Unauthorized()
67 };
68
69
70 //State transition table
71 /*
72
73 state IDLE | STARTED | PENDING | AUTHORIZED | UNAUTHORIZED
74 ////
75 input
76 ----------------------------------------------------------------------------------------------------
77
ke han04e47f32016-10-28 14:15:43 +080078 START STARTED | _ | _ | STARTED | STARTED
Ari Saha89831742015-06-26 10:31:48 -070079
80 REQUEST_ACCESS _ | PENDING | _ | _ | _
81
82 AUTHORIZE_ACCESS _ | _ | AUTHORIZED | _ | _
83
84 DENY_ACCESS _ | - | UNAUTHORIZED | _ | _
85
86 LOGOFF _ | _ | _ | IDLE | IDLE
87 */
88
89 private int[] idleTransition =
90 {STATE_STARTED, STATE_IDLE, STATE_IDLE, STATE_IDLE, STATE_IDLE};
91 private int[] startedTransition =
92 {STATE_STARTED, STATE_PENDING, STATE_STARTED, STATE_STARTED, STATE_STARTED};
93 private int[] pendingTransition =
94 {STATE_PENDING, STATE_PENDING, STATE_AUTHORIZED, STATE_UNAUTHORIZED, STATE_PENDING};
95 private int[] authorizedTransition =
Qianqian Hu0c349812016-02-15 17:25:22 +080096 {STATE_STARTED, STATE_AUTHORIZED, STATE_AUTHORIZED, STATE_AUTHORIZED, STATE_IDLE};
Ari Saha89831742015-06-26 10:31:48 -070097 private int[] unauthorizedTransition =
ke han04e47f32016-10-28 14:15:43 +080098 {STATE_STARTED, STATE_UNAUTHORIZED, STATE_UNAUTHORIZED, STATE_UNAUTHORIZED, STATE_IDLE};
Ari Saha89831742015-06-26 10:31:48 -070099
100 //THE TRANSITION TABLE
101 private int[][] transition =
102 {idleTransition, startedTransition, pendingTransition, authorizedTransition,
103 unauthorizedTransition};
104
105 private int currentState = STATE_IDLE;
106
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700107 // Maps of state machines. Each state machine is represented by an
108 // unique identifier on the switch: dpid + port number
109 private static Map<String, StateMachine> sessionIdMap;
110 private static Map<Integer, StateMachine> identifierMap;
Ari Saha89831742015-06-26 10:31:48 -0700111
Jonathan Hart5db44532018-07-12 18:13:54 -0700112 private static StateMachineDelegate delegate;
113
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700114 public static void initializeMaps() {
115 sessionIdMap = Maps.newConcurrentMap();
116 identifierMap = Maps.newConcurrentMap();
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100117 identifier = -1;
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700118 }
119
120 public static void destroyMaps() {
121 sessionIdMap = null;
122 identifierMap = null;
123 }
124
Jonathan Hart5db44532018-07-12 18:13:54 -0700125 public static void setDelegate(StateMachineDelegate delagate) {
126 StateMachine.delegate = delagate;
127 }
128
129 public static void unsetDelegate(StateMachineDelegate delegate) {
130 if (StateMachine.delegate == delegate) {
131 StateMachine.delegate = null;
132 }
133 }
134
Qianqian Hu61a6a402016-02-16 15:18:05 +0800135 public static Map<String, StateMachine> sessionIdMap() {
136 return sessionIdMap;
137 }
138
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700139 public static StateMachine lookupStateMachineById(byte identifier) {
140 return identifierMap.get((int) identifier);
141 }
142
143 public static StateMachine lookupStateMachineBySessionId(String sessionId) {
144 return sessionIdMap.get(sessionId);
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100145 }
146
147 public static void deleteStateMachineMapping(StateMachine machine) {
148 identifierMap.entrySet().removeIf(e -> e.getValue().equals(machine));
149 }
150
151 /**
David K. Bainbridge62019492017-07-28 17:02:10 -0700152 * Deletes authentication state machine records for a given MAC address.
153 * @param mac mac address of the suppliant who's state machine should be removed
154 */
155 public static void deleteByMac(MacAddress mac) {
156
157 // Walk the map from session IDs to state machines looking for a MAC match
158 for (Map.Entry<String, StateMachine> e : sessionIdMap.entrySet()) {
159
160 // If a MAC match is found then delete the entry from the session ID
161 // and identifier map as well as call delete identifier to clean up
162 // the identifier bit set.
163 if (e.getValue() != null && e.getValue().supplicantAddress != null &&
164 e.getValue().supplicantAddress.equals(mac)) {
165 sessionIdMap.remove(e.getValue().sessionId);
166 if (e.getValue().identifier != -1) {
167 deleteStateMachineMapping(e.getValue());
168 }
169 break;
170 }
171 }
172 }
173
174 /**
Jonathan Hart932bedc2018-07-12 13:46:09 -0700175 * Creates a new StateMachine with the given session ID.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700176 *
Jonathan Hart932bedc2018-07-12 13:46:09 -0700177 * @param sessionId session Id represented by the switch dpid + port number
Ari Saha89831742015-06-26 10:31:48 -0700178 */
Jonathan Hart932bedc2018-07-12 13:46:09 -0700179 public StateMachine(String sessionId) {
180 log.info("Creating a new state machine for {}", sessionId);
Ari Saha89831742015-06-26 10:31:48 -0700181 this.sessionId = sessionId;
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700182 sessionIdMap.put(sessionId, this);
Ari Saha89831742015-06-26 10:31:48 -0700183 }
184
185 /**
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700186 * Gets the connect point for the supplicant side.
187 *
188 * @return supplicant connect point
189 */
190 public ConnectPoint supplicantConnectpoint() {
191 return supplicantConnectpoint;
192 }
193
194 /**
195 * Sets the supplicant side connect point.
196 *
197 * @param supplicantConnectpoint supplicant select point.
198 */
199 public void setSupplicantConnectpoint(ConnectPoint supplicantConnectpoint) {
200 this.supplicantConnectpoint = supplicantConnectpoint;
201 }
202
203 /**
204 * Gets the MAC address of the supplicant.
205 *
206 * @return supplicant MAC address
207 */
208 public MacAddress supplicantAddress() {
209 return supplicantAddress;
210 }
211
212 /**
213 * Sets the supplicant MAC address.
214 *
215 * @param supplicantAddress new supplicant MAC address
216 */
217 public void setSupplicantAddress(MacAddress supplicantAddress) {
218 this.supplicantAddress = supplicantAddress;
219 }
220
221 /**
222 * Gets the client's Vlan ID.
223 *
224 * @return client vlan ID
225 */
226 public short vlanId() {
227 return vlanId;
228 }
229
230 /**
231 * Sets the client's vlan ID.
232 *
233 * @param vlanId new client vlan ID
234 */
235 public void setVlanId(short vlanId) {
236 this.vlanId = vlanId;
237 }
238
239 /**
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100240 * Gets the client's priority Code.
241 *
242 * @return client Priority code
243 */
244 public byte priorityCode() {
245 return priorityCode;
246 }
247
248 /**
249 * Sets the client's priority Code.
250 *
251 * @param priorityCode new client priority Code
252 */
253 public void setPriorityCode(byte priorityCode) {
254 this.priorityCode = priorityCode;
255 }
256
257 /**
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700258 * Gets the client id that is requesting for access.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700259 *
Ari Saha89831742015-06-26 10:31:48 -0700260 * @return The client id.
261 */
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700262 public String sessionId() {
Ari Saha89831742015-06-26 10:31:48 -0700263 return this.sessionId;
264 }
265
266 /**
Ari Saha89831742015-06-26 10:31:48 -0700267 * Set the challenge identifier and the state issued by the RADIUS.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700268 *
Ari Saha89831742015-06-26 10:31:48 -0700269 * @param challengeIdentifier The challenge identifier set into the EAP packet from the RADIUS message.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700270 * @param challengeState The challenge state from the RADIUS.
Ari Saha89831742015-06-26 10:31:48 -0700271 */
272 protected void setChallengeInfo(byte challengeIdentifier, byte[] challengeState) {
273 this.challengeIdentifier = challengeIdentifier;
274 this.challengeState = challengeState;
275 }
Thomas Vachuskae9894202015-07-30 11:59:07 -0700276
Ari Saha89831742015-06-26 10:31:48 -0700277 /**
278 * Set the challenge identifier issued by the RADIUS on the access challenge request.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700279 *
Ari Saha89831742015-06-26 10:31:48 -0700280 * @param challengeIdentifier The challenge identifier set into the EAP packet from the RADIUS message.
281 */
282 protected void setChallengeIdentifier(byte challengeIdentifier) {
283 log.info("Set Challenge Identifier to {}", challengeIdentifier);
284 this.challengeIdentifier = challengeIdentifier;
285 }
286
287 /**
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700288 * Gets the challenge EAP identifier set by the RADIUS.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700289 *
Ari Saha89831742015-06-26 10:31:48 -0700290 * @return The challenge EAP identifier.
291 */
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700292 protected byte challengeIdentifier() {
Ari Saha89831742015-06-26 10:31:48 -0700293 return this.challengeIdentifier;
294 }
295
296
297 /**
298 * Set the challenge state info issued by the RADIUS.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700299 *
Ari Saha89831742015-06-26 10:31:48 -0700300 * @param challengeState The challenge state from the RADIUS.
301 */
302 protected void setChallengeState(byte[] challengeState) {
303 log.info("Set Challenge State");
304 this.challengeState = challengeState;
305 }
306
307 /**
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700308 * Gets the challenge state set by the RADIUS.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700309 *
Ari Saha89831742015-06-26 10:31:48 -0700310 * @return The challenge state.
311 */
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700312 protected byte[] challengeState() {
Ari Saha89831742015-06-26 10:31:48 -0700313 return this.challengeState;
314 }
315
316 /**
317 * Set the username.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700318 *
Ari Saha89831742015-06-26 10:31:48 -0700319 * @param username The username sent to the RADIUS upon access request.
320 */
321 protected void setUsername(byte[] username) {
322 this.username = username;
323 }
324
Ari Saha89831742015-06-26 10:31:48 -0700325 /**
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700326 * Gets the username.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700327 *
Ari Saha89831742015-06-26 10:31:48 -0700328 * @return The requestAuthenticator.
329 */
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700330 protected byte[] requestAuthenticator() {
Ari Saha89831742015-06-26 10:31:48 -0700331 return this.requestAuthenticator;
332 }
333
334 /**
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700335 * Sets the authenticator.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700336 *
Ari Saha89831742015-06-26 10:31:48 -0700337 * @param authenticator The username sent to the RADIUS upon access request.
338 */
339 protected void setRequestAuthenticator(byte[] authenticator) {
340 this.requestAuthenticator = authenticator;
341 }
342
343
344 /**
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700345 * Gets the username.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700346 *
Ari Saha89831742015-06-26 10:31:48 -0700347 * @return The username.
348 */
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700349 protected byte[] username() {
Ari Saha89831742015-06-26 10:31:48 -0700350 return this.username;
351 }
352
353 /**
354 * Return the identifier of the state machine.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700355 *
Ari Saha89831742015-06-26 10:31:48 -0700356 * @return The state machine identifier.
357 */
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100358 public synchronized byte identifier() {
359 identifier = (identifier + 1) % 255;
360 identifierMap.put(identifier, this);
361 return (byte) identifier;
Ari Saha89831742015-06-26 10:31:48 -0700362 }
363
Ari Saha89831742015-06-26 10:31:48 -0700364 /**
365 * Move to the next state.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700366 *
Ray Milkey78e95a42015-09-24 08:36:45 -0700367 * @param msg message
Ari Saha89831742015-06-26 10:31:48 -0700368 */
Thomas Vachuskae9894202015-07-30 11:59:07 -0700369 private void next(int msg) {
Ari Saha89831742015-06-26 10:31:48 -0700370 currentState = transition[currentState][msg];
371 log.info("Current State " + currentState);
372 }
373
374 /**
375 * Client has requested the start action to allow network access.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700376 *
377 * @throws StateMachineException if authentication protocol is violated
Ari Saha89831742015-06-26 10:31:48 -0700378 */
379 public void start() throws StateMachineException {
Ray Milkey78e95a42015-09-24 08:36:45 -0700380 states[currentState].start();
Jonathan Hart5db44532018-07-12 18:13:54 -0700381
382 delegate.notify(new AuthenticationEvent(
383 AuthenticationEvent.Type.STARTED, supplicantConnectpoint));
384
Ray Milkey78e95a42015-09-24 08:36:45 -0700385 //move to the next state
386 next(TRANSITION_START);
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100387 identifier = this.identifier();
Ari Saha89831742015-06-26 10:31:48 -0700388 }
389
390 /**
391 * An Identification information has been sent by the supplicant.
392 * Move to the next state if possible.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700393 *
394 * @throws StateMachineException if authentication protocol is violated
Ari Saha89831742015-06-26 10:31:48 -0700395 */
396 public void requestAccess() throws StateMachineException {
Ray Milkey78e95a42015-09-24 08:36:45 -0700397 states[currentState].requestAccess();
Jonathan Hart5db44532018-07-12 18:13:54 -0700398
399 delegate.notify(new AuthenticationEvent(
400 AuthenticationEvent.Type.REQUESTED, supplicantConnectpoint));
401
Ray Milkey78e95a42015-09-24 08:36:45 -0700402 //move to the next state
403 next(TRANSITION_REQUEST_ACCESS);
Ari Saha89831742015-06-26 10:31:48 -0700404 }
405
406 /**
407 * RADIUS has accepted the identification.
408 * Move to the next state if possible.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700409 *
410 * @throws StateMachineException if authentication protocol is violated
Ari Saha89831742015-06-26 10:31:48 -0700411 */
412 public void authorizeAccess() throws StateMachineException {
Ray Milkey78e95a42015-09-24 08:36:45 -0700413 states[currentState].radiusAccepted();
414 //move to the next state
415 next(TRANSITION_AUTHORIZE_ACCESS);
Ari Saha89831742015-06-26 10:31:48 -0700416
Jonathan Hart5db44532018-07-12 18:13:54 -0700417 delegate.notify(new AuthenticationEvent(
418 AuthenticationEvent.Type.APPROVED, supplicantConnectpoint));
Ari Saha89831742015-06-26 10:31:48 -0700419
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100420 // Clear mapping
421 deleteStateMachineMapping(this);
Ari Saha89831742015-06-26 10:31:48 -0700422 }
423
424 /**
425 * RADIUS has denied the identification.
426 * Move to the next state if possible.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700427 *
428 * @throws StateMachineException if authentication protocol is violated
Ari Saha89831742015-06-26 10:31:48 -0700429 */
430 public void denyAccess() throws StateMachineException {
Ray Milkey78e95a42015-09-24 08:36:45 -0700431 states[currentState].radiusDenied();
432 //move to the next state
433 next(TRANSITION_DENY_ACCESS);
Jonathan Hart5db44532018-07-12 18:13:54 -0700434
435 delegate.notify(new AuthenticationEvent(
436 AuthenticationEvent.Type.DENIED, supplicantConnectpoint));
437
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100438 // Clear mappings
439 deleteStateMachineMapping(this);
Ari Saha89831742015-06-26 10:31:48 -0700440 }
441
442 /**
443 * Logoff request has been requested.
444 * Move to the next state if possible.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700445 *
446 * @throws StateMachineException if authentication protocol is violated
Ari Saha89831742015-06-26 10:31:48 -0700447 */
448 public void logoff() throws StateMachineException {
Ray Milkey78e95a42015-09-24 08:36:45 -0700449 states[currentState].logoff();
450 //move to the next state
451 next(TRANSITION_LOGOFF);
Ari Saha89831742015-06-26 10:31:48 -0700452 }
453
454 /**
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700455 * Gets the current state.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700456 *
Ari Saha89831742015-06-26 10:31:48 -0700457 * @return The current state. Could be STATE_IDLE, STATE_STARTED, STATE_PENDING, STATE_AUTHORIZED,
458 * STATE_UNAUTHORIZED.
459 */
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700460 public int state() {
Ari Saha89831742015-06-26 10:31:48 -0700461 return currentState;
462 }
463
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700464 @Override
Ari Saha89831742015-06-26 10:31:48 -0700465 public String toString() {
466 return ("sessionId: " + this.sessionId) + "\t" + ("identifier: " + this.identifier) + "\t" +
467 ("state: " + this.currentState);
468 }
Ari Saha89831742015-06-26 10:31:48 -0700469
Ray Milkey78e95a42015-09-24 08:36:45 -0700470 abstract class State {
471 private final Logger log = getLogger(getClass());
Thomas Vachuskae9894202015-07-30 11:59:07 -0700472
Ray Milkey78e95a42015-09-24 08:36:45 -0700473 private String name = "State";
Ari Saha89831742015-06-26 10:31:48 -0700474
Ray Milkey78e95a42015-09-24 08:36:45 -0700475 public void start() throws StateMachineInvalidTransitionException {
476 log.warn("START transition from this state is not allowed.");
477 }
Ari Saha89831742015-06-26 10:31:48 -0700478
Ray Milkey78e95a42015-09-24 08:36:45 -0700479 public void requestAccess() throws StateMachineInvalidTransitionException {
480 log.warn("REQUEST ACCESS transition from this state is not allowed.");
481 }
482
483 public void radiusAccepted() throws StateMachineInvalidTransitionException {
484 log.warn("AUTHORIZE ACCESS transition from this state is not allowed.");
485 }
486
487 public void radiusDenied() throws StateMachineInvalidTransitionException {
488 log.warn("DENY ACCESS transition from this state is not allowed.");
489 }
490
491 public void logoff() throws StateMachineInvalidTransitionException {
492 log.warn("LOGOFF transition from this state is not allowed.");
493 }
Ari Saha89831742015-06-26 10:31:48 -0700494 }
Thomas Vachuskae9894202015-07-30 11:59:07 -0700495
Ray Milkey78e95a42015-09-24 08:36:45 -0700496 /**
497 * Idle state: supplicant is logged of from the network.
498 */
499 class Idle extends State {
500 private final Logger log = getLogger(getClass());
501 private String name = "IDLE_STATE";
502
503 public void start() {
504 log.info("Moving from IDLE state to STARTED state.");
505 }
Ari Saha89831742015-06-26 10:31:48 -0700506 }
Thomas Vachuskae9894202015-07-30 11:59:07 -0700507
Ray Milkey78e95a42015-09-24 08:36:45 -0700508 /**
509 * Started state: supplicant has entered the network and informed the authenticator.
510 */
511 class Started extends State {
512 private final Logger log = getLogger(getClass());
513 private String name = "STARTED_STATE";
514
515 public void requestAccess() {
516 log.info("Moving from STARTED state to PENDING state.");
517 }
Ari Saha89831742015-06-26 10:31:48 -0700518 }
Thomas Vachuskae9894202015-07-30 11:59:07 -0700519
Ray Milkey78e95a42015-09-24 08:36:45 -0700520 /**
521 * Pending state: supplicant has been identified by the authenticator but has not access yet.
522 */
523 class Pending extends State {
524 private final Logger log = getLogger(getClass());
525 private String name = "PENDING_STATE";
526
527 public void radiusAccepted() {
528 log.info("Moving from PENDING state to AUTHORIZED state.");
529 }
530
531 public void radiusDenied() {
532 log.info("Moving from PENDING state to UNAUTHORIZED state.");
533 }
Ari Saha89831742015-06-26 10:31:48 -0700534 }
Thomas Vachuskae9894202015-07-30 11:59:07 -0700535
Ray Milkey78e95a42015-09-24 08:36:45 -0700536 /**
537 * Authorized state: supplicant port has been accepted, access is granted.
538 */
539 class Authorized extends State {
540 private final Logger log = getLogger(getClass());
541 private String name = "AUTHORIZED_STATE";
Ari Saha89831742015-06-26 10:31:48 -0700542
Qianqian Hu0c349812016-02-15 17:25:22 +0800543 public void start() {
544 log.info("Moving from AUTHORIZED state to STARTED state.");
545 }
546
Ray Milkey78e95a42015-09-24 08:36:45 -0700547 public void logoff() {
Ari Saha89831742015-06-26 10:31:48 -0700548
Ray Milkey78e95a42015-09-24 08:36:45 -0700549 log.info("Moving from AUTHORIZED state to IDLE state.");
550 }
Ari Saha89831742015-06-26 10:31:48 -0700551 }
552
Ray Milkey78e95a42015-09-24 08:36:45 -0700553 /**
554 * Unauthorized state: supplicant port has been rejected, access is denied.
555 */
556 class Unauthorized extends State {
557 private final Logger log = getLogger(getClass());
558 private String name = "UNAUTHORIZED_STATE";
559
ke han04e47f32016-10-28 14:15:43 +0800560 public void start() {
561 log.info("Moving from UNAUTHORIZED state to STARTED state.");
562 }
563
Ray Milkey78e95a42015-09-24 08:36:45 -0700564 public void logoff() {
565 log.info("Moving from UNAUTHORIZED state to IDLE state.");
566 }
Ari Saha89831742015-06-26 10:31:48 -0700567 }
Ari Saha89831742015-06-26 10:31:48 -0700568
569
Ari Saha89831742015-06-26 10:31:48 -0700570}