blob: a4b46aab449c59146c42091113e59dbd416c83ec [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;
Amit Ghoshc9ac1e52017-07-28 12:31:18 +010022import org.onlab.packet.VlanId;
Ari Saha89831742015-06-26 10:31:48 -070023import org.onosproject.net.ConnectPoint;
Amit Ghoshc9ac1e52017-07-28 12:31:18 +010024import org.opencord.olt.AccessDeviceService;
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 AccessDeviceService accessDeviceService;
Ari Saha89831742015-06-26 10:31:48 -070051
Amit Ghoshc9ac1e52017-07-28 12:31:18 +010052 private static int identifier = -1;
Ari Saha89831742015-06-26 10:31:48 -070053 private byte challengeIdentifier;
54 private byte[] challengeState;
55 private byte[] username;
56 private byte[] requestAuthenticator;
57
58 // Supplicant connectivity info
Ray Milkeyf61a24e2015-09-24 16:34:02 -070059 private ConnectPoint supplicantConnectpoint;
60 private MacAddress supplicantAddress;
61 private short vlanId;
Amit Ghoshc9ac1e52017-07-28 12:31:18 +010062 private VlanId ctag;
63 private byte priorityCode;
Ari Saha89831742015-06-26 10:31:48 -070064
65 private String sessionId = null;
66
67 private final Logger log = getLogger(getClass());
68
69
70 private State[] states = {
71 new Idle(), new Started(), new Pending(), new Authorized(), new Unauthorized()
72 };
73
74
75 //State transition table
76 /*
77
78 state IDLE | STARTED | PENDING | AUTHORIZED | UNAUTHORIZED
79 ////
80 input
81 ----------------------------------------------------------------------------------------------------
82
ke han04e47f32016-10-28 14:15:43 +080083 START STARTED | _ | _ | STARTED | STARTED
Ari Saha89831742015-06-26 10:31:48 -070084
85 REQUEST_ACCESS _ | PENDING | _ | _ | _
86
87 AUTHORIZE_ACCESS _ | _ | AUTHORIZED | _ | _
88
89 DENY_ACCESS _ | - | UNAUTHORIZED | _ | _
90
91 LOGOFF _ | _ | _ | IDLE | IDLE
92 */
93
94 private int[] idleTransition =
95 {STATE_STARTED, STATE_IDLE, STATE_IDLE, STATE_IDLE, STATE_IDLE};
96 private int[] startedTransition =
97 {STATE_STARTED, STATE_PENDING, STATE_STARTED, STATE_STARTED, STATE_STARTED};
98 private int[] pendingTransition =
99 {STATE_PENDING, STATE_PENDING, STATE_AUTHORIZED, STATE_UNAUTHORIZED, STATE_PENDING};
100 private int[] authorizedTransition =
Qianqian Hu0c349812016-02-15 17:25:22 +0800101 {STATE_STARTED, STATE_AUTHORIZED, STATE_AUTHORIZED, STATE_AUTHORIZED, STATE_IDLE};
Ari Saha89831742015-06-26 10:31:48 -0700102 private int[] unauthorizedTransition =
ke han04e47f32016-10-28 14:15:43 +0800103 {STATE_STARTED, STATE_UNAUTHORIZED, STATE_UNAUTHORIZED, STATE_UNAUTHORIZED, STATE_IDLE};
Ari Saha89831742015-06-26 10:31:48 -0700104
105 //THE TRANSITION TABLE
106 private int[][] transition =
107 {idleTransition, startedTransition, pendingTransition, authorizedTransition,
108 unauthorizedTransition};
109
110 private int currentState = STATE_IDLE;
111
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700112 // Maps of state machines. Each state machine is represented by an
113 // unique identifier on the switch: dpid + port number
114 private static Map<String, StateMachine> sessionIdMap;
115 private static Map<Integer, StateMachine> identifierMap;
Ari Saha89831742015-06-26 10:31:48 -0700116
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700117 public static void initializeMaps() {
118 sessionIdMap = Maps.newConcurrentMap();
119 identifierMap = Maps.newConcurrentMap();
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100120 identifier = -1;
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700121 }
122
123 public static void destroyMaps() {
124 sessionIdMap = null;
125 identifierMap = null;
126 }
127
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100128 public static void setAccessDeviceService(AccessDeviceService service) {
129 accessDeviceService = service;
130 }
131
Qianqian Hu61a6a402016-02-16 15:18:05 +0800132 public static Map<String, StateMachine> sessionIdMap() {
133 return sessionIdMap;
134 }
135
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700136 public static StateMachine lookupStateMachineById(byte identifier) {
137 return identifierMap.get((int) identifier);
138 }
139
140 public static StateMachine lookupStateMachineBySessionId(String sessionId) {
141 return sessionIdMap.get(sessionId);
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100142 }
143
144 public static void deleteStateMachineMapping(StateMachine machine) {
145 identifierMap.entrySet().removeIf(e -> e.getValue().equals(machine));
146 }
147
148 /**
David K. Bainbridge62019492017-07-28 17:02:10 -0700149 * Deletes authentication state machine records for a given MAC address.
150 * @param mac mac address of the suppliant who's state machine should be removed
151 */
152 public static void deleteByMac(MacAddress mac) {
153
154 // Walk the map from session IDs to state machines looking for a MAC match
155 for (Map.Entry<String, StateMachine> e : sessionIdMap.entrySet()) {
156
157 // If a MAC match is found then delete the entry from the session ID
158 // and identifier map as well as call delete identifier to clean up
159 // the identifier bit set.
160 if (e.getValue() != null && e.getValue().supplicantAddress != null &&
161 e.getValue().supplicantAddress.equals(mac)) {
162 sessionIdMap.remove(e.getValue().sessionId);
163 if (e.getValue().identifier != -1) {
164 deleteStateMachineMapping(e.getValue());
165 }
166 break;
167 }
168 }
169 }
170
171 /**
Ari Saha89831742015-06-26 10:31:48 -0700172 * State Machine Constructor.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700173 *
174 * @param sessionId session Id represented by the switch dpid + port number
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100175 * @param ctag C-TAG for this subscriber
Ari Saha89831742015-06-26 10:31:48 -0700176 */
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100177 public StateMachine(String sessionId, VlanId ctag) {
178 log.info("Creating a new state machine for {} C-TAG {}", sessionId,
179 ctag);
Ari Saha89831742015-06-26 10:31:48 -0700180 this.sessionId = sessionId;
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700181 sessionIdMap.put(sessionId, this);
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100182 this.ctag = ctag;
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();
381 //move to the next state
382 next(TRANSITION_START);
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100383 identifier = this.identifier();
Ari Saha89831742015-06-26 10:31:48 -0700384 }
385
386 /**
387 * An Identification information has been sent by the supplicant.
388 * Move to the next state if possible.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700389 *
390 * @throws StateMachineException if authentication protocol is violated
Ari Saha89831742015-06-26 10:31:48 -0700391 */
392 public void requestAccess() throws StateMachineException {
Ray Milkey78e95a42015-09-24 08:36:45 -0700393 states[currentState].requestAccess();
394 //move to the next state
395 next(TRANSITION_REQUEST_ACCESS);
Ari Saha89831742015-06-26 10:31:48 -0700396 }
397
398 /**
399 * RADIUS has accepted the identification.
400 * Move to the next state if possible.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700401 *
402 * @throws StateMachineException if authentication protocol is violated
Ari Saha89831742015-06-26 10:31:48 -0700403 */
404 public void authorizeAccess() throws StateMachineException {
Ray Milkey78e95a42015-09-24 08:36:45 -0700405 states[currentState].radiusAccepted();
406 //move to the next state
407 next(TRANSITION_AUTHORIZE_ACCESS);
Ari Saha89831742015-06-26 10:31:48 -0700408
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100409 if (accessDeviceService != null) {
410 log.info("Provisioning subscriber at {} with C-TAG {}",
411 supplicantConnectpoint(), ctag);
412 accessDeviceService.provisionSubscriber(supplicantConnectpoint(),
413 ctag);
414 }
Ari Saha89831742015-06-26 10:31:48 -0700415
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100416 // Clear mapping
417 deleteStateMachineMapping(this);
Ari Saha89831742015-06-26 10:31:48 -0700418 }
419
420 /**
421 * RADIUS has denied the identification.
422 * Move to the next state if possible.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700423 *
424 * @throws StateMachineException if authentication protocol is violated
Ari Saha89831742015-06-26 10:31:48 -0700425 */
426 public void denyAccess() throws StateMachineException {
Ray Milkey78e95a42015-09-24 08:36:45 -0700427 states[currentState].radiusDenied();
428 //move to the next state
429 next(TRANSITION_DENY_ACCESS);
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100430 // Clear mappings
431 deleteStateMachineMapping(this);
Ari Saha89831742015-06-26 10:31:48 -0700432 }
433
434 /**
435 * Logoff request has been requested.
436 * Move to the next state if possible.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700437 *
438 * @throws StateMachineException if authentication protocol is violated
Ari Saha89831742015-06-26 10:31:48 -0700439 */
440 public void logoff() throws StateMachineException {
Ray Milkey78e95a42015-09-24 08:36:45 -0700441 states[currentState].logoff();
442 //move to the next state
443 next(TRANSITION_LOGOFF);
Ari Saha89831742015-06-26 10:31:48 -0700444 }
445
446 /**
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700447 * Gets the current state.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700448 *
Ari Saha89831742015-06-26 10:31:48 -0700449 * @return The current state. Could be STATE_IDLE, STATE_STARTED, STATE_PENDING, STATE_AUTHORIZED,
450 * STATE_UNAUTHORIZED.
451 */
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700452 public int state() {
Ari Saha89831742015-06-26 10:31:48 -0700453 return currentState;
454 }
455
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700456 @Override
Ari Saha89831742015-06-26 10:31:48 -0700457 public String toString() {
458 return ("sessionId: " + this.sessionId) + "\t" + ("identifier: " + this.identifier) + "\t" +
459 ("state: " + this.currentState);
460 }
Ari Saha89831742015-06-26 10:31:48 -0700461
Ray Milkey78e95a42015-09-24 08:36:45 -0700462 abstract class State {
463 private final Logger log = getLogger(getClass());
Thomas Vachuskae9894202015-07-30 11:59:07 -0700464
Ray Milkey78e95a42015-09-24 08:36:45 -0700465 private String name = "State";
Ari Saha89831742015-06-26 10:31:48 -0700466
Ray Milkey78e95a42015-09-24 08:36:45 -0700467 public void start() throws StateMachineInvalidTransitionException {
468 log.warn("START transition from this state is not allowed.");
469 }
Ari Saha89831742015-06-26 10:31:48 -0700470
Ray Milkey78e95a42015-09-24 08:36:45 -0700471 public void requestAccess() throws StateMachineInvalidTransitionException {
472 log.warn("REQUEST ACCESS transition from this state is not allowed.");
473 }
474
475 public void radiusAccepted() throws StateMachineInvalidTransitionException {
476 log.warn("AUTHORIZE ACCESS transition from this state is not allowed.");
477 }
478
479 public void radiusDenied() throws StateMachineInvalidTransitionException {
480 log.warn("DENY ACCESS transition from this state is not allowed.");
481 }
482
483 public void logoff() throws StateMachineInvalidTransitionException {
484 log.warn("LOGOFF transition from this state is not allowed.");
485 }
Ari Saha89831742015-06-26 10:31:48 -0700486 }
Thomas Vachuskae9894202015-07-30 11:59:07 -0700487
Ray Milkey78e95a42015-09-24 08:36:45 -0700488 /**
489 * Idle state: supplicant is logged of from the network.
490 */
491 class Idle extends State {
492 private final Logger log = getLogger(getClass());
493 private String name = "IDLE_STATE";
494
495 public void start() {
496 log.info("Moving from IDLE state to STARTED state.");
497 }
Ari Saha89831742015-06-26 10:31:48 -0700498 }
Thomas Vachuskae9894202015-07-30 11:59:07 -0700499
Ray Milkey78e95a42015-09-24 08:36:45 -0700500 /**
501 * Started state: supplicant has entered the network and informed the authenticator.
502 */
503 class Started extends State {
504 private final Logger log = getLogger(getClass());
505 private String name = "STARTED_STATE";
506
507 public void requestAccess() {
508 log.info("Moving from STARTED state to PENDING state.");
509 }
Ari Saha89831742015-06-26 10:31:48 -0700510 }
Thomas Vachuskae9894202015-07-30 11:59:07 -0700511
Ray Milkey78e95a42015-09-24 08:36:45 -0700512 /**
513 * Pending state: supplicant has been identified by the authenticator but has not access yet.
514 */
515 class Pending extends State {
516 private final Logger log = getLogger(getClass());
517 private String name = "PENDING_STATE";
518
519 public void radiusAccepted() {
520 log.info("Moving from PENDING state to AUTHORIZED state.");
521 }
522
523 public void radiusDenied() {
524 log.info("Moving from PENDING state to UNAUTHORIZED state.");
525 }
Ari Saha89831742015-06-26 10:31:48 -0700526 }
Thomas Vachuskae9894202015-07-30 11:59:07 -0700527
Ray Milkey78e95a42015-09-24 08:36:45 -0700528 /**
529 * Authorized state: supplicant port has been accepted, access is granted.
530 */
531 class Authorized extends State {
532 private final Logger log = getLogger(getClass());
533 private String name = "AUTHORIZED_STATE";
Ari Saha89831742015-06-26 10:31:48 -0700534
Qianqian Hu0c349812016-02-15 17:25:22 +0800535 public void start() {
536 log.info("Moving from AUTHORIZED state to STARTED state.");
537 }
538
Ray Milkey78e95a42015-09-24 08:36:45 -0700539 public void logoff() {
Ari Saha89831742015-06-26 10:31:48 -0700540
Ray Milkey78e95a42015-09-24 08:36:45 -0700541 log.info("Moving from AUTHORIZED state to IDLE state.");
542 }
Ari Saha89831742015-06-26 10:31:48 -0700543 }
544
Ray Milkey78e95a42015-09-24 08:36:45 -0700545 /**
546 * Unauthorized state: supplicant port has been rejected, access is denied.
547 */
548 class Unauthorized extends State {
549 private final Logger log = getLogger(getClass());
550 private String name = "UNAUTHORIZED_STATE";
551
ke han04e47f32016-10-28 14:15:43 +0800552 public void start() {
553 log.info("Moving from UNAUTHORIZED state to STARTED state.");
554 }
555
Ray Milkey78e95a42015-09-24 08:36:45 -0700556 public void logoff() {
557 log.info("Moving from UNAUTHORIZED state to IDLE state.");
558 }
Ari Saha89831742015-06-26 10:31:48 -0700559 }
Ari Saha89831742015-06-26 10:31:48 -0700560
561
Ari Saha89831742015-06-26 10:31:48 -0700562}