blob: 379419dfad15e094e0eeb6ac4c1db96eb1090448 [file] [log] [blame]
Simon Hunt439d6d82017-10-31 14:55:09 -07001/*
2 * Copyright 2017-present Open Networking Foundation
3 *
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 */
16package org.opencord.aaa.api;
17
18import org.onlab.packet.MacAddress;
19import org.onlab.packet.VlanId;
20import org.onosproject.net.ConnectPoint;
21import org.onosproject.net.DeviceId;
22import org.onosproject.net.PortNumber;
23
24/**
25 * Represents an AAA authentication session.
26 */
27public final class AaaSession {
28 // This defines supplicant device and port
29 private final ConnectPoint supplicantConnectPoint;
30
31 // User name associated with this session
32 private final String username;
33
34 // MAC associated with this session
35 private final MacAddress supplicantMacAddress;
36
37 // TODO: Review why isn't vlanId of type VlanId ??
38 // VLAN from the EAP eth packet
39 private final short vlanId;
40
41 // VLAN from subscriber info : C-Tag
42 private final VlanId ctag;
43
44 // Current authentication state of this session
45 private final AaaAuthState state;
46
47 /**
48 * Constructs an immutable AAA session description.
49 *
50 * @param supplicantConnectPoint the supplicant connect point
51 * @param username the associated user name
52 * @param supplicantMacAddress the associated mac address
53 * @param vlanId the VLAN ID
54 * @param ctag the C-TAG VLAN ID
55 * @param state the current authentication state
56 */
57 public AaaSession(ConnectPoint supplicantConnectPoint, String username,
58 MacAddress supplicantMacAddress, short vlanId, VlanId ctag,
59 AaaAuthState state) {
60 this.supplicantConnectPoint = supplicantConnectPoint;
61 this.username = username;
62 this.supplicantMacAddress = supplicantMacAddress;
63 this.vlanId = vlanId;
64 this.ctag = ctag;
65 this.state = state;
66 }
67
68 /**
69 * The supplicant connect point.
70 *
71 * @return the connect point
72 */
73 public ConnectPoint getConnectPoint() {
74 return supplicantConnectPoint;
75 }
76
77 /**
78 * The device identifier of the supplicant connect point.
79 *
80 * @return the device identifier
81 */
82 public DeviceId deviceId() {
83 return supplicantConnectPoint.deviceId();
84 }
85
86 /**
87 * The port number of the supplicant connect point.
88 *
89 * @return the port number
90 */
91 public PortNumber portNumber() {
92 return supplicantConnectPoint.port();
93 }
94
95 /**
96 * The user name of the supplicant.
97 *
98 * @return the user name
99 */
100 public String username() {
101 return username;
102 }
103
104 /**
105 * The MAC address of the supplicant.
106 *
107 * @return the MAC address
108 */
109 public MacAddress macAddress() {
110 return supplicantMacAddress;
111 }
112
113 // TODO: Review this description of vlanId for correctness
114
115 /**
116 * The VLAN identifier for the supplicant connection.
117 *
118 * @return the VLAN ID
119 */
120 public short vlanId() {
121 return vlanId;
122 }
123
124 // TODO: Review - does this make sense in the general (other-than-VOLTHA) case?
125
126 /**
127 * The C-TAG associated with this supplicant's session.
128 *
129 * @return the C-TAG VLAN ID
130 */
131 public VlanId cTag() {
132 return ctag;
133 }
134
135 /**
136 * The current state of this session.
137 *
138 * @return the session state
139 */
140 public AaaAuthState state() {
141 return state;
142 }
143}