Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 1 | /* |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 2 | * Copyright 2017-present Open Networking Foundation |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 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 | */ |
Matteo Scandolo | cf847b8 | 2019-04-26 15:00:00 -0700 | [diff] [blame] | 16 | package org.opencord.aaa.impl; |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 17 | |
Shubham Sharma | 4900ce6 | 2019-06-19 14:18:50 +0000 | [diff] [blame] | 18 | import com.google.common.base.Strings; |
Jonathan Hart | 612651f | 2019-11-25 09:21:43 -0800 | [diff] [blame] | 19 | import com.google.common.collect.Maps; |
Matteo Scandolo | 9510e5d | 2020-09-24 17:31:52 -0700 | [diff] [blame] | 20 | |
Andrea Campanella | c4781e6 | 2020-10-08 12:58:45 +0200 | [diff] [blame] | 21 | import static java.util.concurrent.Executors.newSingleThreadExecutor; |
Matteo Scandolo | 9510e5d | 2020-09-24 17:31:52 -0700 | [diff] [blame] | 22 | import static org.onlab.util.Tools.groupedThreads; |
Girish Kumar | 064084c | 2020-02-04 08:32:46 +0000 | [diff] [blame] | 23 | import static org.onosproject.net.config.basics.SubjectFactories.APP_SUBJECT_FACTORY; |
Matteo Scandolo | 9510e5d | 2020-09-24 17:31:52 -0700 | [diff] [blame] | 24 | import static org.opencord.aaa.impl.OsgiPropertyConstants.*; |
Girish Kumar | 064084c | 2020-02-04 08:32:46 +0000 | [diff] [blame] | 25 | import static org.slf4j.LoggerFactory.getLogger; |
| 26 | |
| 27 | import com.google.common.collect.Sets; |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 28 | |
Girish Kumar | 064084c | 2020-02-04 08:32:46 +0000 | [diff] [blame] | 29 | import java.net.InetAddress; |
| 30 | import java.net.UnknownHostException; |
| 31 | import java.nio.ByteBuffer; |
| 32 | import java.util.Dictionary; |
| 33 | import java.util.HashSet; |
| 34 | import java.util.Arrays; |
| 35 | import java.util.List; |
Hardik Windlass | d0b4969 | 2020-02-26 18:17:14 +0000 | [diff] [blame] | 36 | import java.util.Map; |
Girish Kumar | 064084c | 2020-02-04 08:32:46 +0000 | [diff] [blame] | 37 | import java.util.Set; |
| 38 | import java.util.Map.Entry; |
| 39 | |
Jonathan Hart | 932bedc | 2018-07-12 13:46:09 -0700 | [diff] [blame] | 40 | import org.apache.commons.lang3.builder.ToStringBuilder; |
Jonathan Hart | 4731dd9 | 2018-05-02 17:30:05 -0700 | [diff] [blame] | 41 | import org.onlab.packet.DeserializationException; |
Jonathan Hart | a46dddf | 2015-06-30 15:31:20 -0700 | [diff] [blame] | 42 | import org.onlab.packet.EAP; |
| 43 | import org.onlab.packet.EAPOL; |
| 44 | import org.onlab.packet.EthType; |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 45 | import org.onlab.packet.Ethernet; |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 46 | import org.onlab.packet.MacAddress; |
Jonathan Hart | a46dddf | 2015-06-30 15:31:20 -0700 | [diff] [blame] | 47 | import org.onlab.packet.RADIUS; |
| 48 | import org.onlab.packet.RADIUSAttribute; |
Jonathan Hart | 9d1ce80 | 2020-01-28 10:45:08 -0800 | [diff] [blame] | 49 | import org.onlab.util.KryoNamespace; |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 50 | import org.onlab.util.Tools; |
| 51 | import org.onosproject.cfg.ComponentConfigService; |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 52 | import org.onosproject.core.ApplicationId; |
| 53 | import org.onosproject.core.CoreService; |
Jonathan Hart | 5db4453 | 2018-07-12 18:13:54 -0700 | [diff] [blame] | 54 | import org.onosproject.event.AbstractListenerManager; |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 55 | import org.onosproject.mastership.MastershipService; |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 56 | import org.onosproject.net.ConnectPoint; |
| 57 | import org.onosproject.net.DeviceId; |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 58 | import org.onosproject.net.PortNumber; |
Ray Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 59 | import org.onosproject.net.config.ConfigFactory; |
| 60 | import org.onosproject.net.config.NetworkConfigEvent; |
| 61 | import org.onosproject.net.config.NetworkConfigListener; |
| 62 | import org.onosproject.net.config.NetworkConfigRegistry; |
Amit Ghosh | f739be5 | 2017-09-21 15:49:37 +0100 | [diff] [blame] | 63 | import org.onosproject.net.device.DeviceEvent; |
| 64 | import org.onosproject.net.device.DeviceListener; |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 65 | import org.onosproject.net.device.DeviceService; |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 66 | import org.onosproject.net.flow.DefaultTrafficTreatment; |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 67 | import org.onosproject.net.flow.TrafficTreatment; |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 68 | import org.onosproject.net.packet.DefaultOutboundPacket; |
| 69 | import org.onosproject.net.packet.InboundPacket; |
| 70 | import org.onosproject.net.packet.OutboundPacket; |
| 71 | import org.onosproject.net.packet.PacketContext; |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 72 | import org.onosproject.net.packet.PacketProcessor; |
| 73 | import org.onosproject.net.packet.PacketService; |
Jonathan Hart | c41227c | 2020-01-28 16:56:49 -0800 | [diff] [blame] | 74 | import org.onosproject.store.serializers.KryoNamespaces; |
Jonathan Hart | 9d1ce80 | 2020-01-28 10:45:08 -0800 | [diff] [blame] | 75 | import org.onosproject.store.service.ConsistentMap; |
| 76 | import org.onosproject.store.service.MapEvent; |
| 77 | import org.onosproject.store.service.MapEventListener; |
| 78 | import org.onosproject.store.service.Serializer; |
| 79 | import org.onosproject.store.service.StorageService; |
Matteo Scandolo | cf847b8 | 2019-04-26 15:00:00 -0700 | [diff] [blame] | 80 | import org.opencord.aaa.AaaConfig; |
Kartikey Dubey | adeb26e | 2019-10-01 12:18:35 +0000 | [diff] [blame] | 81 | import org.opencord.aaa.AaaMachineStatisticsEvent; |
| 82 | import org.opencord.aaa.AaaMachineStatisticsService; |
| 83 | import org.opencord.aaa.AaaSupplicantMachineStats; |
Matteo Scandolo | cf847b8 | 2019-04-26 15:00:00 -0700 | [diff] [blame] | 84 | import org.opencord.aaa.AuthenticationEvent; |
| 85 | import org.opencord.aaa.AuthenticationEventListener; |
Jonathan Hart | 612651f | 2019-11-25 09:21:43 -0800 | [diff] [blame] | 86 | import org.opencord.aaa.AuthenticationRecord; |
Matteo Scandolo | cf847b8 | 2019-04-26 15:00:00 -0700 | [diff] [blame] | 87 | import org.opencord.aaa.AuthenticationService; |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 88 | import org.opencord.aaa.AuthenticationStatisticsService; |
Matteo Scandolo | cf847b8 | 2019-04-26 15:00:00 -0700 | [diff] [blame] | 89 | import org.opencord.aaa.RadiusCommunicator; |
Shubham Sharma | 4900ce6 | 2019-06-19 14:18:50 +0000 | [diff] [blame] | 90 | import org.opencord.aaa.RadiusOperationalStatusEvent; |
| 91 | import org.opencord.aaa.RadiusOperationalStatusService; |
| 92 | import org.opencord.aaa.RadiusOperationalStatusService.RadiusOperationalStatusEvaluationMode; |
Matteo Scandolo | cf847b8 | 2019-04-26 15:00:00 -0700 | [diff] [blame] | 93 | import org.opencord.aaa.StateMachineDelegate; |
Gamze Abaka | 1cfdb19 | 2018-10-25 11:39:19 +0000 | [diff] [blame] | 94 | import org.opencord.sadis.BaseInformationService; |
| 95 | import org.opencord.sadis.SadisService; |
| 96 | import org.opencord.sadis.SubscriberAndDeviceInformation; |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 97 | import org.osgi.service.component.ComponentContext; |
Carmelo Cascone | 58b5329 | 2019-09-30 12:35:31 -0700 | [diff] [blame] | 98 | import org.osgi.service.component.annotations.Activate; |
Shubham Sharma | 4900ce6 | 2019-06-19 14:18:50 +0000 | [diff] [blame] | 99 | import org.osgi.service.component.annotations.Component; |
| 100 | import org.osgi.service.component.annotations.Deactivate; |
| 101 | import org.osgi.service.component.annotations.Modified; |
| 102 | import org.osgi.service.component.annotations.Reference; |
| 103 | import org.osgi.service.component.annotations.ReferenceCardinality; |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 104 | import org.slf4j.Logger; |
| 105 | |
Shubham Sharma | 4900ce6 | 2019-06-19 14:18:50 +0000 | [diff] [blame] | 106 | import javax.crypto.Mac; |
| 107 | import javax.crypto.spec.SecretKeySpec; |
Jonathan Hart | 9d1ce80 | 2020-01-28 10:45:08 -0800 | [diff] [blame] | 108 | import java.util.Optional; |
Jonathan Hart | 612651f | 2019-11-25 09:21:43 -0800 | [diff] [blame] | 109 | import java.util.concurrent.ConcurrentMap; |
Matteo Scandolo | 9510e5d | 2020-09-24 17:31:52 -0700 | [diff] [blame] | 110 | import java.util.concurrent.ExecutorService; |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 111 | import java.util.concurrent.Executors; |
| 112 | import java.util.concurrent.ScheduledExecutorService; |
| 113 | import java.util.concurrent.ScheduledFuture; |
| 114 | import java.util.concurrent.TimeUnit; |
Vijaykumar Kushwaha | 056e4cd | 2019-08-06 13:16:25 +0000 | [diff] [blame] | 115 | |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 116 | /** |
Jonathan Hart | a46dddf | 2015-06-30 15:31:20 -0700 | [diff] [blame] | 117 | * AAA application for ONOS. |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 118 | */ |
Carmelo Cascone | 58b5329 | 2019-09-30 12:35:31 -0700 | [diff] [blame] | 119 | @Component(immediate = true, property = { |
Shubham Sharma | 4900ce6 | 2019-06-19 14:18:50 +0000 | [diff] [blame] | 120 | OPERATIONAL_STATUS_SERVER_EVENT_GENERATION + ":Integer=" + OPERATIONAL_STATUS_SERVER_EVENT_GENERATION_DEFAULT, |
| 121 | OPERATIONAL_STATUS_SERVER_TIMEOUT + ":Integer=" + OPERATIONAL_STATUS_SERVER_TIMEOUT_DEFAULT, |
| 122 | STATUS_SERVER_MODE + ":String=" + STATUS_SERVER_MODE_DEFAULT, |
Matteo Scandolo | 9510e5d | 2020-09-24 17:31:52 -0700 | [diff] [blame] | 123 | PACKET_PROCESSOR_THREADS + ":Integer=" + PACKET_PROCESSOR_THREADS_DEFAULT, |
Carmelo Cascone | 58b5329 | 2019-09-30 12:35:31 -0700 | [diff] [blame] | 124 | }) |
Jonathan Hart | 5db4453 | 2018-07-12 18:13:54 -0700 | [diff] [blame] | 125 | public class AaaManager |
| 126 | extends AbstractListenerManager<AuthenticationEvent, AuthenticationEventListener> |
| 127 | implements AuthenticationService { |
| 128 | |
Charles Chan | df7ff86 | 2017-01-20 11:22:05 -0800 | [diff] [blame] | 129 | private static final String APP_NAME = "org.opencord.aaa"; |
Matteo Scandolo | 9510e5d | 2020-09-24 17:31:52 -0700 | [diff] [blame] | 130 | private static final int STATE_MACHINE_THREADS = 3; |
Ray Milkey | f51eba2 | 2015-09-25 10:24:23 -0700 | [diff] [blame] | 131 | |
Ray Milkey | f61a24e | 2015-09-24 16:34:02 -0700 | [diff] [blame] | 132 | private final Logger log = getLogger(getClass()); |
Ray Milkey | f51eba2 | 2015-09-25 10:24:23 -0700 | [diff] [blame] | 133 | |
Carmelo Cascone | 58b5329 | 2019-09-30 12:35:31 -0700 | [diff] [blame] | 134 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
Ray Milkey | f61a24e | 2015-09-24 16:34:02 -0700 | [diff] [blame] | 135 | protected CoreService coreService; |
Ray Milkey | f51eba2 | 2015-09-25 10:24:23 -0700 | [diff] [blame] | 136 | |
Carmelo Cascone | 58b5329 | 2019-09-30 12:35:31 -0700 | [diff] [blame] | 137 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
Jonathan Hart | 9d1ce80 | 2020-01-28 10:45:08 -0800 | [diff] [blame] | 138 | protected StorageService storageService; |
| 139 | |
| 140 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
Ray Milkey | f61a24e | 2015-09-24 16:34:02 -0700 | [diff] [blame] | 141 | protected PacketService packetService; |
Ray Milkey | f51eba2 | 2015-09-25 10:24:23 -0700 | [diff] [blame] | 142 | |
Carmelo Cascone | 58b5329 | 2019-09-30 12:35:31 -0700 | [diff] [blame] | 143 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
Ray Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 144 | protected NetworkConfigRegistry netCfgService; |
Ray Milkey | f51eba2 | 2015-09-25 10:24:23 -0700 | [diff] [blame] | 145 | |
Carmelo Cascone | 58b5329 | 2019-09-30 12:35:31 -0700 | [diff] [blame] | 146 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 147 | protected DeviceService deviceService; |
| 148 | |
Carmelo Cascone | 58b5329 | 2019-09-30 12:35:31 -0700 | [diff] [blame] | 149 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
Gamze Abaka | 1cfdb19 | 2018-10-25 11:39:19 +0000 | [diff] [blame] | 150 | protected SadisService sadisService; |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 151 | |
Carmelo Cascone | 58b5329 | 2019-09-30 12:35:31 -0700 | [diff] [blame] | 152 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 153 | protected MastershipService mastershipService; |
| 154 | |
Carmelo Cascone | 58b5329 | 2019-09-30 12:35:31 -0700 | [diff] [blame] | 155 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 156 | protected AuthenticationStatisticsService aaaStatisticsManager; |
Gamze Abaka | 1cfdb19 | 2018-10-25 11:39:19 +0000 | [diff] [blame] | 157 | |
Carmelo Cascone | 58b5329 | 2019-09-30 12:35:31 -0700 | [diff] [blame] | 158 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
Kartikey Dubey | adeb26e | 2019-10-01 12:18:35 +0000 | [diff] [blame] | 159 | protected AaaMachineStatisticsService aaaSupplicantStatsManager; |
| 160 | |
| 161 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 162 | protected ComponentConfigService cfgService; |
| 163 | |
Shubham Sharma | 4900ce6 | 2019-06-19 14:18:50 +0000 | [diff] [blame] | 164 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
| 165 | protected RadiusOperationalStatusService radiusOperationalStatusService; |
| 166 | |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 167 | protected BaseInformationService<SubscriberAndDeviceInformation> subsService; |
Amit Ghosh | f739be5 | 2017-09-21 15:49:37 +0100 | [diff] [blame] | 168 | private final DeviceListener deviceListener = new InternalDeviceListener(); |
| 169 | |
Shubham Sharma | 4900ce6 | 2019-06-19 14:18:50 +0000 | [diff] [blame] | 170 | // Properties |
Shubham Sharma | 4900ce6 | 2019-06-19 14:18:50 +0000 | [diff] [blame] | 171 | private int operationalStatusEventGenerationPeriodInSeconds = OPERATIONAL_STATUS_SERVER_EVENT_GENERATION_DEFAULT; |
| 172 | private int operationalStatusServerTimeoutInSeconds = OPERATIONAL_STATUS_SERVER_TIMEOUT_DEFAULT; |
| 173 | protected String operationalStatusEvaluationMode = STATUS_SERVER_MODE_DEFAULT; |
Matteo Scandolo | 9510e5d | 2020-09-24 17:31:52 -0700 | [diff] [blame] | 174 | /** |
| 175 | * Number of threads used to process the packet. |
| 176 | */ |
| 177 | protected int packetProcessorThreads = PACKET_PROCESSOR_THREADS_DEFAULT; |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 178 | |
Jonathan Hart | 612651f | 2019-11-25 09:21:43 -0800 | [diff] [blame] | 179 | private IdentifierManager idManager; |
| 180 | |
| 181 | private ConcurrentMap<String, StateMachine> stateMachines; |
| 182 | |
Hardik Windlass | d0b4969 | 2020-02-26 18:17:14 +0000 | [diff] [blame] | 183 | private ConsistentMap<ConnectPoint, AuthenticationRecord> authenticationsConsistentMap; |
| 184 | private Map<ConnectPoint, AuthenticationRecord> authentications; |
Jonathan Hart | 9d1ce80 | 2020-01-28 10:45:08 -0800 | [diff] [blame] | 185 | |
Ray Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 186 | // NAS IP address |
| 187 | protected InetAddress nasIpAddress; |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 188 | |
| 189 | // self MAC address |
Jonathan Hart | 5db4453 | 2018-07-12 18:13:54 -0700 | [diff] [blame] | 190 | protected String nasMacAddress; |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 191 | |
| 192 | // Parsed RADIUS server addresses |
| 193 | protected InetAddress radiusIpAddress; |
| 194 | |
| 195 | // MAC address of RADIUS server or net hop router |
| 196 | protected String radiusMacAddress; |
Ray Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 197 | |
| 198 | // RADIUS server secret |
| 199 | protected String radiusSecret; |
| 200 | |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 201 | // bindings |
| 202 | protected CustomizationInfo customInfo; |
Ray Milkey | 5d99bd1 | 2015-10-06 15:41:30 -0700 | [diff] [blame] | 203 | |
Ray Milkey | f61a24e | 2015-09-24 16:34:02 -0700 | [diff] [blame] | 204 | // our application-specific event handler |
| 205 | private ReactivePacketProcessor processor = new ReactivePacketProcessor(); |
Ray Milkey | f51eba2 | 2015-09-25 10:24:23 -0700 | [diff] [blame] | 206 | |
Ray Milkey | f61a24e | 2015-09-24 16:34:02 -0700 | [diff] [blame] | 207 | // our unique identifier |
| 208 | private ApplicationId appId; |
Ray Milkey | f51eba2 | 2015-09-25 10:24:23 -0700 | [diff] [blame] | 209 | |
Shubham Sharma | 1e43c56 | 2019-06-19 14:18:12 +0000 | [diff] [blame] | 210 | // TimeOut time for cleaning up stateMachines stuck due to pending AAA/EAPOL message. |
| 211 | protected int cleanupTimerTimeOutInMins; |
| 212 | |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 213 | // Setup specific customization/attributes on the RADIUS packets |
| 214 | PacketCustomizer pktCustomizer; |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 215 | |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 216 | // packet customizer to use |
| 217 | private String customizer; |
| 218 | |
| 219 | // Type of connection to use to communicate with Radius server, options are |
| 220 | // "socket" or "packet_out" |
| 221 | private String radiusConnectionType; |
| 222 | |
Jonathan Hart | 5db4453 | 2018-07-12 18:13:54 -0700 | [diff] [blame] | 223 | // Object for the specific type of communication with the RADIUS |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 224 | // server, socket based or packet_out based |
| 225 | RadiusCommunicator impl = null; |
| 226 | |
| 227 | // latest configuration |
| 228 | AaaConfig newCfg; |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 229 | |
Shubham Sharma | 4900ce6 | 2019-06-19 14:18:50 +0000 | [diff] [blame] | 230 | ScheduledFuture<?> scheduledStatusServerChecker; |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 231 | String configuredAaaServerAddress; |
Jonathan Hart | c41227c | 2020-01-28 16:56:49 -0800 | [diff] [blame] | 232 | HashSet<Byte> outPacketSet = new HashSet<>(); |
| 233 | HashSet<Byte> outPacketSupp = new HashSet<>(); |
Shubham Sharma | 3c8c702 | 2019-09-13 10:39:47 +0000 | [diff] [blame] | 234 | static final List<Byte> VALID_EAPOL_TYPE = Arrays.asList(EAPOL.EAPOL_START, EAPOL.EAPOL_LOGOFF, EAPOL.EAPOL_PACKET); |
| 235 | static final int HEADER_LENGTH = 4; |
Ray Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 236 | // Configuration properties factory |
| 237 | private final ConfigFactory factory = |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 238 | new ConfigFactory<ApplicationId, AaaConfig>(APP_SUBJECT_FACTORY, |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 239 | AaaConfig.class, |
| 240 | "AAA") { |
Ray Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 241 | @Override |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 242 | public AaaConfig createConfig() { |
| 243 | return new AaaConfig(); |
Ray Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 244 | } |
| 245 | }; |
Ray Milkey | f51eba2 | 2015-09-25 10:24:23 -0700 | [diff] [blame] | 246 | |
Ray Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 247 | // Listener for config changes |
| 248 | private final InternalConfigListener cfgListener = new InternalConfigListener(); |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 249 | |
Jonathan Hart | 9d1ce80 | 2020-01-28 10:45:08 -0800 | [diff] [blame] | 250 | private final InternalMapEventListener mapListener = new InternalMapEventListener(); |
| 251 | |
Jonathan Hart | 5db4453 | 2018-07-12 18:13:54 -0700 | [diff] [blame] | 252 | private StateMachineDelegate delegate = new InternalStateMachineDelegate(); |
| 253 | |
Matteo Scandolo | 9510e5d | 2020-09-24 17:31:52 -0700 | [diff] [blame] | 254 | protected ExecutorService packetProcessorExecutor; |
| 255 | protected ScheduledExecutorService serverStatusAndStateMachineTimeoutExecutor; |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 256 | |
Ray Milkey | f61a24e | 2015-09-24 16:34:02 -0700 | [diff] [blame] | 257 | /** |
| 258 | * Builds an EAPOL packet based on the given parameters. |
| 259 | * |
| 260 | * @param dstMac destination MAC address |
| 261 | * @param srcMac source MAC address |
| 262 | * @param vlan vlan identifier |
| 263 | * @param eapolType EAPOL type |
| 264 | * @param eap EAP payload |
| 265 | * @return Ethernet frame |
| 266 | */ |
| 267 | private static Ethernet buildEapolResponse(MacAddress dstMac, MacAddress srcMac, |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 268 | short vlan, byte eapolType, EAP eap, byte priorityCode) { |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 269 | |
Ray Milkey | f61a24e | 2015-09-24 16:34:02 -0700 | [diff] [blame] | 270 | Ethernet eth = new Ethernet(); |
| 271 | eth.setDestinationMACAddress(dstMac.toBytes()); |
| 272 | eth.setSourceMACAddress(srcMac.toBytes()); |
| 273 | eth.setEtherType(EthType.EtherType.EAPOL.ethType().toShort()); |
| 274 | if (vlan != Ethernet.VLAN_UNTAGGED) { |
| 275 | eth.setVlanID(vlan); |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 276 | eth.setPriorityCode(priorityCode); |
Ray Milkey | f61a24e | 2015-09-24 16:34:02 -0700 | [diff] [blame] | 277 | } |
| 278 | //eapol header |
| 279 | EAPOL eapol = new EAPOL(); |
| 280 | eapol.setEapolType(eapolType); |
| 281 | eapol.setPacketLength(eap.getLength()); |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 282 | |
Ray Milkey | f61a24e | 2015-09-24 16:34:02 -0700 | [diff] [blame] | 283 | //eap part |
| 284 | eapol.setPayload(eap); |
| 285 | |
| 286 | eth.setPayload(eapol); |
| 287 | eth.setPad(true); |
| 288 | return eth; |
| 289 | } |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 290 | |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 291 | @Activate |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 292 | public void activate(ComponentContext context) { |
Matteo Scandolo | 9510e5d | 2020-09-24 17:31:52 -0700 | [diff] [blame] | 293 | |
Jonathan Hart | 612651f | 2019-11-25 09:21:43 -0800 | [diff] [blame] | 294 | idManager = new IdentifierManager(); |
| 295 | stateMachines = Maps.newConcurrentMap(); |
Charles Chan | df7ff86 | 2017-01-20 11:22:05 -0800 | [diff] [blame] | 296 | appId = coreService.registerApplication(APP_NAME); |
Jonathan Hart | 9d1ce80 | 2020-01-28 10:45:08 -0800 | [diff] [blame] | 297 | |
| 298 | KryoNamespace authSerializer = KryoNamespace.newBuilder() |
Jonathan Hart | c41227c | 2020-01-28 16:56:49 -0800 | [diff] [blame] | 299 | .register(KryoNamespaces.API) |
Jonathan Hart | 9d1ce80 | 2020-01-28 10:45:08 -0800 | [diff] [blame] | 300 | .register(AuthenticationRecord.class) |
| 301 | .build(); |
| 302 | |
Hardik Windlass | d0b4969 | 2020-02-26 18:17:14 +0000 | [diff] [blame] | 303 | authenticationsConsistentMap = storageService.<ConnectPoint, AuthenticationRecord>consistentMapBuilder() |
Jonathan Hart | 9d1ce80 | 2020-01-28 10:45:08 -0800 | [diff] [blame] | 304 | .withApplicationId(appId) |
| 305 | .withName("authentications") |
| 306 | .withSerializer(Serializer.using(authSerializer)) |
| 307 | .build(); |
Hardik Windlass | d0b4969 | 2020-02-26 18:17:14 +0000 | [diff] [blame] | 308 | authenticationsConsistentMap.addListener(mapListener); |
| 309 | authentications = authenticationsConsistentMap.asJavaMap(); |
Jonathan Hart | 9d1ce80 | 2020-01-28 10:45:08 -0800 | [diff] [blame] | 310 | |
Jonathan Hart | 5db4453 | 2018-07-12 18:13:54 -0700 | [diff] [blame] | 311 | eventDispatcher.addSink(AuthenticationEvent.class, listenerRegistry); |
Matt Jeanneret | 2ff1a78 | 2018-06-13 15:24:25 -0400 | [diff] [blame] | 312 | netCfgService.addListener(cfgListener); |
| 313 | netCfgService.registerConfigFactory(factory); |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 314 | cfgService.registerProperties(getClass()); |
| 315 | modified(context); |
Gamze Abaka | 1cfdb19 | 2018-10-25 11:39:19 +0000 | [diff] [blame] | 316 | subsService = sadisService.getSubscriberInfoService(); |
Deepa Vaddireddy | e0e1072 | 2017-09-27 05:00:10 +0530 | [diff] [blame] | 317 | customInfo = new CustomizationInfo(subsService, deviceService); |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 318 | cfgListener.reconfigureNetwork(netCfgService.getConfig(appId, AaaConfig.class)); |
Matt Jeanneret | 2ff1a78 | 2018-06-13 15:24:25 -0400 | [diff] [blame] | 319 | log.info("Starting with config {} {}", this, newCfg); |
Deepa Vaddireddy | e0e1072 | 2017-09-27 05:00:10 +0530 | [diff] [blame] | 320 | configureRadiusCommunication(); |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 321 | // register our event handler |
Brian O'Connor | d9c7da0 | 2015-07-29 17:49:24 -0700 | [diff] [blame] | 322 | packetService.addProcessor(processor, PacketProcessor.director(2)); |
Jonathan Hart | 5db4453 | 2018-07-12 18:13:54 -0700 | [diff] [blame] | 323 | StateMachine.setDelegate(delegate); |
Shubham Sharma | 1e43c56 | 2019-06-19 14:18:12 +0000 | [diff] [blame] | 324 | cleanupTimerTimeOutInMins = newCfg.sessionCleanupTimer(); |
| 325 | StateMachine.setcleanupTimerTimeOutInMins(cleanupTimerTimeOutInMins); |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 326 | impl.initializeLocalState(newCfg); |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 327 | impl.requestIntercepts(); |
Amit Ghosh | f739be5 | 2017-09-21 15:49:37 +0100 | [diff] [blame] | 328 | deviceService.addListener(deviceListener); |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 329 | getConfiguredAaaServerAddress(); |
Shubham Sharma | 4900ce6 | 2019-06-19 14:18:50 +0000 | [diff] [blame] | 330 | radiusOperationalStatusService.initialize(nasIpAddress.getAddress(), radiusSecret, impl); |
Matteo Scandolo | 9510e5d | 2020-09-24 17:31:52 -0700 | [diff] [blame] | 331 | serverStatusAndStateMachineTimeoutExecutor = Executors.newScheduledThreadPool(STATE_MACHINE_THREADS, |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 332 | groupedThreads("onos/aaa", "aaa-machine-%d", log)); |
Shubham Sharma | 4900ce6 | 2019-06-19 14:18:50 +0000 | [diff] [blame] | 333 | |
Matteo Scandolo | 9510e5d | 2020-09-24 17:31:52 -0700 | [diff] [blame] | 334 | scheduledStatusServerChecker = serverStatusAndStateMachineTimeoutExecutor.scheduleAtFixedRate( |
| 335 | new ServerStatusChecker(), 0, |
| 336 | operationalStatusEventGenerationPeriodInSeconds, TimeUnit.SECONDS); |
Amit Ghosh | f739be5 | 2017-09-21 15:49:37 +0100 | [diff] [blame] | 337 | |
Jian Li | 13c6716 | 2015-12-09 13:20:34 -0800 | [diff] [blame] | 338 | log.info("Started"); |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 339 | } |
| 340 | |
| 341 | @Deactivate |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 342 | public void deactivate(ComponentContext context) { |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 343 | impl.withdrawIntercepts(); |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 344 | packetService.removeProcessor(processor); |
Deepa Vaddireddy | b9c24c6 | 2017-09-21 13:45:30 +0530 | [diff] [blame] | 345 | netCfgService.removeListener(cfgListener); |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 346 | cfgService.unregisterProperties(getClass(), false); |
Jonathan Hart | 5db4453 | 2018-07-12 18:13:54 -0700 | [diff] [blame] | 347 | StateMachine.unsetDelegate(delegate); |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 348 | impl.deactivate(); |
Amit Ghosh | f739be5 | 2017-09-21 15:49:37 +0100 | [diff] [blame] | 349 | deviceService.removeListener(deviceListener); |
Jonathan Hart | 5db4453 | 2018-07-12 18:13:54 -0700 | [diff] [blame] | 350 | eventDispatcher.removeSink(AuthenticationEvent.class); |
Shubham Sharma | 4900ce6 | 2019-06-19 14:18:50 +0000 | [diff] [blame] | 351 | scheduledStatusServerChecker.cancel(true); |
Matteo Scandolo | 9510e5d | 2020-09-24 17:31:52 -0700 | [diff] [blame] | 352 | serverStatusAndStateMachineTimeoutExecutor.shutdown(); |
| 353 | packetProcessorExecutor.shutdown(); |
Hardik Windlass | d0b4969 | 2020-02-26 18:17:14 +0000 | [diff] [blame] | 354 | authenticationsConsistentMap.removeListener(mapListener); |
Jonathan Hart | 9d1ce80 | 2020-01-28 10:45:08 -0800 | [diff] [blame] | 355 | |
Jian Li | 13c6716 | 2015-12-09 13:20:34 -0800 | [diff] [blame] | 356 | log.info("Stopped"); |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 357 | } |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 358 | |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 359 | @Modified |
| 360 | public void modified(ComponentContext context) { |
Shubham Sharma | 4900ce6 | 2019-06-19 14:18:50 +0000 | [diff] [blame] | 361 | Dictionary<String, Object> properties = context.getProperties(); |
| 362 | |
Jonathan Hart | c41227c | 2020-01-28 16:56:49 -0800 | [diff] [blame] | 363 | String s = Tools.get(properties, "operationalStatusEventGenerationPeriodInSeconds"); |
Shubham Sharma | 4900ce6 | 2019-06-19 14:18:50 +0000 | [diff] [blame] | 364 | operationalStatusEventGenerationPeriodInSeconds = Strings.isNullOrEmpty(s) |
| 365 | ? OPERATIONAL_STATUS_SERVER_EVENT_GENERATION_DEFAULT |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 366 | : Integer.parseInt(s.trim()); |
Shubham Sharma | 4900ce6 | 2019-06-19 14:18:50 +0000 | [diff] [blame] | 367 | |
| 368 | s = Tools.get(properties, "operationalStatusServerTimeoutInSeconds"); |
| 369 | operationalStatusServerTimeoutInSeconds = Strings.isNullOrEmpty(s) ? OPERATIONAL_STATUS_SERVER_TIMEOUT_DEFAULT |
| 370 | : Integer.parseInt(s.trim()); |
| 371 | |
| 372 | s = Tools.get(properties, "operationalStatusEvaluationMode"); |
| 373 | String newEvaluationModeString = Strings.isNullOrEmpty(s) ? STATUS_SERVER_MODE_DEFAULT : s.trim(); |
| 374 | |
| 375 | radiusOperationalStatusService |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 376 | .setOperationalStatusServerTimeoutInMillis(operationalStatusServerTimeoutInSeconds * 1000); |
Shubham Sharma | 4900ce6 | 2019-06-19 14:18:50 +0000 | [diff] [blame] | 377 | RadiusOperationalStatusEvaluationMode newEvaluationMode = |
| 378 | RadiusOperationalStatusEvaluationMode.getValue(newEvaluationModeString); |
| 379 | if (newEvaluationMode != null) { |
| 380 | radiusOperationalStatusService.setRadiusOperationalStatusEvaluationMode(newEvaluationMode); |
| 381 | operationalStatusEvaluationMode = newEvaluationModeString; |
| 382 | } else { |
| 383 | properties.put("operationalStatusEvaluationMode", operationalStatusEvaluationMode); |
| 384 | } |
Matteo Scandolo | 9510e5d | 2020-09-24 17:31:52 -0700 | [diff] [blame] | 385 | |
| 386 | s = Tools.get(properties, PACKET_PROCESSOR_THREADS); |
| 387 | int oldpacketProcessorThreads = packetProcessorThreads; |
| 388 | packetProcessorThreads = Strings.isNullOrEmpty(s) ? oldpacketProcessorThreads |
| 389 | : Integer.parseInt(s.trim()); |
| 390 | if (packetProcessorExecutor == null || oldpacketProcessorThreads != packetProcessorThreads) { |
| 391 | if (packetProcessorExecutor != null) { |
| 392 | packetProcessorExecutor.shutdown(); |
| 393 | } |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 394 | packetProcessorExecutor = newSingleThreadExecutor( |
| 395 | groupedThreads("onos/aaa", "aaa-packet-%d", log)); |
Matteo Scandolo | 9510e5d | 2020-09-24 17:31:52 -0700 | [diff] [blame] | 396 | } |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 397 | } |
| 398 | |
Shubham Sharma | cf5e503 | 2019-11-26 11:09:21 +0000 | [diff] [blame] | 399 | protected void configureRadiusCommunication() { |
Deepa Vaddireddy | e0e1072 | 2017-09-27 05:00:10 +0530 | [diff] [blame] | 400 | if (radiusConnectionType.toLowerCase().equals("socket")) { |
| 401 | impl = new SocketBasedRadiusCommunicator(appId, packetService, this); |
| 402 | } else { |
| 403 | impl = new PortBasedRadiusCommunicator(appId, packetService, mastershipService, |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 404 | deviceService, subsService, pktCustomizer, this); |
Deepa Vaddireddy | e0e1072 | 2017-09-27 05:00:10 +0530 | [diff] [blame] | 405 | } |
| 406 | } |
| 407 | |
| 408 | private void configurePacketCustomizer() { |
| 409 | switch (customizer.toLowerCase()) { |
| 410 | case "sample": |
| 411 | pktCustomizer = new SamplePacketCustomizer(customInfo); |
| 412 | log.info("Created SamplePacketCustomizer"); |
| 413 | break; |
Saurav Das | e72358a | 2018-11-13 21:56:46 -0800 | [diff] [blame] | 414 | case "att": |
| 415 | pktCustomizer = new AttPacketCustomizer(customInfo); |
| 416 | log.info("Created AttPacketCustomizer"); |
| 417 | break; |
Deepa Vaddireddy | e0e1072 | 2017-09-27 05:00:10 +0530 | [diff] [blame] | 418 | default: |
| 419 | pktCustomizer = new PacketCustomizer(customInfo); |
| 420 | log.info("Created default PacketCustomizer"); |
| 421 | break; |
| 422 | } |
| 423 | } |
| 424 | |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 425 | private void getConfiguredAaaServerAddress() { |
| 426 | try { |
| 427 | InetAddress address; |
| 428 | if (newCfg.radiusHostName() != null) { |
| 429 | address = InetAddress.getByName(newCfg.radiusHostName()); |
| 430 | } else { |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 431 | address = newCfg.radiusIp(); |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 432 | } |
| 433 | |
| 434 | configuredAaaServerAddress = address.getHostAddress(); |
| 435 | } catch (UnknownHostException uhe) { |
| 436 | log.warn("Unable to resolve host {}", newCfg.radiusHostName()); |
| 437 | } |
| 438 | } |
| 439 | |
Vijaykumar Kushwaha | 056e4cd | 2019-08-06 13:16:25 +0000 | [diff] [blame] | 440 | private void checkReceivedPacketForValidValidator(RADIUS radiusPacket, byte[] requestAuthenticator) { |
| 441 | if (!checkResponseMessageAuthenticator(radiusSecret, radiusPacket, requestAuthenticator)) { |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 442 | aaaStatisticsManager.getAaaStats().increaseInvalidValidatorsRx(); |
| 443 | } |
| 444 | } |
Vijaykumar Kushwaha | 056e4cd | 2019-08-06 13:16:25 +0000 | [diff] [blame] | 445 | |
| 446 | private boolean checkResponseMessageAuthenticator(String key, RADIUS radiusPacket, byte[] requestAuthenticator) { |
| 447 | byte[] newHash = new byte[16]; |
| 448 | Arrays.fill(newHash, (byte) 0); |
| 449 | byte[] messageAuthenticator = radiusPacket.getAttribute(RADIUSAttribute.RADIUS_ATTR_MESSAGE_AUTH).getValue(); |
| 450 | byte[] authenticator = radiusPacket.getAuthenticator(); |
| 451 | radiusPacket.updateAttribute(RADIUSAttribute.RADIUS_ATTR_MESSAGE_AUTH, newHash); |
| 452 | radiusPacket.setAuthenticator(requestAuthenticator); |
| 453 | // Calculate the MD5 HMAC based on the message |
| 454 | try { |
| 455 | SecretKeySpec keySpec = new SecretKeySpec(key.getBytes(), "HmacMD5"); |
| 456 | Mac mac = Mac.getInstance("HmacMD5"); |
| 457 | mac.init(keySpec); |
| 458 | newHash = mac.doFinal(radiusPacket.serialize()); |
| 459 | } catch (Exception e) { |
| 460 | log.error("Failed to generate message authenticator: {}", e.getMessage()); |
| 461 | } |
| 462 | radiusPacket.updateAttribute(RADIUSAttribute.RADIUS_ATTR_MESSAGE_AUTH, messageAuthenticator); |
| 463 | radiusPacket.setAuthenticator(authenticator); |
| 464 | // Compare the calculated Message-Authenticator with the one in the message |
| 465 | return Arrays.equals(newHash, messageAuthenticator); |
| 466 | } |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 467 | |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 468 | public void checkForPacketFromUnknownServer(String hostAddress) { |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 469 | if (!hostAddress.equals(configuredAaaServerAddress)) { |
| 470 | getConfiguredAaaServerAddress(); |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 471 | if (!hostAddress.equals(configuredAaaServerAddress)) { |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 472 | aaaStatisticsManager.getAaaStats().incrementUnknownServerRx(); |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 473 | } |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 474 | } |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 475 | } |
| 476 | |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 477 | /** |
| 478 | * Send RADIUS packet to the RADIUS server. |
| 479 | * |
| 480 | * @param radiusPacket RADIUS packet to be sent to server. |
| 481 | * @param inPkt Incoming EAPOL packet |
| 482 | */ |
| 483 | protected void sendRadiusPacket(RADIUS radiusPacket, InboundPacket inPkt) { |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 484 | outPacketSet.add(radiusPacket.getIdentifier()); |
| 485 | aaaStatisticsManager.getAaaStats().increaseOrDecreasePendingRequests(true); |
| 486 | aaaStatisticsManager.getAaaStats().increaseAccessRequestsTx(); |
Shubham Sharma | 4900ce6 | 2019-06-19 14:18:50 +0000 | [diff] [blame] | 487 | aaaStatisticsManager.putOutgoingIdentifierToMap(radiusPacket.getIdentifier()); |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 488 | impl.sendRadiusPacket(radiusPacket, inPkt); |
| 489 | } |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 490 | |
Jonathan Hart | 612651f | 2019-11-25 09:21:43 -0800 | [diff] [blame] | 491 | /** |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 492 | * Handles RADIUS packets. |
| 493 | * |
| 494 | * @param radiusPacket RADIUS packet coming from the RADIUS server. |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 495 | */ |
Matteo Scandolo | 9510e5d | 2020-09-24 17:31:52 -0700 | [diff] [blame] | 496 | public void handleRadiusPacket(RADIUS radiusPacket) { |
Andrea Campanella | c4781e6 | 2020-10-08 12:58:45 +0200 | [diff] [blame] | 497 | if (log.isTraceEnabled()) { |
| 498 | log.trace("Received RADIUS packet {}", radiusPacket); |
| 499 | } |
| 500 | if (radiusOperationalStatusService.isRadiusResponseForOperationalStatus(radiusPacket.getIdentifier())) { |
| 501 | radiusOperationalStatusService.handleRadiusPacketForOperationalStatus(radiusPacket); |
| 502 | return; |
| 503 | } |
Jonathan Hart | 612651f | 2019-11-25 09:21:43 -0800 | [diff] [blame] | 504 | |
Andrea Campanella | c4781e6 | 2020-10-08 12:58:45 +0200 | [diff] [blame] | 505 | RequestIdentifier identifier = RequestIdentifier.of(radiusPacket.getIdentifier()); |
| 506 | String sessionId = idManager.getSessionId(identifier); |
Jonathan Hart | 612651f | 2019-11-25 09:21:43 -0800 | [diff] [blame] | 507 | |
Andrea Campanella | c4781e6 | 2020-10-08 12:58:45 +0200 | [diff] [blame] | 508 | if (sessionId == null) { |
| 509 | log.error("Invalid packet identifier {}, could not find corresponding " |
| 510 | + "state machine ... exiting", radiusPacket.getIdentifier()); |
| 511 | aaaStatisticsManager.getAaaStats().incrementNumberOfSessionsExpired(); |
| 512 | aaaStatisticsManager.getAaaStats().countDroppedResponsesRx(); |
| 513 | return; |
| 514 | } |
Jonathan Hart | 612651f | 2019-11-25 09:21:43 -0800 | [diff] [blame] | 515 | |
Andrea Campanella | c4781e6 | 2020-10-08 12:58:45 +0200 | [diff] [blame] | 516 | idManager.releaseIdentifier(identifier); |
| 517 | StateMachine stateMachine = stateMachines.get(sessionId); |
| 518 | if (stateMachine == null) { |
| 519 | log.error("Invalid packet identifier {}, could not find corresponding " |
| 520 | + "state machine ... exiting", radiusPacket.getIdentifier()); |
| 521 | aaaStatisticsManager.getAaaStats().incrementNumberOfSessionsExpired(); |
| 522 | aaaStatisticsManager.getAaaStats().countDroppedResponsesRx(); |
| 523 | return; |
| 524 | } |
Kartikey Dubey | adeb26e | 2019-10-01 12:18:35 +0000 | [diff] [blame] | 525 | |
Andrea Campanella | c4781e6 | 2020-10-08 12:58:45 +0200 | [diff] [blame] | 526 | //instance of StateMachine using the sessionId for updating machine stats |
| 527 | StateMachine machineStats = stateMachines.get(stateMachine.sessionId()); |
Kartikey Dubey | adeb26e | 2019-10-01 12:18:35 +0000 | [diff] [blame] | 528 | |
Andrea Campanella | c4781e6 | 2020-10-08 12:58:45 +0200 | [diff] [blame] | 529 | EAP eapPayload; |
| 530 | Ethernet eth; |
| 531 | checkReceivedPacketForValidValidator(radiusPacket, stateMachine.requestAuthenticator()); |
Kartikey Dubey | adeb26e | 2019-10-01 12:18:35 +0000 | [diff] [blame] | 532 | |
Andrea Campanella | c4781e6 | 2020-10-08 12:58:45 +0200 | [diff] [blame] | 533 | //increasing packets and octets received from server |
| 534 | machineStats.incrementTotalPacketsReceived(); |
| 535 | try { |
| 536 | machineStats.incrementTotalOctetReceived(radiusPacket.decapsulateMessage().getLength()); |
| 537 | } catch (DeserializationException e) { |
| 538 | log.error(e.getMessage()); |
| 539 | return; |
| 540 | } |
Matteo Scandolo | 9510e5d | 2020-09-24 17:31:52 -0700 | [diff] [blame] | 541 | |
Andrea Campanella | c4781e6 | 2020-10-08 12:58:45 +0200 | [diff] [blame] | 542 | if (outPacketSet.contains(radiusPacket.getIdentifier())) { |
| 543 | aaaStatisticsManager.getAaaStats().increaseOrDecreasePendingRequests(false); |
| 544 | outPacketSet.remove(new Byte(radiusPacket.getIdentifier())); |
| 545 | } |
Matteo Scandolo | 9510e5d | 2020-09-24 17:31:52 -0700 | [diff] [blame] | 546 | |
Andrea Campanella | c4781e6 | 2020-10-08 12:58:45 +0200 | [diff] [blame] | 547 | MacAddress dstMac = stateMachine.supplicantAddress(); |
| 548 | ConnectPoint supplicantCp = stateMachine.supplicantConnectpoint(); |
| 549 | switch (radiusPacket.getCode()) { |
| 550 | case RADIUS.RADIUS_CODE_ACCESS_CHALLENGE: |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 551 | log.debug("RADIUS packet: RADIUS_CODE_ACCESS_CHALLENGE for dev/port: {}/{} " + |
| 552 | "with MacAddress {} and Identifier {}", |
| 553 | supplicantCp.deviceId(), supplicantCp.port(), dstMac, radiusPacket.getIdentifier() & 0xff); |
Andrea Campanella | c4781e6 | 2020-10-08 12:58:45 +0200 | [diff] [blame] | 554 | RADIUSAttribute radiusAttrState = radiusPacket.getAttribute(RADIUSAttribute.RADIUS_ATTR_STATE); |
| 555 | byte[] challengeState = null; |
| 556 | if (radiusAttrState != null) { |
| 557 | challengeState = radiusAttrState.getValue(); |
| 558 | } |
| 559 | try { |
| 560 | eapPayload = radiusPacket.decapsulateMessage(); |
| 561 | eth = buildEapolResponse(stateMachine.supplicantAddress(), |
| 562 | MacAddress.valueOf(nasMacAddress), |
| 563 | stateMachine.vlanId(), |
| 564 | EAPOL.EAPOL_PACKET, |
| 565 | eapPayload, stateMachine.priorityCode()); |
| 566 | stateMachine.setChallengeInfo(eapPayload.getIdentifier(), challengeState); |
| 567 | } catch (DeserializationException e) { |
| 568 | log.error(e.getMessage()); |
Matteo Scandolo | 9510e5d | 2020-09-24 17:31:52 -0700 | [diff] [blame] | 569 | break; |
Andrea Campanella | c4781e6 | 2020-10-08 12:58:45 +0200 | [diff] [blame] | 570 | } |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 571 | log.debug("Send EAP challenge response to supplicant on dev/port: {}/{}" + |
| 572 | " with MacAddress {} and Identifier {}", |
| 573 | supplicantCp.deviceId(), supplicantCp.port(), dstMac, radiusPacket.getIdentifier() & 0xff); |
Andrea Campanella | c4781e6 | 2020-10-08 12:58:45 +0200 | [diff] [blame] | 574 | sendPacketToSupplicant(eth, stateMachine.supplicantConnectpoint(), true); |
| 575 | aaaStatisticsManager.getAaaStats().increaseChallengeResponsesRx(); |
| 576 | outPacketSupp.add(eapPayload.getIdentifier()); |
Andrea Campanella | 76ae68d | 2020-10-14 11:16:37 +0200 | [diff] [blame] | 577 | aaaStatisticsManager.getAaaStats().incrementPendingReqSupp(); |
Andrea Campanella | c4781e6 | 2020-10-08 12:58:45 +0200 | [diff] [blame] | 578 | //increasing packets send to server |
| 579 | machineStats.incrementTotalPacketsSent(); |
| 580 | machineStats.incrementTotalOctetSent(eapPayload.getLength()); |
| 581 | break; |
| 582 | case RADIUS.RADIUS_CODE_ACCESS_ACCEPT: |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 583 | log.debug("RADIUS packet: RADIUS_CODE_ACCESS_ACCEPT for dev/port: {}/{}" + |
| 584 | " with MacAddress {} and Identifier {}", |
| 585 | supplicantCp.deviceId(), supplicantCp.port(), dstMac, radiusPacket.getIdentifier() & 0xff); |
Andrea Campanella | c4781e6 | 2020-10-08 12:58:45 +0200 | [diff] [blame] | 586 | //send an EAPOL - Success to the supplicant. |
| 587 | byte[] eapMessageSuccess = |
| 588 | radiusPacket.getAttribute(RADIUSAttribute.RADIUS_ATTR_EAP_MESSAGE).getValue(); |
| 589 | try { |
Matteo Scandolo | 9510e5d | 2020-09-24 17:31:52 -0700 | [diff] [blame] | 590 | eapPayload = EAP.deserializer().deserialize( |
| 591 | eapMessageSuccess, 0, eapMessageSuccess.length); |
Andrea Campanella | c4781e6 | 2020-10-08 12:58:45 +0200 | [diff] [blame] | 592 | } catch (DeserializationException e) { |
| 593 | log.error(e.getMessage()); |
Matteo Scandolo | 9510e5d | 2020-09-24 17:31:52 -0700 | [diff] [blame] | 594 | break; |
Andrea Campanella | c4781e6 | 2020-10-08 12:58:45 +0200 | [diff] [blame] | 595 | } |
Matteo Scandolo | 9510e5d | 2020-09-24 17:31:52 -0700 | [diff] [blame] | 596 | |
Andrea Campanella | c4781e6 | 2020-10-08 12:58:45 +0200 | [diff] [blame] | 597 | eth = buildEapolResponse(stateMachine.supplicantAddress(), |
| 598 | MacAddress.valueOf(nasMacAddress), |
| 599 | stateMachine.vlanId(), |
| 600 | EAPOL.EAPOL_PACKET, |
| 601 | eapPayload, stateMachine.priorityCode()); |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 602 | log.info("Send EAP success message to supplicant on dev/port: {}/{}" + |
| 603 | " with MacAddress {} and Identifier {}", |
| 604 | supplicantCp.deviceId(), supplicantCp.port(), dstMac, radiusPacket.getIdentifier() & 0xff); |
Andrea Campanella | c4781e6 | 2020-10-08 12:58:45 +0200 | [diff] [blame] | 605 | sendPacketToSupplicant(eth, stateMachine.supplicantConnectpoint(), false); |
| 606 | aaaStatisticsManager.getAaaStats().incrementEapolAuthSuccessTrans(); |
| 607 | |
| 608 | stateMachine.authorizeAccess(); |
| 609 | aaaStatisticsManager.getAaaStats().increaseAcceptResponsesRx(); |
| 610 | //increasing packets send to server |
| 611 | machineStats.incrementTotalPacketsSent(); |
| 612 | machineStats.incrementTotalOctetSent(eapPayload.getLength()); |
| 613 | break; |
| 614 | case RADIUS.RADIUS_CODE_ACCESS_REJECT: |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 615 | log.debug("RADIUS packet: RADIUS_CODE_ACCESS_REJECT for dev/port: {}/{}" + |
| 616 | " with MacAddress {} and Identifier {}", |
| 617 | supplicantCp.deviceId(), supplicantCp.port(), dstMac, radiusPacket.getIdentifier() & 0xff); |
Andrea Campanella | c4781e6 | 2020-10-08 12:58:45 +0200 | [diff] [blame] | 618 | //send an EAPOL - Failure to the supplicant. |
| 619 | byte[] eapMessageFailure; |
| 620 | eapPayload = new EAP(); |
| 621 | RADIUSAttribute radiusAttrEap = radiusPacket.getAttribute(RADIUSAttribute.RADIUS_ATTR_EAP_MESSAGE); |
| 622 | if (radiusAttrEap == null) { |
| 623 | eapPayload.setCode(EAP.FAILURE); |
| 624 | eapPayload.setIdentifier(stateMachine.challengeIdentifier()); |
| 625 | eapPayload.setLength(EAP.EAP_HDR_LEN_SUC_FAIL); |
| 626 | } else { |
| 627 | eapMessageFailure = radiusAttrEap.getValue(); |
Matteo Scandolo | 9510e5d | 2020-09-24 17:31:52 -0700 | [diff] [blame] | 628 | try { |
Andrea Campanella | c4781e6 | 2020-10-08 12:58:45 +0200 | [diff] [blame] | 629 | eapPayload = EAP.deserializer().deserialize( |
| 630 | eapMessageFailure, 0, eapMessageFailure.length); |
Matteo Scandolo | 9510e5d | 2020-09-24 17:31:52 -0700 | [diff] [blame] | 631 | } catch (DeserializationException e) { |
| 632 | log.error(e.getMessage()); |
| 633 | break; |
| 634 | } |
Andrea Campanella | c4781e6 | 2020-10-08 12:58:45 +0200 | [diff] [blame] | 635 | } |
| 636 | eth = buildEapolResponse(stateMachine.supplicantAddress(), |
| 637 | MacAddress.valueOf(nasMacAddress), |
| 638 | stateMachine.vlanId(), |
| 639 | EAPOL.EAPOL_PACKET, |
| 640 | eapPayload, stateMachine.priorityCode()); |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 641 | log.warn("Send EAP failure message to supplicant {} on dev/port: {}/{}" + |
| 642 | " with MacAddress {} and Identifier {}", supplicantCp.deviceId(), supplicantCp.port(), |
| 643 | dstMac, stateMachine.challengeIdentifier() & 0xff); |
Andrea Campanella | c4781e6 | 2020-10-08 12:58:45 +0200 | [diff] [blame] | 644 | sendPacketToSupplicant(eth, stateMachine.supplicantConnectpoint(), false); |
| 645 | aaaStatisticsManager.getAaaStats().incrementEapolauthFailureTrans(); |
| 646 | |
| 647 | stateMachine.denyAccess(); |
| 648 | aaaStatisticsManager.getAaaStats().increaseRejectResponsesRx(); |
| 649 | //increasing packets send to server |
| 650 | machineStats.incrementTotalPacketsSent(); |
| 651 | machineStats.incrementTotalOctetSent(eapPayload.getLength()); |
| 652 | //pushing machine stats to kafka |
| 653 | AaaSupplicantMachineStats machineObj = aaaSupplicantStatsManager.getSupplicantStats(machineStats); |
| 654 | aaaSupplicantStatsManager.getMachineStatsDelegate() |
| 655 | .notify(new AaaMachineStatisticsEvent(AaaMachineStatisticsEvent.Type.STATS_UPDATE, |
| 656 | machineObj)); |
| 657 | break; |
| 658 | default: |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 659 | log.warn("Unknown RADIUS message received with code: {} for dev/port: {}/{}" + |
| 660 | " with MacAddress {} and Identifier {}", |
| 661 | radiusPacket.getCode(), supplicantCp.deviceId(), supplicantCp.port(), dstMac, |
| 662 | radiusPacket.getIdentifier() & 0xff); |
Andrea Campanella | c4781e6 | 2020-10-08 12:58:45 +0200 | [diff] [blame] | 663 | aaaStatisticsManager.getAaaStats().increaseUnknownTypeRx(); |
| 664 | //increasing packets received to server |
| 665 | machineStats.incrementTotalPacketsReceived(); |
| 666 | try { |
| 667 | machineStats.incrementTotalOctetReceived(radiusPacket.decapsulateMessage().getLength()); |
| 668 | } catch (DeserializationException e) { |
| 669 | log.error(e.getMessage()); |
| 670 | break; |
| 671 | } |
| 672 | } |
| 673 | aaaStatisticsManager.getAaaStats().countDroppedResponsesRx(); |
Aaron Kruglikov | d39d99e | 2015-07-03 13:30:57 -0700 | [diff] [blame] | 674 | } |
| 675 | |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 676 | /** |
| 677 | * Send the ethernet packet to the supplicant. |
| 678 | * |
| 679 | * @param ethernetPkt the ethernet packet |
| 680 | * @param connectPoint the connect point to send out |
| 681 | */ |
Shubham Sharma | 1f19358 | 2019-07-11 12:12:41 +0000 | [diff] [blame] | 682 | private void sendPacketToSupplicant(Ethernet ethernetPkt, ConnectPoint connectPoint, boolean isChallengeResponse) { |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 683 | TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(connectPoint.port()).build(); |
| 684 | OutboundPacket packet = new DefaultOutboundPacket(connectPoint.deviceId(), |
| 685 | treatment, ByteBuffer.wrap(ethernetPkt.serialize())); |
Shubham Sharma | 1f19358 | 2019-07-11 12:12:41 +0000 | [diff] [blame] | 686 | EAPOL eap = ((EAPOL) ethernetPkt.getPayload()); |
Saurav Das | 987441a | 2018-09-18 16:33:47 -0700 | [diff] [blame] | 687 | if (log.isTraceEnabled()) { |
Andrea Campanella | c4781e6 | 2020-10-08 12:58:45 +0200 | [diff] [blame] | 688 | log.trace("Sending eapol payload {} enclosed in {} to supplicant at {} with MacAddress {}", |
| 689 | eap, ethernetPkt, connectPoint, ethernetPkt.getDestinationMAC()); |
Saurav Das | 987441a | 2018-09-18 16:33:47 -0700 | [diff] [blame] | 690 | } |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 691 | packetService.emit(packet); |
Shubham Sharma | 1f19358 | 2019-07-11 12:12:41 +0000 | [diff] [blame] | 692 | if (isChallengeResponse) { |
| 693 | aaaStatisticsManager.getAaaStats().incrementEapPktTxauthEap(); |
| 694 | } |
Shubham Sharma | 3c8c702 | 2019-09-13 10:39:47 +0000 | [diff] [blame] | 695 | aaaStatisticsManager.getAaaStats().incrementEapolFramesTx(); |
| 696 | aaaStatisticsManager.getAaaStats().countReqEapFramesTx(); |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 697 | } |
| 698 | |
Matt Jeanneret | 2ff1a78 | 2018-06-13 15:24:25 -0400 | [diff] [blame] | 699 | @Override |
| 700 | public String toString() { |
| 701 | return ToStringBuilder.reflectionToString(this); |
| 702 | } |
| 703 | |
Jonathan Hart | 612651f | 2019-11-25 09:21:43 -0800 | [diff] [blame] | 704 | @Override |
Jonathan Hart | 9d1ce80 | 2020-01-28 10:45:08 -0800 | [diff] [blame] | 705 | public Iterable<AuthenticationRecord> getAuthenticationRecords() { |
Hardik Windlass | d0b4969 | 2020-02-26 18:17:14 +0000 | [diff] [blame] | 706 | return authentications.values(); |
Jonathan Hart | 612651f | 2019-11-25 09:21:43 -0800 | [diff] [blame] | 707 | } |
| 708 | |
| 709 | @Override |
| 710 | public boolean removeAuthenticationStateByMac(MacAddress mac) { |
| 711 | |
Hardik Windlass | d0b4969 | 2020-02-26 18:17:14 +0000 | [diff] [blame] | 712 | Optional<AuthenticationRecord> r = authentications.values().stream() |
| 713 | .filter(v -> v.supplicantAddress().equals(mac)) |
Jonathan Hart | 9d1ce80 | 2020-01-28 10:45:08 -0800 | [diff] [blame] | 714 | .findFirst(); |
Jonathan Hart | 612651f | 2019-11-25 09:21:43 -0800 | [diff] [blame] | 715 | |
Jonathan Hart | 9d1ce80 | 2020-01-28 10:45:08 -0800 | [diff] [blame] | 716 | if (r.isEmpty()) { |
| 717 | return false; |
Jonathan Hart | 612651f | 2019-11-25 09:21:43 -0800 | [diff] [blame] | 718 | } |
| 719 | |
Hardik Windlass | d0b4969 | 2020-02-26 18:17:14 +0000 | [diff] [blame] | 720 | AuthenticationRecord removed = |
| 721 | authentications.remove(r.get().supplicantConnectPoint()); |
Jonathan Hart | 612651f | 2019-11-25 09:21:43 -0800 | [diff] [blame] | 722 | |
Jonathan Hart | 9d1ce80 | 2020-01-28 10:45:08 -0800 | [diff] [blame] | 723 | return removed != null; |
Jonathan Hart | 612651f | 2019-11-25 09:21:43 -0800 | [diff] [blame] | 724 | } |
| 725 | |
Jonathan Hart | 9d1ce80 | 2020-01-28 10:45:08 -0800 | [diff] [blame] | 726 | StateMachine getStateMachine(String sessionId) { |
Jonathan Hart | 612651f | 2019-11-25 09:21:43 -0800 | [diff] [blame] | 727 | return stateMachines.get(sessionId); |
| 728 | } |
| 729 | |
| 730 | private String sessionId(ConnectPoint cp) { |
| 731 | return cp.deviceId().toString() + cp.port().toString(); |
| 732 | } |
| 733 | |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 734 | // our handler defined as a private inner class |
| 735 | |
| 736 | /** |
| 737 | * Packet processor responsible for forwarding packets along their paths. |
| 738 | */ |
| 739 | private class ReactivePacketProcessor implements PacketProcessor { |
| 740 | @Override |
| 741 | public void process(PacketContext context) { |
Andrea Campanella | c4781e6 | 2020-10-08 12:58:45 +0200 | [diff] [blame] | 742 | packetProcessorExecutor.execute(() -> { |
| 743 | // Extract the original Ethernet frame from the packet information |
| 744 | InboundPacket pkt = context.inPacket(); |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 745 | if (pkt == null) { |
| 746 | log.error("InboundPacket is null when parsed from {}", context); |
| 747 | return; |
| 748 | } |
Andrea Campanella | c4781e6 | 2020-10-08 12:58:45 +0200 | [diff] [blame] | 749 | Ethernet ethPkt = pkt.parsed(); |
| 750 | if (ethPkt == null) { |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 751 | log.error("EthPkt is null when parsed from {}", pkt); |
Andrea Campanella | c4781e6 | 2020-10-08 12:58:45 +0200 | [diff] [blame] | 752 | return; |
| 753 | } |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 754 | |
Andrea Campanella | c4781e6 | 2020-10-08 12:58:45 +0200 | [diff] [blame] | 755 | // identify if incoming packet comes from supplicant (EAP) or RADIUS |
| 756 | switch (EthType.EtherType.lookup(ethPkt.getEtherType())) { |
| 757 | case EAPOL: |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 758 | if (log.isTraceEnabled()) { |
| 759 | log.trace("Received EAPOL supplicant packet from dev/port: {} with MacAddress {}", |
| 760 | context.inPacket().receivedFrom(), ethPkt.getSourceMAC()); |
| 761 | } |
Andrea Campanella | c4781e6 | 2020-10-08 12:58:45 +0200 | [diff] [blame] | 762 | handleSupplicantPacket(context.inPacket()); |
| 763 | break; |
| 764 | default: |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 765 | if (log.isTraceEnabled()) { |
| 766 | log.trace("Received packet-in from RADIUS server {} in enclosing packet {} from " |
| 767 | + "dev/port: {} with MacAddress {}", ethPkt, context.inPacket(), |
| 768 | context.inPacket().receivedFrom(), ethPkt.getSourceMAC()); |
| 769 | } |
Andrea Campanella | c4781e6 | 2020-10-08 12:58:45 +0200 | [diff] [blame] | 770 | // any other packets let the specific implementation handle |
| 771 | impl.handlePacketFromServer(context); |
| 772 | } |
| 773 | }); |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 774 | } |
| 775 | |
Ray Milkey | 9eb293f | 2015-09-30 15:09:17 -0700 | [diff] [blame] | 776 | /** |
| 777 | * Creates and initializes common fields of a RADIUS packet. |
| 778 | * |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 779 | * @param stateMachine state machine for the request |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 780 | * @param eapPacket EAP packet |
Ray Milkey | 9eb293f | 2015-09-30 15:09:17 -0700 | [diff] [blame] | 781 | * @return RADIUS packet |
| 782 | */ |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 783 | private RADIUS getRadiusPayload(StateMachine stateMachine, byte identifier, EAP eapPacket) { |
Ray Milkey | 9eb293f | 2015-09-30 15:09:17 -0700 | [diff] [blame] | 784 | RADIUS radiusPayload = |
| 785 | new RADIUS(RADIUS.RADIUS_CODE_ACCESS_REQUEST, |
| 786 | eapPacket.getIdentifier()); |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 787 | |
| 788 | // set Request Authenticator in StateMachine |
| 789 | stateMachine.setRequestAuthenticator(radiusPayload.generateAuthCode()); |
| 790 | |
Ray Milkey | 9eb293f | 2015-09-30 15:09:17 -0700 | [diff] [blame] | 791 | radiusPayload.setIdentifier(identifier); |
| 792 | radiusPayload.setAttribute(RADIUSAttribute.RADIUS_ATTR_USERNAME, |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 793 | stateMachine.username()); |
Ray Milkey | 9eb293f | 2015-09-30 15:09:17 -0700 | [diff] [blame] | 794 | |
| 795 | radiusPayload.setAttribute(RADIUSAttribute.RADIUS_ATTR_NAS_IP, |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 796 | AaaManager.this.nasIpAddress.getAddress()); |
Ray Milkey | 9eb293f | 2015-09-30 15:09:17 -0700 | [diff] [blame] | 797 | |
| 798 | radiusPayload.encapsulateMessage(eapPacket); |
Ray Milkey | 9eb293f | 2015-09-30 15:09:17 -0700 | [diff] [blame] | 799 | |
| 800 | return radiusPayload; |
| 801 | } |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 802 | |
| 803 | /** |
Jonathan Hart | a46dddf | 2015-06-30 15:31:20 -0700 | [diff] [blame] | 804 | * Handles PAE packets (supplicant). |
| 805 | * |
| 806 | * @param inPacket Ethernet packet coming from the supplicant |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 807 | */ |
Jonathan Hart | 612651f | 2019-11-25 09:21:43 -0800 | [diff] [blame] | 808 | private void handleSupplicantPacket(InboundPacket inPacket) { |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 809 | |
Jonathan Hart | a46dddf | 2015-06-30 15:31:20 -0700 | [diff] [blame] | 810 | Ethernet ethPkt = inPacket.parsed(); |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 811 | // Where does it come from? |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 812 | MacAddress srcMac = ethPkt.getSourceMAC(); |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 813 | |
Jonathan Hart | a46dddf | 2015-06-30 15:31:20 -0700 | [diff] [blame] | 814 | DeviceId deviceId = inPacket.receivedFrom().deviceId(); |
| 815 | PortNumber portNumber = inPacket.receivedFrom().port(); |
Jonathan Hart | 9d1ce80 | 2020-01-28 10:45:08 -0800 | [diff] [blame] | 816 | String sessionId = sessionId(inPacket.receivedFrom()); |
Saurav Das | 987441a | 2018-09-18 16:33:47 -0700 | [diff] [blame] | 817 | EAPOL eapol = (EAPOL) ethPkt.getPayload(); |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 818 | |
Saurav Das | 987441a | 2018-09-18 16:33:47 -0700 | [diff] [blame] | 819 | if (log.isTraceEnabled()) { |
| 820 | log.trace("Received EAPOL packet {} in enclosing packet {} from " |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 821 | + "dev/port: {}/{} with MacAddress {} and type {}", |
| 822 | eapol, ethPkt, deviceId, portNumber, srcMac, eapol.getEapolType()); |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 823 | } |
Jonathan Hart | a46dddf | 2015-06-30 15:31:20 -0700 | [diff] [blame] | 824 | |
Shubham Sharma | 3c8c702 | 2019-09-13 10:39:47 +0000 | [diff] [blame] | 825 | short pktlen = eapol.getPacketLength(); |
| 826 | byte[] eapPayLoadBuffer = eapol.serialize(); |
| 827 | int len = eapPayLoadBuffer.length; |
| 828 | if (len != (HEADER_LENGTH + pktlen)) { |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 829 | log.error("Invalid EAPOL pkt length {} (shoudl be {}) for packet {} from dev/port: {}/{} " + |
| 830 | "with MacAddress {}", len, HEADER_LENGTH + pktlen, eapol, deviceId, portNumber, srcMac); |
Shubham Sharma | 3c8c702 | 2019-09-13 10:39:47 +0000 | [diff] [blame] | 831 | aaaStatisticsManager.getAaaStats().incrementInvalidBodyLength(); |
| 832 | return; |
| 833 | } |
| 834 | if (!VALID_EAPOL_TYPE.contains(eapol.getEapolType())) { |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 835 | log.error("Invalid EAPOL Type {} for packet {} from dev/port: {}/{} with MacAddress {}", |
| 836 | eapol.getEapolType(), eapol, deviceId, portNumber, srcMac); |
Shubham Sharma | 3c8c702 | 2019-09-13 10:39:47 +0000 | [diff] [blame] | 837 | aaaStatisticsManager.getAaaStats().incrementInvalidPktType(); |
| 838 | return; |
| 839 | } |
| 840 | if (pktlen >= 0 && ethPkt.getEtherType() == EthType.EtherType.EAPOL.ethType().toShort()) { |
| 841 | aaaStatisticsManager.getAaaStats().incrementValidEapolFramesRx(); |
| 842 | } |
Matteo Scandolo | 9510e5d | 2020-09-24 17:31:52 -0700 | [diff] [blame] | 843 | StateMachine stateMachine = stateMachines.computeIfAbsent(sessionId, id -> |
| 844 | new StateMachine(id, serverStatusAndStateMachineTimeoutExecutor)); |
Jonathan Hart | 612651f | 2019-11-25 09:21:43 -0800 | [diff] [blame] | 845 | stateMachine.setEapolTypeVal(eapol.getEapolType()); |
Saurav Das | 987441a | 2018-09-18 16:33:47 -0700 | [diff] [blame] | 846 | |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 847 | switch (eapol.getEapolType()) { |
| 848 | case EAPOL.EAPOL_START: |
Andrea Campanella | c4781e6 | 2020-10-08 12:58:45 +0200 | [diff] [blame] | 849 | log.debug("EAP packet: EAPOL_START from dev/port: {}/{} with MacAddress {}", |
| 850 | deviceId, portNumber, srcMac); |
Ray Milkey | f51eba2 | 2015-09-25 10:24:23 -0700 | [diff] [blame] | 851 | stateMachine.setSupplicantConnectpoint(inPacket.receivedFrom()); |
Jonathan Hart | 9d1ce80 | 2020-01-28 10:45:08 -0800 | [diff] [blame] | 852 | stateMachine.setSupplicantAddress(srcMac); |
Jonathan Hart | 5db4453 | 2018-07-12 18:13:54 -0700 | [diff] [blame] | 853 | stateMachine.start(); |
Jonathan Hart | 612651f | 2019-11-25 09:21:43 -0800 | [diff] [blame] | 854 | |
Andrea Campanella | 76ae68d | 2020-10-14 11:16:37 +0200 | [diff] [blame] | 855 | aaaStatisticsManager.getAaaStats().incrementEapolStartReqRx(); |
Ray Milkey | f51eba2 | 2015-09-25 10:24:23 -0700 | [diff] [blame] | 856 | //send an EAP Request/Identify to the supplicant |
| 857 | EAP eapPayload = new EAP(EAP.REQUEST, stateMachine.identifier(), EAP.ATTR_IDENTITY, null); |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 858 | if (ethPkt.getVlanID() != Ethernet.VLAN_UNTAGGED) { |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 859 | stateMachine.setPriorityCode(ethPkt.getPriorityCode()); |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 860 | } |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 861 | Ethernet eth = buildEapolResponse(srcMac, MacAddress.valueOf(nasMacAddress), |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 862 | ethPkt.getVlanID(), EAPOL.EAPOL_PACKET, eapPayload, stateMachine.priorityCode()); |
Matt Jeanneret | 2ff1a78 | 2018-06-13 15:24:25 -0400 | [diff] [blame] | 863 | |
Ray Milkey | f51eba2 | 2015-09-25 10:24:23 -0700 | [diff] [blame] | 864 | stateMachine.setVlanId(ethPkt.getVlanID()); |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 865 | log.debug("Getting EAP identity from supplicant {} and Identifier {}", |
| 866 | stateMachine.supplicantAddress().toString(), stateMachine.identifier() & 0xff); |
Shubham Sharma | 1f19358 | 2019-07-11 12:12:41 +0000 | [diff] [blame] | 867 | sendPacketToSupplicant(eth, stateMachine.supplicantConnectpoint(), false); |
Shubham Sharma | 3c8c702 | 2019-09-13 10:39:47 +0000 | [diff] [blame] | 868 | aaaStatisticsManager.getAaaStats().incrementRequestIdFramesTx(); |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 869 | break; |
Qianqian Hu | b55a1ac | 2015-12-23 20:44:48 +0800 | [diff] [blame] | 870 | case EAPOL.EAPOL_LOGOFF: |
Andrea Campanella | c4781e6 | 2020-10-08 12:58:45 +0200 | [diff] [blame] | 871 | log.debug("EAP packet: EAPOL_LOGOFF from dev/port: {}/{} with MacAddress {}", |
| 872 | deviceId, portNumber, srcMac); |
Kartikey Dubey | adeb26e | 2019-10-01 12:18:35 +0000 | [diff] [blame] | 873 | //posting the machine stat data for current supplicant device. |
| 874 | if (stateMachine.getSessionTerminateReason() == null || |
| 875 | stateMachine.getSessionTerminateReason().equals("")) { |
| 876 | stateMachine.setSessionTerminateReason( |
| 877 | StateMachine.SessionTerminationReasons.SUPPLICANT_LOGOFF.getReason()); |
| 878 | } |
| 879 | AaaSupplicantMachineStats obj = aaaSupplicantStatsManager.getSupplicantStats(stateMachine); |
| 880 | aaaSupplicantStatsManager.getMachineStatsDelegate() |
| 881 | .notify(new AaaMachineStatisticsEvent(AaaMachineStatisticsEvent.Type.STATS_UPDATE, obj)); |
Ray Milkey | b34b496 | 2016-01-04 10:24:43 -0800 | [diff] [blame] | 882 | if (stateMachine.state() == StateMachine.STATE_AUTHORIZED) { |
| 883 | stateMachine.logoff(); |
Shubham Sharma | 1f19358 | 2019-07-11 12:12:41 +0000 | [diff] [blame] | 884 | aaaStatisticsManager.getAaaStats().incrementEapolLogoffRx(); |
Qianqian Hu | b55a1ac | 2015-12-23 20:44:48 +0800 | [diff] [blame] | 885 | } |
Shubham Sharma | 3c8c702 | 2019-09-13 10:39:47 +0000 | [diff] [blame] | 886 | if (stateMachine.state() == StateMachine.STATE_IDLE) { |
| 887 | aaaStatisticsManager.getAaaStats().incrementAuthStateIdle(); |
| 888 | } |
Qianqian Hu | b55a1ac | 2015-12-23 20:44:48 +0800 | [diff] [blame] | 889 | break; |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 890 | case EAPOL.EAPOL_PACKET: |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 891 | |
Ray Milkey | 9eb293f | 2015-09-30 15:09:17 -0700 | [diff] [blame] | 892 | // check if this is a Response/Identify or a Response/TLS |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 893 | EAP eapPacket = (EAP) eapol.getPayload(); |
Shubham Sharma | 3c8c702 | 2019-09-13 10:39:47 +0000 | [diff] [blame] | 894 | Byte identifier = new Byte(eapPacket.getIdentifier()); |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 895 | log.debug("EAP packet: EAPOL_PACKET from dev/port: {}/{} with MacAddress {} with Identifier {}", |
| 896 | deviceId, portNumber, srcMac, identifier.doubleValue()); |
Jonathan Hart | 612651f | 2019-11-25 09:21:43 -0800 | [diff] [blame] | 897 | // get identifier for request and store mapping to session ID |
| 898 | RequestIdentifier radiusIdentifier = idManager.getNewIdentifier(sessionId); |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 899 | if (radiusIdentifier == null) { |
| 900 | log.error("Cannot get RADIUS Identifier, dropping packet"); |
| 901 | return; |
| 902 | } |
Jonathan Hart | 612651f | 2019-11-25 09:21:43 -0800 | [diff] [blame] | 903 | |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 904 | byte dataType = eapPacket.getDataType(); |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 905 | |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 906 | switch (dataType) { |
Ray Milkey | 9eb293f | 2015-09-30 15:09:17 -0700 | [diff] [blame] | 907 | case EAP.ATTR_IDENTITY: |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 908 | handleAttrIdentity(inPacket, srcMac, deviceId, portNumber, |
| 909 | eapol, stateMachine, eapPacket, radiusIdentifier); |
Ray Milkey | 9eb293f | 2015-09-30 15:09:17 -0700 | [diff] [blame] | 910 | break; |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 911 | case EAP.ATTR_MD5: |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 912 | handleMD5(inPacket, srcMac, deviceId, portNumber, stateMachine, |
| 913 | eapPacket, identifier, radiusIdentifier); |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 914 | break; |
| 915 | case EAP.ATTR_TLS: |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 916 | handleTls(inPacket, srcMac, deviceId, portNumber, stateMachine, |
| 917 | eapPacket, identifier, radiusIdentifier); |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 918 | break; |
| 919 | default: |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 920 | log.warn("Unknown EAP packet type from dev/port: {}/{} with MacAddress {} and " + |
| 921 | "Identifier {}", deviceId, portNumber, srcMac, eapPacket.getIdentifier() & 0xff); |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 922 | return; |
| 923 | } |
| 924 | break; |
| 925 | default: |
Andrea Campanella | c4781e6 | 2020-10-08 12:58:45 +0200 | [diff] [blame] | 926 | log.debug("Skipping EAPOL message {} from dev/port: {}/{} with MacAddress {}", |
| 927 | eapol.getEapolType(), deviceId, portNumber, srcMac); |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 928 | } |
Shubham Sharma | 1f19358 | 2019-07-11 12:12:41 +0000 | [diff] [blame] | 929 | aaaStatisticsManager.getAaaStats().countTransRespNotNak(); |
| 930 | aaaStatisticsManager.getAaaStats().countEapolResIdentityMsgTrans(); |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 931 | } |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 932 | |
| 933 | private void handleAttrIdentity(InboundPacket inPacket, MacAddress srcMac, DeviceId deviceId, |
| 934 | PortNumber portNumber, EAPOL eapol, StateMachine stateMachine, |
| 935 | EAP eapPacket, RequestIdentifier radiusIdentifier) { |
| 936 | RADIUS radiusPayload; |
| 937 | log.debug("EAP packet: EAPOL_PACKET ATTR_IDENTITY from dev/port: {}/{} with MacAddress {}" + |
| 938 | " and Identifier {}", deviceId, portNumber, srcMac, eapPacket.getIdentifier() & 0xff); |
| 939 | //Setting the time of this response from RG, only when its not a re-transmission. |
| 940 | if (stateMachine.getLastPacketReceivedTime() == 0) { |
| 941 | stateMachine.setLastPacketReceivedTime(System.currentTimeMillis()); |
| 942 | } |
| 943 | // request id access to RADIUS |
| 944 | stateMachine.setUsername(eapPacket.getData()); |
| 945 | |
| 946 | radiusPayload = getRadiusPayload(stateMachine, radiusIdentifier.identifier(), eapPacket); |
| 947 | radiusPayload = pktCustomizer.customizePacket(radiusPayload, inPacket); |
| 948 | radiusPayload.addMessageAuthenticator(radiusSecret); |
| 949 | |
| 950 | if (log.isTraceEnabled()) { |
| 951 | log.trace("Sending ATTR_IDENTITY packet to RADIUS for supplicant at dev/port: " + |
| 952 | "{}/{} with MacAddress {} and Identifier {}", deviceId, portNumber, |
| 953 | srcMac, radiusIdentifier.identifier() & 0xff); |
| 954 | } |
| 955 | |
| 956 | sendRadiusPacket(radiusPayload, inPacket); |
| 957 | stateMachine.setWaitingForRadiusResponse(true); |
| 958 | aaaStatisticsManager.getAaaStats().incrementRadiusReqIdTx(); |
| 959 | aaaStatisticsManager.getAaaStats().incrementEapolAtrrIdentity(); |
| 960 | // change the state to "PENDING" |
| 961 | if (stateMachine.state() == StateMachine.STATE_PENDING) { |
| 962 | aaaStatisticsManager.getAaaStats().increaseRequestReTx(); |
| 963 | stateMachine.incrementTotalPacketsSent(); |
| 964 | stateMachine.incrementTotalOctetSent(eapol.getPacketLength()); |
| 965 | } |
| 966 | stateMachine.requestAccess(); |
| 967 | } |
| 968 | |
| 969 | private void handleMD5(InboundPacket inPacket, MacAddress srcMac, DeviceId deviceId, |
| 970 | PortNumber portNumber, StateMachine stateMachine, EAP eapPacket, |
| 971 | Byte identifier, RequestIdentifier radiusIdentifier) { |
| 972 | RADIUS radiusPayload; |
| 973 | log.debug("EAP packet: EAPOL_PACKET ATTR_MD5 from dev/port: {}/{} with MacAddress {}" + |
| 974 | " and Identifier {}", deviceId, portNumber, srcMac, eapPacket.getIdentifier() & 0xff); |
| 975 | // verify if the EAP identifier corresponds to the |
| 976 | // challenge identifier from the client state |
| 977 | // machine. |
| 978 | stateMachine.setLastPacketReceivedTime(System.currentTimeMillis()); |
| 979 | if (eapPacket.getIdentifier() == stateMachine.challengeIdentifier()) { |
| 980 | //send the RADIUS challenge response |
| 981 | radiusPayload = getRadiusPayload(stateMachine, |
| 982 | radiusIdentifier.identifier(), eapPacket); |
| 983 | radiusPayload = pktCustomizer.customizePacket(radiusPayload, inPacket); |
| 984 | |
| 985 | if (stateMachine.challengeState() != null) { |
| 986 | radiusPayload.setAttribute(RADIUSAttribute.RADIUS_ATTR_STATE, |
| 987 | stateMachine.challengeState()); |
| 988 | } |
| 989 | radiusPayload.addMessageAuthenticator(radiusSecret); |
| 990 | if (outPacketSupp.contains(eapPacket.getIdentifier())) { |
| 991 | aaaStatisticsManager.getAaaStats().decrementPendingReqSupp(); |
| 992 | outPacketSupp.remove(identifier); |
| 993 | } |
| 994 | if (log.isTraceEnabled()) { |
| 995 | log.trace("Sending ATTR_MD5 packet to RADIUS for supplicant at dev/port: {}/{}" + |
| 996 | " with MacAddress {} and Identifier {}", deviceId, portNumber, srcMac, |
| 997 | radiusIdentifier.identifier() & 0xff); |
| 998 | } |
| 999 | sendRadiusPacket(radiusPayload, inPacket); |
| 1000 | stateMachine.setWaitingForRadiusResponse(true); |
| 1001 | aaaStatisticsManager.getAaaStats().incrementRadiusReqChallengeTx(); |
| 1002 | aaaStatisticsManager.getAaaStats().incrementEapolMd5RspChall(); |
| 1003 | } else { |
| 1004 | log.error("eapolIdentifier {} and stateMachine Identifier {} do not " + |
| 1005 | "correspond for packet from dev/port: {}/{} with MacAddress {}", |
| 1006 | eapPacket.getIdentifier() & 0xff, stateMachine.challengeIdentifier() & 0xff, |
| 1007 | deviceId, portNumber, srcMac); |
| 1008 | aaaStatisticsManager.getAaaStats().incrementEapolMd5RspChall(); |
| 1009 | if (outPacketSupp.contains(eapPacket.getIdentifier())) { |
| 1010 | aaaStatisticsManager.getAaaStats().decrementPendingReqSupp(); |
| 1011 | outPacketSupp.remove(identifier); |
| 1012 | } |
| 1013 | aaaStatisticsManager.getAaaStats().incrementEapolauthFailureTrans(); |
| 1014 | } |
| 1015 | } |
| 1016 | |
| 1017 | |
| 1018 | private void handleTls(InboundPacket inPacket, MacAddress srcMac, DeviceId deviceId, |
| 1019 | PortNumber portNumber, StateMachine stateMachine, EAP eapPacket, |
| 1020 | Byte identifier, RequestIdentifier radiusIdentifier) { |
| 1021 | RADIUS radiusPayload; |
| 1022 | log.debug("EAP packet: EAPOL_PACKET ATTR_TLS from dev/port: {}/{} with MacAddress {} " + |
| 1023 | "and Identifier {}", deviceId, portNumber, srcMac, eapPacket.getIdentifier() & 0xff); |
| 1024 | // request id access to RADIUS |
| 1025 | radiusPayload = getRadiusPayload(stateMachine, radiusIdentifier.identifier(), eapPacket); |
| 1026 | radiusPayload = pktCustomizer.customizePacket(radiusPayload, inPacket); |
| 1027 | if (stateMachine.challengeState() != null) { |
| 1028 | radiusPayload.setAttribute(RADIUSAttribute.RADIUS_ATTR_STATE, |
| 1029 | stateMachine.challengeState()); |
| 1030 | } |
| 1031 | stateMachine.setRequestAuthenticator(radiusPayload.generateAuthCode()); |
| 1032 | radiusPayload.addMessageAuthenticator(radiusSecret); |
| 1033 | if (outPacketSupp.contains(eapPacket.getIdentifier())) { |
| 1034 | aaaStatisticsManager.getAaaStats().decrementPendingReqSupp(); |
| 1035 | outPacketSupp.remove(identifier); |
| 1036 | } |
| 1037 | if (log.isTraceEnabled()) { |
| 1038 | log.trace("Sending ATTR_TLS packet to RADIUS for supplicant at dev/port: {}/{} with " + |
| 1039 | "MacAddress {} and Identifier {}", deviceId, portNumber, srcMac, |
| 1040 | radiusIdentifier.identifier() & 0xff); |
| 1041 | } |
| 1042 | sendRadiusPacket(radiusPayload, inPacket); |
| 1043 | stateMachine.setWaitingForRadiusResponse(true); |
| 1044 | aaaStatisticsManager.getAaaStats().incrementRadiusReqChallengeTx(); |
| 1045 | aaaStatisticsManager.getAaaStats().incrementEapolTlsRespChall(); |
| 1046 | if (stateMachine.state() != StateMachine.STATE_PENDING) { |
| 1047 | stateMachine.requestAccess(); |
| 1048 | } |
| 1049 | } |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 1050 | } |
| 1051 | |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 1052 | /** |
Jonathan Hart | 5db4453 | 2018-07-12 18:13:54 -0700 | [diff] [blame] | 1053 | * Delegate allowing the StateMachine to notify us of events. |
| 1054 | */ |
| 1055 | private class InternalStateMachineDelegate implements StateMachineDelegate { |
| 1056 | |
| 1057 | @Override |
| 1058 | public void notify(AuthenticationEvent authenticationEvent) { |
| 1059 | log.info("Auth event {} for {}", |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 1060 | authenticationEvent.type(), authenticationEvent.subject()); |
Jonathan Hart | 612651f | 2019-11-25 09:21:43 -0800 | [diff] [blame] | 1061 | |
| 1062 | if (authenticationEvent.type() == AuthenticationEvent.Type.TIMEOUT) { |
| 1063 | handleStateMachineTimeout(authenticationEvent.subject()); |
| 1064 | } |
| 1065 | |
Jonathan Hart | 9d1ce80 | 2020-01-28 10:45:08 -0800 | [diff] [blame] | 1066 | AuthenticationRecord record = authenticationEvent.authenticationRecord(); |
| 1067 | if (record == null) { |
| 1068 | authentications.remove(authenticationEvent.subject()); |
| 1069 | } else { |
| 1070 | authentications.put(authenticationEvent.subject(), record); |
| 1071 | } |
| 1072 | |
Jonathan Hart | 5db4453 | 2018-07-12 18:13:54 -0700 | [diff] [blame] | 1073 | post(authenticationEvent); |
| 1074 | } |
| 1075 | } |
| 1076 | |
Jonathan Hart | 612651f | 2019-11-25 09:21:43 -0800 | [diff] [blame] | 1077 | private void handleStateMachineTimeout(ConnectPoint supplicantConnectPoint) { |
| 1078 | StateMachine stateMachine = stateMachines.remove(sessionId(supplicantConnectPoint)); |
Andrea Campanella | e66466a | 2020-02-03 14:05:45 +0000 | [diff] [blame] | 1079 | //pushing captured machine stats to kafka |
| 1080 | stateMachine.setSessionTerminateReason("Time out"); |
| 1081 | AaaSupplicantMachineStats obj = aaaSupplicantStatsManager |
| 1082 | .getSupplicantStats(stateMachine); |
| 1083 | aaaSupplicantStatsManager.getMachineStatsDelegate() |
| 1084 | .notify(new AaaMachineStatisticsEvent( |
| 1085 | AaaMachineStatisticsEvent.Type.STATS_UPDATE, obj)); |
| 1086 | |
Jonathan Hart | 612651f | 2019-11-25 09:21:43 -0800 | [diff] [blame] | 1087 | if (stateMachine.state() == StateMachine.STATE_PENDING && stateMachine.isWaitingForRadiusResponse()) { |
| 1088 | aaaStatisticsManager.getAaaStats().increaseTimedOutPackets(); |
| 1089 | } |
| 1090 | |
| 1091 | StateMachine.deleteStateMachineMapping(stateMachine); |
| 1092 | } |
| 1093 | |
Jonathan Hart | 5db4453 | 2018-07-12 18:13:54 -0700 | [diff] [blame] | 1094 | /** |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 1095 | * Configuration Listener, handles change in configuration. |
| 1096 | */ |
Ray Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 1097 | private class InternalConfigListener implements NetworkConfigListener { |
| 1098 | |
| 1099 | /** |
Ray Milkey | c9e8dcc | 2015-12-30 10:31:32 -0800 | [diff] [blame] | 1100 | * Reconfigures the AAA application according to the |
| 1101 | * configuration parameters passed. |
Ray Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 1102 | * |
| 1103 | * @param cfg configuration object |
| 1104 | */ |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 1105 | private void reconfigureNetwork(AaaConfig cfg) { |
Matt Jeanneret | 2ff1a78 | 2018-06-13 15:24:25 -0400 | [diff] [blame] | 1106 | log.info("Reconfiguring AaaConfig from config: {}", cfg); |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 1107 | |
Ray Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 1108 | if (cfg == null) { |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 1109 | newCfg = new AaaConfig(); |
Ray Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 1110 | } else { |
| 1111 | newCfg = cfg; |
| 1112 | } |
| 1113 | if (newCfg.nasIp() != null) { |
| 1114 | nasIpAddress = newCfg.nasIp(); |
| 1115 | } |
| 1116 | if (newCfg.radiusIp() != null) { |
| 1117 | radiusIpAddress = newCfg.radiusIp(); |
| 1118 | } |
| 1119 | if (newCfg.radiusMac() != null) { |
| 1120 | radiusMacAddress = newCfg.radiusMac(); |
| 1121 | } |
| 1122 | if (newCfg.nasMac() != null) { |
| 1123 | nasMacAddress = newCfg.nasMac(); |
| 1124 | } |
Andrea Campanella | c4781e6 | 2020-10-08 12:58:45 +0200 | [diff] [blame] | 1125 | if (newCfg.radiusSecret() != null && !newCfg.radiusSecret().equals(radiusSecret)) { |
Ray Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 1126 | radiusSecret = newCfg.radiusSecret(); |
Andrea Campanella | c4781e6 | 2020-10-08 12:58:45 +0200 | [diff] [blame] | 1127 | radiusOperationalStatusService.initialize(nasIpAddress.getAddress(), radiusSecret, impl); |
Ray Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 1128 | } |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 1129 | |
Deepa Vaddireddy | e0e1072 | 2017-09-27 05:00:10 +0530 | [diff] [blame] | 1130 | boolean reconfigureCustomizer = false; |
| 1131 | if (customizer == null || !customizer.equals(newCfg.radiusPktCustomizer())) { |
| 1132 | customizer = newCfg.radiusPktCustomizer(); |
| 1133 | configurePacketCustomizer(); |
| 1134 | reconfigureCustomizer = true; |
| 1135 | } |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 1136 | |
Deepa Vaddireddy | e0e1072 | 2017-09-27 05:00:10 +0530 | [diff] [blame] | 1137 | if (radiusConnectionType == null |
| 1138 | || reconfigureCustomizer |
| 1139 | || !radiusConnectionType.equals(newCfg.radiusConnectionType())) { |
| 1140 | radiusConnectionType = newCfg.radiusConnectionType(); |
| 1141 | if (impl != null) { |
| 1142 | impl.withdrawIntercepts(); |
| 1143 | impl.clearLocalState(); |
| 1144 | } |
| 1145 | configureRadiusCommunication(); |
| 1146 | impl.initializeLocalState(newCfg); |
| 1147 | impl.requestIntercepts(); |
| 1148 | } else if (impl != null) { |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 1149 | impl.clearLocalState(); |
| 1150 | impl.initializeLocalState(newCfg); |
Ray Milkey | 5d99bd1 | 2015-10-06 15:41:30 -0700 | [diff] [blame] | 1151 | } |
Ray Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 1152 | } |
| 1153 | |
| 1154 | @Override |
| 1155 | public void event(NetworkConfigEvent event) { |
| 1156 | |
| 1157 | if ((event.type() == NetworkConfigEvent.Type.CONFIG_ADDED || |
| 1158 | event.type() == NetworkConfigEvent.Type.CONFIG_UPDATED) && |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 1159 | event.configClass().equals(AaaConfig.class)) { |
Ray Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 1160 | |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 1161 | AaaConfig cfg = netCfgService.getConfig(appId, AaaConfig.class); |
Ray Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 1162 | reconfigureNetwork(cfg); |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 1163 | |
Matt Jeanneret | 2ff1a78 | 2018-06-13 15:24:25 -0400 | [diff] [blame] | 1164 | log.info("Reconfigured: {}", cfg.toString()); |
Ray Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 1165 | } |
| 1166 | } |
| 1167 | } |
Amit Ghosh | f739be5 | 2017-09-21 15:49:37 +0100 | [diff] [blame] | 1168 | |
Jonathan Hart | 9d1ce80 | 2020-01-28 10:45:08 -0800 | [diff] [blame] | 1169 | private class InternalMapEventListener implements MapEventListener<ConnectPoint, AuthenticationRecord> { |
| 1170 | @Override |
| 1171 | public void event(MapEvent<ConnectPoint, AuthenticationRecord> event) { |
| 1172 | if (event.type() == MapEvent.Type.REMOVE) { |
| 1173 | // remove local state machine if user has requested remove |
| 1174 | StateMachine sm = stateMachines.remove(sessionId(event.key())); |
| 1175 | if (sm != null) { |
| 1176 | sm.stop(); |
| 1177 | } |
| 1178 | } |
| 1179 | } |
| 1180 | } |
| 1181 | |
Amit Ghosh | f739be5 | 2017-09-21 15:49:37 +0100 | [diff] [blame] | 1182 | private class InternalDeviceListener implements DeviceListener { |
| 1183 | @Override |
| 1184 | public void event(DeviceEvent event) { |
Andrea Campanella | bba3367 | 2020-02-11 14:03:01 +0100 | [diff] [blame] | 1185 | DeviceId deviceId = event.subject().id(); |
Amit Ghosh | f739be5 | 2017-09-21 15:49:37 +0100 | [diff] [blame] | 1186 | switch (event.type()) { |
| 1187 | case PORT_REMOVED: |
Amit Ghosh | f739be5 | 2017-09-21 15:49:37 +0100 | [diff] [blame] | 1188 | PortNumber portNumber = event.port().number(); |
Andrea Campanella | bba3367 | 2020-02-11 14:03:01 +0100 | [diff] [blame] | 1189 | String sessionId = deviceId.toString() + portNumber.toString(); |
Girish Kumar | 064084c | 2020-02-04 08:32:46 +0000 | [diff] [blame] | 1190 | log.debug("Received PORT_REMOVED event. Clearing AAA Session with Id {}", sessionId); |
Hardik Windlass | 75c6771 | 2020-02-21 10:57:20 +0000 | [diff] [blame] | 1191 | |
Girish Kumar | 064084c | 2020-02-04 08:32:46 +0000 | [diff] [blame] | 1192 | flushStateMachineSession(sessionId, |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 1193 | StateMachine.SessionTerminationReasons.PORT_REMOVED.getReason()); |
Kartikey Dubey | adeb26e | 2019-10-01 12:18:35 +0000 | [diff] [blame] | 1194 | |
Girish Kumar | 064084c | 2020-02-04 08:32:46 +0000 | [diff] [blame] | 1195 | break; |
Girish Kumar | 064084c | 2020-02-04 08:32:46 +0000 | [diff] [blame] | 1196 | case DEVICE_REMOVED: |
Girish Kumar | 064084c | 2020-02-04 08:32:46 +0000 | [diff] [blame] | 1197 | log.debug("Received DEVICE_REMOVED event for {}", deviceId); |
Andrea Campanella | bba3367 | 2020-02-11 14:03:01 +0100 | [diff] [blame] | 1198 | clearAllSessionStateForDevice(deviceId); |
Amit Ghosh | f739be5 | 2017-09-21 15:49:37 +0100 | [diff] [blame] | 1199 | break; |
Girish Kumar | 064084c | 2020-02-04 08:32:46 +0000 | [diff] [blame] | 1200 | |
Amit Ghosh | f739be5 | 2017-09-21 15:49:37 +0100 | [diff] [blame] | 1201 | default: |
| 1202 | return; |
| 1203 | } |
| 1204 | } |
Girish Kumar | 064084c | 2020-02-04 08:32:46 +0000 | [diff] [blame] | 1205 | |
Andrea Campanella | bba3367 | 2020-02-11 14:03:01 +0100 | [diff] [blame] | 1206 | private void clearAllSessionStateForDevice(DeviceId deviceId) { |
| 1207 | Set<String> associatedSessions = Sets.newHashSet(); |
| 1208 | for (Entry<String, StateMachine> stateMachineEntry : stateMachines.entrySet()) { |
| 1209 | ConnectPoint cp = stateMachineEntry.getValue().supplicantConnectpoint(); |
| 1210 | if (cp != null && cp.deviceId().toString().equals(deviceId.toString())) { |
| 1211 | associatedSessions.add(stateMachineEntry.getKey()); |
| 1212 | } |
| 1213 | } |
| 1214 | |
| 1215 | for (String session : associatedSessions) { |
| 1216 | log.debug("Clearing AAA Session {} associated with Removed Device", session); |
| 1217 | flushStateMachineSession(session, |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 1218 | StateMachine.SessionTerminationReasons.DEVICE_REMOVED.getReason()); |
Andrea Campanella | bba3367 | 2020-02-11 14:03:01 +0100 | [diff] [blame] | 1219 | } |
| 1220 | } |
| 1221 | |
Girish Kumar | 064084c | 2020-02-04 08:32:46 +0000 | [diff] [blame] | 1222 | private void flushStateMachineSession(String sessionId, String terminationReason) { |
| 1223 | StateMachine stateMachine = stateMachines.get(sessionId); |
Girish Kumar | e5a1aa9 | 2020-02-14 14:08:54 +0000 | [diff] [blame] | 1224 | if (stateMachine == null) { |
| 1225 | // No active AAA sessions for this UNI port |
| 1226 | log.debug("No Active AAA Session found with Id {}", sessionId); |
| 1227 | return; |
Girish Kumar | 064084c | 2020-02-04 08:32:46 +0000 | [diff] [blame] | 1228 | } |
| 1229 | |
Hardik Windlass | 9a09b83 | 2020-02-25 11:45:35 +0000 | [diff] [blame] | 1230 | authentications.remove(stateMachine.supplicantConnectpoint()); |
Girish Kumar | e5a1aa9 | 2020-02-14 14:08:54 +0000 | [diff] [blame] | 1231 | stateMachine.setSessionTerminateReason(terminationReason); |
| 1232 | |
Girish Kumar | 064084c | 2020-02-04 08:32:46 +0000 | [diff] [blame] | 1233 | //pushing captured machine stats to kafka |
| 1234 | AaaSupplicantMachineStats obj = aaaSupplicantStatsManager.getSupplicantStats(stateMachine); |
| 1235 | aaaSupplicantStatsManager.getMachineStatsDelegate() |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 1236 | .notify(new AaaMachineStatisticsEvent(AaaMachineStatisticsEvent.Type.STATS_UPDATE, obj)); |
Girish Kumar | 064084c | 2020-02-04 08:32:46 +0000 | [diff] [blame] | 1237 | StateMachine removed = stateMachines.remove(sessionId); |
Shubham Sharma | 8d7a982 | 2020-01-28 10:04:01 +0000 | [diff] [blame] | 1238 | |
Girish Kumar | 064084c | 2020-02-04 08:32:46 +0000 | [diff] [blame] | 1239 | if (removed != null) { |
| 1240 | StateMachine.deleteStateMachineMapping(removed); |
| 1241 | } |
| 1242 | } |
Amit Ghosh | f739be5 | 2017-09-21 15:49:37 +0100 | [diff] [blame] | 1243 | } |
Girish Kumar | 064084c | 2020-02-04 08:32:46 +0000 | [diff] [blame] | 1244 | |
Shubham Sharma | 4900ce6 | 2019-06-19 14:18:50 +0000 | [diff] [blame] | 1245 | private class ServerStatusChecker implements Runnable { |
| 1246 | @Override |
| 1247 | public void run() { |
Matteo Scandolo | 3498bc0 | 2020-01-08 09:54:12 -0800 | [diff] [blame] | 1248 | log.debug("Notifying RadiusOperationalStatusEvent"); |
Shubham Sharma | 4900ce6 | 2019-06-19 14:18:50 +0000 | [diff] [blame] | 1249 | radiusOperationalStatusService.checkServerOperationalStatus(); |
Matteo Scandolo | 3498bc0 | 2020-01-08 09:54:12 -0800 | [diff] [blame] | 1250 | log.trace("--POSTING--" + radiusOperationalStatusService.getRadiusServerOperationalStatus()); |
Shubham Sharma | 4900ce6 | 2019-06-19 14:18:50 +0000 | [diff] [blame] | 1251 | radiusOperationalStatusService.getRadiusOprStDelegate() |
Matteo Scandolo | e033c26 | 2020-10-14 11:37:39 -0700 | [diff] [blame^] | 1252 | .notify(new RadiusOperationalStatusEvent( |
| 1253 | RadiusOperationalStatusEvent.Type.RADIUS_OPERATIONAL_STATUS, |
| 1254 | radiusOperationalStatusService. |
| 1255 | getRadiusServerOperationalStatus())); |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 1256 | } |
Shubham Sharma | 4900ce6 | 2019-06-19 14:18:50 +0000 | [diff] [blame] | 1257 | |
| 1258 | } |
Shubham Sharma | 544ffa2 | 2020-02-13 06:41:02 +0000 | [diff] [blame] | 1259 | |
| 1260 | @Override |
| 1261 | public AaaSupplicantMachineStats getSupplicantMachineStats(String sessionId) { |
| 1262 | StateMachine aaaSupplicantMachine = stateMachines.get(sessionId); |
| 1263 | if (aaaSupplicantMachine != null) { |
| 1264 | return aaaSupplicantStatsManager.getSupplicantStats(aaaSupplicantMachine); |
| 1265 | } else { |
| 1266 | return null; |
| 1267 | } |
| 1268 | } |
Jonathan Hart | 612651f | 2019-11-25 09:21:43 -0800 | [diff] [blame] | 1269 | } |