blob: 6795c4372bbb7deb194f5d5de70ca376c5351c1b [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
Ray Milkeyf61a24e2015-09-24 16:34:02 -070020import java.util.Map;
21
Ari Saha89831742015-06-26 10:31:48 -070022import org.onlab.packet.MacAddress;
Amit Ghoshc9ac1e52017-07-28 12:31:18 +010023import org.onlab.packet.VlanId;
Ari Saha89831742015-06-26 10:31:48 -070024import org.onosproject.net.ConnectPoint;
Amit Ghoshc9ac1e52017-07-28 12:31:18 +010025
26import org.opencord.olt.AccessDeviceService;
27
Ari Saha89831742015-06-26 10:31:48 -070028import org.slf4j.Logger;
Thomas Vachuskae9894202015-07-30 11:59:07 -070029
Ray Milkeyf61a24e2015-09-24 16:34:02 -070030import com.google.common.collect.Maps;
Ari Saha89831742015-06-26 10:31:48 -070031
32import static org.slf4j.LoggerFactory.getLogger;
33
34/**
35 * AAA Finite State Machine.
36 */
37
38class StateMachine {
39 //INDEX to identify the state in the transition table
40 static final int STATE_IDLE = 0;
41 static final int STATE_STARTED = 1;
42 static final int STATE_PENDING = 2;
43 static final int STATE_AUTHORIZED = 3;
44 static final int STATE_UNAUTHORIZED = 4;
45
46 //INDEX to identify the transition in the transition table
47 static final int TRANSITION_START = 0; // --> started
48 static final int TRANSITION_REQUEST_ACCESS = 1;
49 static final int TRANSITION_AUTHORIZE_ACCESS = 2;
50 static final int TRANSITION_DENY_ACCESS = 3;
51 static final int TRANSITION_LOGOFF = 4;
52
Amit Ghoshc9ac1e52017-07-28 12:31:18 +010053 private static AccessDeviceService accessDeviceService;
Ari Saha89831742015-06-26 10:31:48 -070054
Amit Ghoshc9ac1e52017-07-28 12:31:18 +010055 private static int identifier = -1;
Ari Saha89831742015-06-26 10:31:48 -070056 private byte challengeIdentifier;
57 private byte[] challengeState;
58 private byte[] username;
59 private byte[] requestAuthenticator;
60
61 // Supplicant connectivity info
Ray Milkeyf61a24e2015-09-24 16:34:02 -070062 private ConnectPoint supplicantConnectpoint;
63 private MacAddress supplicantAddress;
64 private short vlanId;
Amit Ghoshc9ac1e52017-07-28 12:31:18 +010065 private VlanId ctag;
66 private byte priorityCode;
Ari Saha89831742015-06-26 10:31:48 -070067
68 private String sessionId = null;
69
70 private final Logger log = getLogger(getClass());
71
72
73 private State[] states = {
74 new Idle(), new Started(), new Pending(), new Authorized(), new Unauthorized()
75 };
76
77
78 //State transition table
79 /*
80
81 state IDLE | STARTED | PENDING | AUTHORIZED | UNAUTHORIZED
82 ////
83 input
84 ----------------------------------------------------------------------------------------------------
85
ke han04e47f32016-10-28 14:15:43 +080086 START STARTED | _ | _ | STARTED | STARTED
Ari Saha89831742015-06-26 10:31:48 -070087
88 REQUEST_ACCESS _ | PENDING | _ | _ | _
89
90 AUTHORIZE_ACCESS _ | _ | AUTHORIZED | _ | _
91
92 DENY_ACCESS _ | - | UNAUTHORIZED | _ | _
93
94 LOGOFF _ | _ | _ | IDLE | IDLE
95 */
96
97 private int[] idleTransition =
98 {STATE_STARTED, STATE_IDLE, STATE_IDLE, STATE_IDLE, STATE_IDLE};
99 private int[] startedTransition =
100 {STATE_STARTED, STATE_PENDING, STATE_STARTED, STATE_STARTED, STATE_STARTED};
101 private int[] pendingTransition =
102 {STATE_PENDING, STATE_PENDING, STATE_AUTHORIZED, STATE_UNAUTHORIZED, STATE_PENDING};
103 private int[] authorizedTransition =
Qianqian Hu0c349812016-02-15 17:25:22 +0800104 {STATE_STARTED, STATE_AUTHORIZED, STATE_AUTHORIZED, STATE_AUTHORIZED, STATE_IDLE};
Ari Saha89831742015-06-26 10:31:48 -0700105 private int[] unauthorizedTransition =
ke han04e47f32016-10-28 14:15:43 +0800106 {STATE_STARTED, STATE_UNAUTHORIZED, STATE_UNAUTHORIZED, STATE_UNAUTHORIZED, STATE_IDLE};
Ari Saha89831742015-06-26 10:31:48 -0700107
108 //THE TRANSITION TABLE
109 private int[][] transition =
110 {idleTransition, startedTransition, pendingTransition, authorizedTransition,
111 unauthorizedTransition};
112
113 private int currentState = STATE_IDLE;
114
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700115 // Maps of state machines. Each state machine is represented by an
116 // unique identifier on the switch: dpid + port number
117 private static Map<String, StateMachine> sessionIdMap;
118 private static Map<Integer, StateMachine> identifierMap;
Ari Saha89831742015-06-26 10:31:48 -0700119
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700120 public static void initializeMaps() {
121 sessionIdMap = Maps.newConcurrentMap();
122 identifierMap = Maps.newConcurrentMap();
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100123 identifier = -1;
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700124 }
125
126 public static void destroyMaps() {
127 sessionIdMap = null;
128 identifierMap = null;
129 }
130
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100131 public static void setAccessDeviceService(AccessDeviceService service) {
132 accessDeviceService = service;
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 /**
Ari Saha89831742015-06-26 10:31:48 -0700175 * State Machine Constructor.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700176 *
177 * @param sessionId session Id represented by the switch dpid + port number
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100178 * @param ctag C-TAG for this subscriber
Ari Saha89831742015-06-26 10:31:48 -0700179 */
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100180 public StateMachine(String sessionId, VlanId ctag) {
181 log.info("Creating a new state machine for {} C-TAG {}", sessionId,
182 ctag);
Ari Saha89831742015-06-26 10:31:48 -0700183 this.sessionId = sessionId;
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700184 sessionIdMap.put(sessionId, this);
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100185 this.ctag = ctag;
Ari Saha89831742015-06-26 10:31:48 -0700186 }
187
188 /**
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700189 * Gets the connect point for the supplicant side.
190 *
191 * @return supplicant connect point
192 */
193 public ConnectPoint supplicantConnectpoint() {
194 return supplicantConnectpoint;
195 }
196
197 /**
198 * Sets the supplicant side connect point.
199 *
200 * @param supplicantConnectpoint supplicant select point.
201 */
202 public void setSupplicantConnectpoint(ConnectPoint supplicantConnectpoint) {
203 this.supplicantConnectpoint = supplicantConnectpoint;
204 }
205
206 /**
207 * Gets the MAC address of the supplicant.
208 *
209 * @return supplicant MAC address
210 */
211 public MacAddress supplicantAddress() {
212 return supplicantAddress;
213 }
214
215 /**
216 * Sets the supplicant MAC address.
217 *
218 * @param supplicantAddress new supplicant MAC address
219 */
220 public void setSupplicantAddress(MacAddress supplicantAddress) {
221 this.supplicantAddress = supplicantAddress;
222 }
223
224 /**
225 * Gets the client's Vlan ID.
226 *
227 * @return client vlan ID
228 */
229 public short vlanId() {
230 return vlanId;
231 }
232
233 /**
234 * Sets the client's vlan ID.
235 *
236 * @param vlanId new client vlan ID
237 */
238 public void setVlanId(short vlanId) {
239 this.vlanId = vlanId;
240 }
241
242 /**
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100243 * Gets the client's priority Code.
244 *
245 * @return client Priority code
246 */
247 public byte priorityCode() {
248 return priorityCode;
249 }
250
251 /**
252 * Sets the client's priority Code.
253 *
254 * @param priorityCode new client priority Code
255 */
256 public void setPriorityCode(byte priorityCode) {
257 this.priorityCode = priorityCode;
258 }
259
260 /**
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700261 * Gets the client id that is requesting for access.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700262 *
Ari Saha89831742015-06-26 10:31:48 -0700263 * @return The client id.
264 */
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700265 public String sessionId() {
Ari Saha89831742015-06-26 10:31:48 -0700266 return this.sessionId;
267 }
268
269 /**
Ari Saha89831742015-06-26 10:31:48 -0700270 * Set the challenge identifier and the state issued by the RADIUS.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700271 *
Ari Saha89831742015-06-26 10:31:48 -0700272 * @param challengeIdentifier The challenge identifier set into the EAP packet from the RADIUS message.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700273 * @param challengeState The challenge state from the RADIUS.
Ari Saha89831742015-06-26 10:31:48 -0700274 */
275 protected void setChallengeInfo(byte challengeIdentifier, byte[] challengeState) {
276 this.challengeIdentifier = challengeIdentifier;
277 this.challengeState = challengeState;
278 }
Thomas Vachuskae9894202015-07-30 11:59:07 -0700279
Ari Saha89831742015-06-26 10:31:48 -0700280 /**
281 * Set the challenge identifier issued by the RADIUS on the access challenge request.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700282 *
Ari Saha89831742015-06-26 10:31:48 -0700283 * @param challengeIdentifier The challenge identifier set into the EAP packet from the RADIUS message.
284 */
285 protected void setChallengeIdentifier(byte challengeIdentifier) {
286 log.info("Set Challenge Identifier to {}", challengeIdentifier);
287 this.challengeIdentifier = challengeIdentifier;
288 }
289
290 /**
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700291 * Gets the challenge EAP identifier set by the RADIUS.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700292 *
Ari Saha89831742015-06-26 10:31:48 -0700293 * @return The challenge EAP identifier.
294 */
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700295 protected byte challengeIdentifier() {
Ari Saha89831742015-06-26 10:31:48 -0700296 return this.challengeIdentifier;
297 }
298
299
300 /**
301 * Set the challenge state info issued by the RADIUS.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700302 *
Ari Saha89831742015-06-26 10:31:48 -0700303 * @param challengeState The challenge state from the RADIUS.
304 */
305 protected void setChallengeState(byte[] challengeState) {
306 log.info("Set Challenge State");
307 this.challengeState = challengeState;
308 }
309
310 /**
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700311 * Gets the challenge state set by the RADIUS.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700312 *
Ari Saha89831742015-06-26 10:31:48 -0700313 * @return The challenge state.
314 */
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700315 protected byte[] challengeState() {
Ari Saha89831742015-06-26 10:31:48 -0700316 return this.challengeState;
317 }
318
319 /**
320 * Set the username.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700321 *
Ari Saha89831742015-06-26 10:31:48 -0700322 * @param username The username sent to the RADIUS upon access request.
323 */
324 protected void setUsername(byte[] username) {
325 this.username = username;
326 }
327
Ari Saha89831742015-06-26 10:31:48 -0700328 /**
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700329 * Gets the username.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700330 *
Ari Saha89831742015-06-26 10:31:48 -0700331 * @return The requestAuthenticator.
332 */
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700333 protected byte[] requestAuthenticator() {
Ari Saha89831742015-06-26 10:31:48 -0700334 return this.requestAuthenticator;
335 }
336
337 /**
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700338 * Sets the authenticator.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700339 *
Ari Saha89831742015-06-26 10:31:48 -0700340 * @param authenticator The username sent to the RADIUS upon access request.
341 */
342 protected void setRequestAuthenticator(byte[] authenticator) {
343 this.requestAuthenticator = authenticator;
344 }
345
346
347 /**
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700348 * Gets the username.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700349 *
Ari Saha89831742015-06-26 10:31:48 -0700350 * @return The username.
351 */
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700352 protected byte[] username() {
Ari Saha89831742015-06-26 10:31:48 -0700353 return this.username;
354 }
355
356 /**
357 * Return the identifier of the state machine.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700358 *
Ari Saha89831742015-06-26 10:31:48 -0700359 * @return The state machine identifier.
360 */
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100361 public synchronized byte identifier() {
362 identifier = (identifier + 1) % 255;
363 identifierMap.put(identifier, this);
364 return (byte) identifier;
Ari Saha89831742015-06-26 10:31:48 -0700365 }
366
Ari Saha89831742015-06-26 10:31:48 -0700367 /**
368 * Move to the next state.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700369 *
Ray Milkey78e95a42015-09-24 08:36:45 -0700370 * @param msg message
Ari Saha89831742015-06-26 10:31:48 -0700371 */
Thomas Vachuskae9894202015-07-30 11:59:07 -0700372 private void next(int msg) {
Ari Saha89831742015-06-26 10:31:48 -0700373 currentState = transition[currentState][msg];
374 log.info("Current State " + currentState);
375 }
376
377 /**
378 * Client has requested the start action to allow network access.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700379 *
380 * @throws StateMachineException if authentication protocol is violated
Ari Saha89831742015-06-26 10:31:48 -0700381 */
382 public void start() throws StateMachineException {
Ray Milkey78e95a42015-09-24 08:36:45 -0700383 states[currentState].start();
384 //move to the next state
385 next(TRANSITION_START);
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100386 identifier = this.identifier();
Ari Saha89831742015-06-26 10:31:48 -0700387 }
388
389 /**
390 * An Identification information has been sent by the supplicant.
391 * Move to the next state if possible.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700392 *
393 * @throws StateMachineException if authentication protocol is violated
Ari Saha89831742015-06-26 10:31:48 -0700394 */
395 public void requestAccess() throws StateMachineException {
Ray Milkey78e95a42015-09-24 08:36:45 -0700396 states[currentState].requestAccess();
397 //move to the next state
398 next(TRANSITION_REQUEST_ACCESS);
Ari Saha89831742015-06-26 10:31:48 -0700399 }
400
401 /**
402 * RADIUS has accepted the identification.
403 * Move to the next state if possible.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700404 *
405 * @throws StateMachineException if authentication protocol is violated
Ari Saha89831742015-06-26 10:31:48 -0700406 */
407 public void authorizeAccess() throws StateMachineException {
Ray Milkey78e95a42015-09-24 08:36:45 -0700408 states[currentState].radiusAccepted();
409 //move to the next state
410 next(TRANSITION_AUTHORIZE_ACCESS);
Ari Saha89831742015-06-26 10:31:48 -0700411
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100412 if (accessDeviceService != null) {
413 log.info("Provisioning subscriber at {} with C-TAG {}",
414 supplicantConnectpoint(), ctag);
415 accessDeviceService.provisionSubscriber(supplicantConnectpoint(),
416 ctag);
417 }
Ari Saha89831742015-06-26 10:31:48 -0700418
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100419 // Clear mapping
420 deleteStateMachineMapping(this);
Ari Saha89831742015-06-26 10:31:48 -0700421 }
422
423 /**
424 * RADIUS has denied the identification.
425 * Move to the next state if possible.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700426 *
427 * @throws StateMachineException if authentication protocol is violated
Ari Saha89831742015-06-26 10:31:48 -0700428 */
429 public void denyAccess() throws StateMachineException {
Ray Milkey78e95a42015-09-24 08:36:45 -0700430 states[currentState].radiusDenied();
431 //move to the next state
432 next(TRANSITION_DENY_ACCESS);
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100433 // Clear mappings
434 deleteStateMachineMapping(this);
Ari Saha89831742015-06-26 10:31:48 -0700435 }
436
437 /**
438 * Logoff request has been requested.
439 * Move to the next state if possible.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700440 *
441 * @throws StateMachineException if authentication protocol is violated
Ari Saha89831742015-06-26 10:31:48 -0700442 */
443 public void logoff() throws StateMachineException {
Ray Milkey78e95a42015-09-24 08:36:45 -0700444 states[currentState].logoff();
445 //move to the next state
446 next(TRANSITION_LOGOFF);
Ari Saha89831742015-06-26 10:31:48 -0700447 }
448
449 /**
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700450 * Gets the current state.
Thomas Vachuskae9894202015-07-30 11:59:07 -0700451 *
Ari Saha89831742015-06-26 10:31:48 -0700452 * @return The current state. Could be STATE_IDLE, STATE_STARTED, STATE_PENDING, STATE_AUTHORIZED,
453 * STATE_UNAUTHORIZED.
454 */
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700455 public int state() {
Ari Saha89831742015-06-26 10:31:48 -0700456 return currentState;
457 }
458
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700459 @Override
Ari Saha89831742015-06-26 10:31:48 -0700460 public String toString() {
461 return ("sessionId: " + this.sessionId) + "\t" + ("identifier: " + this.identifier) + "\t" +
462 ("state: " + this.currentState);
463 }
Ari Saha89831742015-06-26 10:31:48 -0700464
Ray Milkey78e95a42015-09-24 08:36:45 -0700465 abstract class State {
466 private final Logger log = getLogger(getClass());
Thomas Vachuskae9894202015-07-30 11:59:07 -0700467
Ray Milkey78e95a42015-09-24 08:36:45 -0700468 private String name = "State";
Ari Saha89831742015-06-26 10:31:48 -0700469
Ray Milkey78e95a42015-09-24 08:36:45 -0700470 public void start() throws StateMachineInvalidTransitionException {
471 log.warn("START transition from this state is not allowed.");
472 }
Ari Saha89831742015-06-26 10:31:48 -0700473
Ray Milkey78e95a42015-09-24 08:36:45 -0700474 public void requestAccess() throws StateMachineInvalidTransitionException {
475 log.warn("REQUEST ACCESS transition from this state is not allowed.");
476 }
477
478 public void radiusAccepted() throws StateMachineInvalidTransitionException {
479 log.warn("AUTHORIZE ACCESS transition from this state is not allowed.");
480 }
481
482 public void radiusDenied() throws StateMachineInvalidTransitionException {
483 log.warn("DENY ACCESS transition from this state is not allowed.");
484 }
485
486 public void logoff() throws StateMachineInvalidTransitionException {
487 log.warn("LOGOFF transition from this state is not allowed.");
488 }
Ari Saha89831742015-06-26 10:31:48 -0700489 }
Thomas Vachuskae9894202015-07-30 11:59:07 -0700490
Ray Milkey78e95a42015-09-24 08:36:45 -0700491 /**
492 * Idle state: supplicant is logged of from the network.
493 */
494 class Idle extends State {
495 private final Logger log = getLogger(getClass());
496 private String name = "IDLE_STATE";
497
498 public void start() {
499 log.info("Moving from IDLE state to STARTED state.");
500 }
Ari Saha89831742015-06-26 10:31:48 -0700501 }
Thomas Vachuskae9894202015-07-30 11:59:07 -0700502
Ray Milkey78e95a42015-09-24 08:36:45 -0700503 /**
504 * Started state: supplicant has entered the network and informed the authenticator.
505 */
506 class Started extends State {
507 private final Logger log = getLogger(getClass());
508 private String name = "STARTED_STATE";
509
510 public void requestAccess() {
511 log.info("Moving from STARTED state to PENDING state.");
512 }
Ari Saha89831742015-06-26 10:31:48 -0700513 }
Thomas Vachuskae9894202015-07-30 11:59:07 -0700514
Ray Milkey78e95a42015-09-24 08:36:45 -0700515 /**
516 * Pending state: supplicant has been identified by the authenticator but has not access yet.
517 */
518 class Pending extends State {
519 private final Logger log = getLogger(getClass());
520 private String name = "PENDING_STATE";
521
522 public void radiusAccepted() {
523 log.info("Moving from PENDING state to AUTHORIZED state.");
524 }
525
526 public void radiusDenied() {
527 log.info("Moving from PENDING state to UNAUTHORIZED state.");
528 }
Ari Saha89831742015-06-26 10:31:48 -0700529 }
Thomas Vachuskae9894202015-07-30 11:59:07 -0700530
Ray Milkey78e95a42015-09-24 08:36:45 -0700531 /**
532 * Authorized state: supplicant port has been accepted, access is granted.
533 */
534 class Authorized extends State {
535 private final Logger log = getLogger(getClass());
536 private String name = "AUTHORIZED_STATE";
Ari Saha89831742015-06-26 10:31:48 -0700537
Qianqian Hu0c349812016-02-15 17:25:22 +0800538 public void start() {
539 log.info("Moving from AUTHORIZED state to STARTED state.");
540 }
541
Ray Milkey78e95a42015-09-24 08:36:45 -0700542 public void logoff() {
Ari Saha89831742015-06-26 10:31:48 -0700543
Ray Milkey78e95a42015-09-24 08:36:45 -0700544 log.info("Moving from AUTHORIZED state to IDLE state.");
545 }
Ari Saha89831742015-06-26 10:31:48 -0700546 }
547
Ray Milkey78e95a42015-09-24 08:36:45 -0700548 /**
549 * Unauthorized state: supplicant port has been rejected, access is denied.
550 */
551 class Unauthorized extends State {
552 private final Logger log = getLogger(getClass());
553 private String name = "UNAUTHORIZED_STATE";
554
ke han04e47f32016-10-28 14:15:43 +0800555 public void start() {
556 log.info("Moving from UNAUTHORIZED state to STARTED state.");
557 }
558
Ray Milkey78e95a42015-09-24 08:36:45 -0700559 public void logoff() {
560 log.info("Moving from UNAUTHORIZED state to IDLE state.");
561 }
Ari Saha89831742015-06-26 10:31:48 -0700562 }
Ari Saha89831742015-06-26 10:31:48 -0700563
564
Ari Saha89831742015-06-26 10:31:48 -0700565}