blob: f1f5c053fae6d93cb0547dcc81c426b8c028c909 [file] [log] [blame]
Ari Saha89831742015-06-26 10:31:48 -07001/*
Amit Ghoshc9ac1e52017-07-28 12:31:18 +01002 * Copyright 2017-present Open Networking Foundation
Ari Saha89831742015-06-26 10:31:48 -07003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Matteo Scandolocf847b82019-04-26 15:00:00 -070016package org.opencord.aaa.impl;
Ari Saha89831742015-06-26 10:31:48 -070017
Shubham Sharma4900ce62019-06-19 14:18:50 +000018import com.google.common.base.Strings;
Jonathan Hart932bedc2018-07-12 13:46:09 -070019import org.apache.commons.lang3.builder.ToStringBuilder;
Jonathan Hart4731dd92018-05-02 17:30:05 -070020import org.onlab.packet.DeserializationException;
Jonathan Harta46dddf2015-06-30 15:31:20 -070021import org.onlab.packet.EAP;
22import org.onlab.packet.EAPOL;
23import org.onlab.packet.EthType;
Ari Saha89831742015-06-26 10:31:48 -070024import org.onlab.packet.Ethernet;
Ari Saha89831742015-06-26 10:31:48 -070025import org.onlab.packet.MacAddress;
Jonathan Harta46dddf2015-06-30 15:31:20 -070026import org.onlab.packet.RADIUS;
27import org.onlab.packet.RADIUSAttribute;
kartikey dubeye1545422019-05-22 12:53:45 +000028import org.onlab.util.Tools;
29import org.onosproject.cfg.ComponentConfigService;
Ari Saha89831742015-06-26 10:31:48 -070030import org.onosproject.core.ApplicationId;
31import org.onosproject.core.CoreService;
Jonathan Hart5db44532018-07-12 18:13:54 -070032import org.onosproject.event.AbstractListenerManager;
Amit Ghoshc9ac1e52017-07-28 12:31:18 +010033import org.onosproject.mastership.MastershipService;
Ari Saha89831742015-06-26 10:31:48 -070034import org.onosproject.net.ConnectPoint;
35import org.onosproject.net.DeviceId;
Ari Saha89831742015-06-26 10:31:48 -070036import org.onosproject.net.PortNumber;
Ray Milkeyfcb623d2015-10-01 16:48:18 -070037import org.onosproject.net.config.ConfigFactory;
38import org.onosproject.net.config.NetworkConfigEvent;
39import org.onosproject.net.config.NetworkConfigListener;
40import org.onosproject.net.config.NetworkConfigRegistry;
Amit Ghoshf739be52017-09-21 15:49:37 +010041import org.onosproject.net.device.DeviceEvent;
42import org.onosproject.net.device.DeviceListener;
Amit Ghoshc9ac1e52017-07-28 12:31:18 +010043import org.onosproject.net.device.DeviceService;
Ari Saha89831742015-06-26 10:31:48 -070044import org.onosproject.net.flow.DefaultTrafficTreatment;
Ari Saha89831742015-06-26 10:31:48 -070045import org.onosproject.net.flow.TrafficTreatment;
Ari Saha89831742015-06-26 10:31:48 -070046import org.onosproject.net.packet.DefaultOutboundPacket;
47import org.onosproject.net.packet.InboundPacket;
48import org.onosproject.net.packet.OutboundPacket;
49import org.onosproject.net.packet.PacketContext;
Ari Saha89831742015-06-26 10:31:48 -070050import org.onosproject.net.packet.PacketProcessor;
51import org.onosproject.net.packet.PacketService;
Matteo Scandolocf847b82019-04-26 15:00:00 -070052import org.opencord.aaa.AaaConfig;
Kartikey Dubeyadeb26e2019-10-01 12:18:35 +000053import org.opencord.aaa.AaaMachineStatisticsEvent;
54import org.opencord.aaa.AaaMachineStatisticsService;
55import org.opencord.aaa.AaaSupplicantMachineStats;
Matteo Scandolocf847b82019-04-26 15:00:00 -070056import org.opencord.aaa.AuthenticationEvent;
57import org.opencord.aaa.AuthenticationEventListener;
58import org.opencord.aaa.AuthenticationService;
kartikey dubeye1545422019-05-22 12:53:45 +000059import org.opencord.aaa.AuthenticationStatisticsEvent;
60import org.opencord.aaa.AuthenticationStatisticsService;
Matteo Scandolocf847b82019-04-26 15:00:00 -070061import org.opencord.aaa.RadiusCommunicator;
Shubham Sharma4900ce62019-06-19 14:18:50 +000062import org.opencord.aaa.RadiusOperationalStatusEvent;
63import org.opencord.aaa.RadiusOperationalStatusService;
64import org.opencord.aaa.RadiusOperationalStatusService.RadiusOperationalStatusEvaluationMode;
Matteo Scandolocf847b82019-04-26 15:00:00 -070065import org.opencord.aaa.StateMachineDelegate;
Gamze Abaka1cfdb192018-10-25 11:39:19 +000066import org.opencord.sadis.BaseInformationService;
67import org.opencord.sadis.SadisService;
68import org.opencord.sadis.SubscriberAndDeviceInformation;
kartikey dubeye1545422019-05-22 12:53:45 +000069import org.osgi.service.component.ComponentContext;
Carmelo Cascone58b53292019-09-30 12:35:31 -070070import org.osgi.service.component.annotations.Activate;
Shubham Sharma4900ce62019-06-19 14:18:50 +000071import org.osgi.service.component.annotations.Component;
72import org.osgi.service.component.annotations.Deactivate;
73import org.osgi.service.component.annotations.Modified;
74import org.osgi.service.component.annotations.Reference;
75import org.osgi.service.component.annotations.ReferenceCardinality;
Ari Saha89831742015-06-26 10:31:48 -070076import org.slf4j.Logger;
77
Shubham Sharma4900ce62019-06-19 14:18:50 +000078import javax.crypto.Mac;
79import javax.crypto.spec.SecretKeySpec;
80import java.net.InetAddress;
81import java.net.UnknownHostException;
82import java.nio.ByteBuffer;
83import java.util.Arrays;
84import java.util.Dictionary;
85import java.util.HashSet;
86import java.util.List;
87import java.util.Map;
kartikey dubeye1545422019-05-22 12:53:45 +000088import java.util.concurrent.Executors;
89import java.util.concurrent.ScheduledExecutorService;
90import java.util.concurrent.ScheduledFuture;
91import java.util.concurrent.TimeUnit;
Vijaykumar Kushwaha056e4cd2019-08-06 13:16:25 +000092
Shubham Sharma4900ce62019-06-19 14:18:50 +000093import static org.onosproject.net.config.basics.SubjectFactories.APP_SUBJECT_FACTORY;
94import static org.opencord.aaa.impl.OsgiPropertyConstants.OPERATIONAL_STATUS_SERVER_EVENT_GENERATION;
95import static org.opencord.aaa.impl.OsgiPropertyConstants.OPERATIONAL_STATUS_SERVER_EVENT_GENERATION_DEFAULT;
96import static org.opencord.aaa.impl.OsgiPropertyConstants.OPERATIONAL_STATUS_SERVER_TIMEOUT;
97import static org.opencord.aaa.impl.OsgiPropertyConstants.OPERATIONAL_STATUS_SERVER_TIMEOUT_DEFAULT;
98import static org.opencord.aaa.impl.OsgiPropertyConstants.STATISTICS_GENERATION_PERIOD;
99import static org.opencord.aaa.impl.OsgiPropertyConstants.STATISTICS_GENERATION_PERIOD_DEFAULT;
100import static org.opencord.aaa.impl.OsgiPropertyConstants.STATUS_SERVER_MODE;
101import static org.opencord.aaa.impl.OsgiPropertyConstants.STATUS_SERVER_MODE_DEFAULT;
102import static org.slf4j.LoggerFactory.getLogger;
Carmelo Cascone58b53292019-09-30 12:35:31 -0700103
Ari Saha89831742015-06-26 10:31:48 -0700104/**
Jonathan Harta46dddf2015-06-30 15:31:20 -0700105 * AAA application for ONOS.
Ari Saha89831742015-06-26 10:31:48 -0700106 */
Carmelo Cascone58b53292019-09-30 12:35:31 -0700107@Component(immediate = true, property = {
Shubham Sharma4900ce62019-06-19 14:18:50 +0000108 STATISTICS_GENERATION_PERIOD + ":Integer=" + STATISTICS_GENERATION_PERIOD_DEFAULT,
109 OPERATIONAL_STATUS_SERVER_EVENT_GENERATION + ":Integer=" + OPERATIONAL_STATUS_SERVER_EVENT_GENERATION_DEFAULT,
110 OPERATIONAL_STATUS_SERVER_TIMEOUT + ":Integer=" + OPERATIONAL_STATUS_SERVER_TIMEOUT_DEFAULT,
111 STATUS_SERVER_MODE + ":String=" + STATUS_SERVER_MODE_DEFAULT,
Carmelo Cascone58b53292019-09-30 12:35:31 -0700112})
Jonathan Hart5db44532018-07-12 18:13:54 -0700113public class AaaManager
114 extends AbstractListenerManager<AuthenticationEvent, AuthenticationEventListener>
115 implements AuthenticationService {
116
Charles Chandf7ff862017-01-20 11:22:05 -0800117 private static final String APP_NAME = "org.opencord.aaa";
Ray Milkeyf51eba22015-09-25 10:24:23 -0700118
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700119 private final Logger log = getLogger(getClass());
Ray Milkeyf51eba22015-09-25 10:24:23 -0700120
Carmelo Cascone58b53292019-09-30 12:35:31 -0700121 @Reference(cardinality = ReferenceCardinality.MANDATORY)
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700122 protected CoreService coreService;
Ray Milkeyf51eba22015-09-25 10:24:23 -0700123
Carmelo Cascone58b53292019-09-30 12:35:31 -0700124 @Reference(cardinality = ReferenceCardinality.MANDATORY)
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700125 protected PacketService packetService;
Ray Milkeyf51eba22015-09-25 10:24:23 -0700126
Carmelo Cascone58b53292019-09-30 12:35:31 -0700127 @Reference(cardinality = ReferenceCardinality.MANDATORY)
Ray Milkeyfcb623d2015-10-01 16:48:18 -0700128 protected NetworkConfigRegistry netCfgService;
Ray Milkeyf51eba22015-09-25 10:24:23 -0700129
Carmelo Cascone58b53292019-09-30 12:35:31 -0700130 @Reference(cardinality = ReferenceCardinality.MANDATORY)
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100131 protected DeviceService deviceService;
132
Carmelo Cascone58b53292019-09-30 12:35:31 -0700133 @Reference(cardinality = ReferenceCardinality.MANDATORY)
Gamze Abaka1cfdb192018-10-25 11:39:19 +0000134 protected SadisService sadisService;
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100135
Carmelo Cascone58b53292019-09-30 12:35:31 -0700136 @Reference(cardinality = ReferenceCardinality.MANDATORY)
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100137 protected MastershipService mastershipService;
138
Carmelo Cascone58b53292019-09-30 12:35:31 -0700139 @Reference(cardinality = ReferenceCardinality.MANDATORY)
kartikey dubeye1545422019-05-22 12:53:45 +0000140 protected AuthenticationStatisticsService aaaStatisticsManager;
Gamze Abaka1cfdb192018-10-25 11:39:19 +0000141
Carmelo Cascone58b53292019-09-30 12:35:31 -0700142 @Reference(cardinality = ReferenceCardinality.MANDATORY)
Kartikey Dubeyadeb26e2019-10-01 12:18:35 +0000143 protected AaaMachineStatisticsService aaaSupplicantStatsManager;
144
145 @Reference(cardinality = ReferenceCardinality.MANDATORY)
kartikey dubeye1545422019-05-22 12:53:45 +0000146 protected ComponentConfigService cfgService;
147
Shubham Sharma4900ce62019-06-19 14:18:50 +0000148 @Reference(cardinality = ReferenceCardinality.MANDATORY)
149 protected RadiusOperationalStatusService radiusOperationalStatusService;
150
kartikey dubeye1545422019-05-22 12:53:45 +0000151 protected AuthenticationStatisticsEventPublisher authenticationStatisticsPublisher;
152 protected BaseInformationService<SubscriberAndDeviceInformation> subsService;
Amit Ghoshf739be52017-09-21 15:49:37 +0100153 private final DeviceListener deviceListener = new InternalDeviceListener();
154
Shubham Sharma4900ce62019-06-19 14:18:50 +0000155 // Properties
156 private int statisticsGenerationPeriodInSeconds = STATISTICS_GENERATION_PERIOD_DEFAULT;
157 private int operationalStatusEventGenerationPeriodInSeconds = OPERATIONAL_STATUS_SERVER_EVENT_GENERATION_DEFAULT;
158 private int operationalStatusServerTimeoutInSeconds = OPERATIONAL_STATUS_SERVER_TIMEOUT_DEFAULT;
159 protected String operationalStatusEvaluationMode = STATUS_SERVER_MODE_DEFAULT;
kartikey dubeye1545422019-05-22 12:53:45 +0000160
Ray Milkeyfcb623d2015-10-01 16:48:18 -0700161 // NAS IP address
162 protected InetAddress nasIpAddress;
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100163
164 // self MAC address
Jonathan Hart5db44532018-07-12 18:13:54 -0700165 protected String nasMacAddress;
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100166
167 // Parsed RADIUS server addresses
168 protected InetAddress radiusIpAddress;
169
170 // MAC address of RADIUS server or net hop router
171 protected String radiusMacAddress;
Ray Milkeyfcb623d2015-10-01 16:48:18 -0700172
173 // RADIUS server secret
174 protected String radiusSecret;
175
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100176 // bindings
177 protected CustomizationInfo customInfo;
Ray Milkey5d99bd12015-10-06 15:41:30 -0700178
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700179 // our application-specific event handler
180 private ReactivePacketProcessor processor = new ReactivePacketProcessor();
Ray Milkeyf51eba22015-09-25 10:24:23 -0700181
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700182 // our unique identifier
183 private ApplicationId appId;
Ray Milkeyf51eba22015-09-25 10:24:23 -0700184
Shubham Sharma1e43c562019-06-19 14:18:12 +0000185 // TimeOut time for cleaning up stateMachines stuck due to pending AAA/EAPOL message.
186 protected int cleanupTimerTimeOutInMins;
187
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100188 // Setup specific customization/attributes on the RADIUS packets
189 PacketCustomizer pktCustomizer;
Ray Milkey967776a2015-10-07 14:37:17 -0700190
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100191 // packet customizer to use
192 private String customizer;
193
194 // Type of connection to use to communicate with Radius server, options are
195 // "socket" or "packet_out"
196 private String radiusConnectionType;
197
Jonathan Hart5db44532018-07-12 18:13:54 -0700198 // Object for the specific type of communication with the RADIUS
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100199 // server, socket based or packet_out based
200 RadiusCommunicator impl = null;
201
202 // latest configuration
203 AaaConfig newCfg;
Ray Milkey967776a2015-10-07 14:37:17 -0700204
kartikey dubeye1545422019-05-22 12:53:45 +0000205 ScheduledFuture<?> scheduledFuture;
Shubham Sharma4900ce62019-06-19 14:18:50 +0000206 ScheduledFuture<?> scheduledStatusServerChecker;
kartikey dubeye1545422019-05-22 12:53:45 +0000207 ScheduledExecutorService executor;
208 String configuredAaaServerAddress;
209 HashSet<Byte> outPacketSet = new HashSet<Byte>();
Shubham Sharma3c8c7022019-09-13 10:39:47 +0000210 HashSet<Byte> outPacketSupp = new HashSet<Byte>();
211 static final List<Byte> VALID_EAPOL_TYPE = Arrays.asList(EAPOL.EAPOL_START, EAPOL.EAPOL_LOGOFF, EAPOL.EAPOL_PACKET);
212 static final int HEADER_LENGTH = 4;
Ray Milkeyfcb623d2015-10-01 16:48:18 -0700213 // Configuration properties factory
214 private final ConfigFactory factory =
Jonathan Hart092dfb22015-11-16 23:05:21 -0800215 new ConfigFactory<ApplicationId, AaaConfig>(APP_SUBJECT_FACTORY,
216 AaaConfig.class,
Ray Milkeyfcb623d2015-10-01 16:48:18 -0700217 "AAA") {
218 @Override
Jonathan Hart092dfb22015-11-16 23:05:21 -0800219 public AaaConfig createConfig() {
220 return new AaaConfig();
Ray Milkeyfcb623d2015-10-01 16:48:18 -0700221 }
222 };
Ray Milkeyf51eba22015-09-25 10:24:23 -0700223
Ray Milkeyfcb623d2015-10-01 16:48:18 -0700224 // Listener for config changes
225 private final InternalConfigListener cfgListener = new InternalConfigListener();
Ari Saha89831742015-06-26 10:31:48 -0700226
Jonathan Hart5db44532018-07-12 18:13:54 -0700227 private StateMachineDelegate delegate = new InternalStateMachineDelegate();
228
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700229 /**
230 * Builds an EAPOL packet based on the given parameters.
231 *
232 * @param dstMac destination MAC address
233 * @param srcMac source MAC address
234 * @param vlan vlan identifier
235 * @param eapolType EAPOL type
236 * @param eap EAP payload
237 * @return Ethernet frame
238 */
239 private static Ethernet buildEapolResponse(MacAddress dstMac, MacAddress srcMac,
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100240 short vlan, byte eapolType, EAP eap, byte priorityCode) {
Ari Saha89831742015-06-26 10:31:48 -0700241
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700242 Ethernet eth = new Ethernet();
243 eth.setDestinationMACAddress(dstMac.toBytes());
244 eth.setSourceMACAddress(srcMac.toBytes());
245 eth.setEtherType(EthType.EtherType.EAPOL.ethType().toShort());
246 if (vlan != Ethernet.VLAN_UNTAGGED) {
247 eth.setVlanID(vlan);
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100248 eth.setPriorityCode(priorityCode);
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700249 }
250 //eapol header
251 EAPOL eapol = new EAPOL();
252 eapol.setEapolType(eapolType);
253 eapol.setPacketLength(eap.getLength());
Ari Saha89831742015-06-26 10:31:48 -0700254
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700255 //eap part
256 eapol.setPayload(eap);
257
258 eth.setPayload(eapol);
259 eth.setPad(true);
260 return eth;
261 }
Ari Saha89831742015-06-26 10:31:48 -0700262
Ari Saha89831742015-06-26 10:31:48 -0700263 @Activate
kartikey dubeye1545422019-05-22 12:53:45 +0000264 public void activate(ComponentContext context) {
Charles Chandf7ff862017-01-20 11:22:05 -0800265 appId = coreService.registerApplication(APP_NAME);
Jonathan Hart5db44532018-07-12 18:13:54 -0700266 eventDispatcher.addSink(AuthenticationEvent.class, listenerRegistry);
Matt Jeanneret2ff1a782018-06-13 15:24:25 -0400267 netCfgService.addListener(cfgListener);
268 netCfgService.registerConfigFactory(factory);
kartikey dubeye1545422019-05-22 12:53:45 +0000269 cfgService.registerProperties(getClass());
270 modified(context);
Gamze Abaka1cfdb192018-10-25 11:39:19 +0000271 subsService = sadisService.getSubscriberInfoService();
Deepa Vaddireddye0e10722017-09-27 05:00:10 +0530272 customInfo = new CustomizationInfo(subsService, deviceService);
Jonathan Hart092dfb22015-11-16 23:05:21 -0800273 cfgListener.reconfigureNetwork(netCfgService.getConfig(appId, AaaConfig.class));
Matt Jeanneret2ff1a782018-06-13 15:24:25 -0400274 log.info("Starting with config {} {}", this, newCfg);
Deepa Vaddireddye0e10722017-09-27 05:00:10 +0530275 configureRadiusCommunication();
Ari Saha89831742015-06-26 10:31:48 -0700276 // register our event handler
Brian O'Connord9c7da02015-07-29 17:49:24 -0700277 packetService.addProcessor(processor, PacketProcessor.director(2));
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700278 StateMachine.initializeMaps();
Jonathan Hart5db44532018-07-12 18:13:54 -0700279 StateMachine.setDelegate(delegate);
Shubham Sharma1e43c562019-06-19 14:18:12 +0000280 cleanupTimerTimeOutInMins = newCfg.sessionCleanupTimer();
281 StateMachine.setcleanupTimerTimeOutInMins(cleanupTimerTimeOutInMins);
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100282 impl.initializeLocalState(newCfg);
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100283 impl.requestIntercepts();
Amit Ghoshf739be52017-09-21 15:49:37 +0100284 deviceService.addListener(deviceListener);
kartikey dubeye1545422019-05-22 12:53:45 +0000285 getConfiguredAaaServerAddress();
Shubham Sharma4900ce62019-06-19 14:18:50 +0000286 radiusOperationalStatusService.initialize(nasIpAddress.getAddress(), radiusSecret, impl);
kartikey dubeye1545422019-05-22 12:53:45 +0000287 authenticationStatisticsPublisher =
288 new AuthenticationStatisticsEventPublisher();
Shubham Sharma4900ce62019-06-19 14:18:50 +0000289 executor = Executors.newScheduledThreadPool(3);
290
kartikey dubeye1545422019-05-22 12:53:45 +0000291 scheduledFuture = executor.scheduleAtFixedRate(authenticationStatisticsPublisher,
Shubham Sharma4900ce62019-06-19 14:18:50 +0000292 0, statisticsGenerationPeriodInSeconds, TimeUnit.SECONDS);
293 scheduledStatusServerChecker = executor.scheduleAtFixedRate(new ServerStatusChecker(), 0,
294 operationalStatusEventGenerationPeriodInSeconds, TimeUnit.SECONDS);
Amit Ghoshf739be52017-09-21 15:49:37 +0100295
Jian Li13c67162015-12-09 13:20:34 -0800296 log.info("Started");
Ari Saha89831742015-06-26 10:31:48 -0700297 }
298
299 @Deactivate
kartikey dubeye1545422019-05-22 12:53:45 +0000300 public void deactivate(ComponentContext context) {
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100301 impl.withdrawIntercepts();
Ari Saha89831742015-06-26 10:31:48 -0700302 packetService.removeProcessor(processor);
Deepa Vaddireddyb9c24c62017-09-21 13:45:30 +0530303 netCfgService.removeListener(cfgListener);
kartikey dubeye1545422019-05-22 12:53:45 +0000304 cfgService.unregisterProperties(getClass(), false);
Jonathan Hart5db44532018-07-12 18:13:54 -0700305 StateMachine.unsetDelegate(delegate);
Deepa Vaddireddye0e10722017-09-27 05:00:10 +0530306 StateMachine.destroyMaps();
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100307 impl.deactivate();
Amit Ghoshf739be52017-09-21 15:49:37 +0100308 deviceService.removeListener(deviceListener);
Jonathan Hart5db44532018-07-12 18:13:54 -0700309 eventDispatcher.removeSink(AuthenticationEvent.class);
kartikey dubeye1545422019-05-22 12:53:45 +0000310 scheduledFuture.cancel(true);
Shubham Sharma4900ce62019-06-19 14:18:50 +0000311 scheduledStatusServerChecker.cancel(true);
kartikey dubeye1545422019-05-22 12:53:45 +0000312 executor.shutdown();
Jian Li13c67162015-12-09 13:20:34 -0800313 log.info("Stopped");
Ray Milkey967776a2015-10-07 14:37:17 -0700314 }
kartikey dubeye1545422019-05-22 12:53:45 +0000315 @Modified
316 public void modified(ComponentContext context) {
Shubham Sharma4900ce62019-06-19 14:18:50 +0000317 Dictionary<String, Object> properties = context.getProperties();
318
319 String s = Tools.get(properties, "statisticsGenerationPeriodInSeconds");
320 statisticsGenerationPeriodInSeconds = Strings.isNullOrEmpty(s) ? STATISTICS_GENERATION_PERIOD_DEFAULT
321 : Integer.parseInt(s.trim());
322
323 s = Tools.get(properties, "operationalStatusEventGenerationPeriodInSeconds");
324 operationalStatusEventGenerationPeriodInSeconds = Strings.isNullOrEmpty(s)
325 ? OPERATIONAL_STATUS_SERVER_EVENT_GENERATION_DEFAULT
326 : Integer.parseInt(s.trim());
327
328 s = Tools.get(properties, "operationalStatusServerTimeoutInSeconds");
329 operationalStatusServerTimeoutInSeconds = Strings.isNullOrEmpty(s) ? OPERATIONAL_STATUS_SERVER_TIMEOUT_DEFAULT
330 : Integer.parseInt(s.trim());
331
332 s = Tools.get(properties, "operationalStatusEvaluationMode");
333 String newEvaluationModeString = Strings.isNullOrEmpty(s) ? STATUS_SERVER_MODE_DEFAULT : s.trim();
334
335 radiusOperationalStatusService
336 .setOperationalStatusServerTimeoutInMillis(operationalStatusServerTimeoutInSeconds * 1000);
337 RadiusOperationalStatusEvaluationMode newEvaluationMode =
338 RadiusOperationalStatusEvaluationMode.getValue(newEvaluationModeString);
339 if (newEvaluationMode != null) {
340 radiusOperationalStatusService.setRadiusOperationalStatusEvaluationMode(newEvaluationMode);
341 operationalStatusEvaluationMode = newEvaluationModeString;
342 } else {
343 properties.put("operationalStatusEvaluationMode", operationalStatusEvaluationMode);
344 }
kartikey dubeye1545422019-05-22 12:53:45 +0000345 }
346
Shubham Sharmacf5e5032019-11-26 11:09:21 +0000347 protected void configureRadiusCommunication() {
Deepa Vaddireddye0e10722017-09-27 05:00:10 +0530348 if (radiusConnectionType.toLowerCase().equals("socket")) {
349 impl = new SocketBasedRadiusCommunicator(appId, packetService, this);
350 } else {
351 impl = new PortBasedRadiusCommunicator(appId, packetService, mastershipService,
352 deviceService, subsService, pktCustomizer, this);
353 }
354 }
355
356 private void configurePacketCustomizer() {
357 switch (customizer.toLowerCase()) {
358 case "sample":
359 pktCustomizer = new SamplePacketCustomizer(customInfo);
360 log.info("Created SamplePacketCustomizer");
361 break;
Saurav Dase72358a2018-11-13 21:56:46 -0800362 case "att":
363 pktCustomizer = new AttPacketCustomizer(customInfo);
364 log.info("Created AttPacketCustomizer");
365 break;
Deepa Vaddireddye0e10722017-09-27 05:00:10 +0530366 default:
367 pktCustomizer = new PacketCustomizer(customInfo);
368 log.info("Created default PacketCustomizer");
369 break;
370 }
371 }
372
kartikey dubeye1545422019-05-22 12:53:45 +0000373 private void getConfiguredAaaServerAddress() {
374 try {
375 InetAddress address;
376 if (newCfg.radiusHostName() != null) {
377 address = InetAddress.getByName(newCfg.radiusHostName());
378 } else {
379 address = newCfg.radiusIp();
380 }
381
382 configuredAaaServerAddress = address.getHostAddress();
383 } catch (UnknownHostException uhe) {
384 log.warn("Unable to resolve host {}", newCfg.radiusHostName());
385 }
386 }
387
Vijaykumar Kushwaha056e4cd2019-08-06 13:16:25 +0000388 private void checkReceivedPacketForValidValidator(RADIUS radiusPacket, byte[] requestAuthenticator) {
389 if (!checkResponseMessageAuthenticator(radiusSecret, radiusPacket, requestAuthenticator)) {
kartikey dubeye1545422019-05-22 12:53:45 +0000390 aaaStatisticsManager.getAaaStats().increaseInvalidValidatorsRx();
391 }
392 }
Vijaykumar Kushwaha056e4cd2019-08-06 13:16:25 +0000393
394 private boolean checkResponseMessageAuthenticator(String key, RADIUS radiusPacket, byte[] requestAuthenticator) {
395 byte[] newHash = new byte[16];
396 Arrays.fill(newHash, (byte) 0);
397 byte[] messageAuthenticator = radiusPacket.getAttribute(RADIUSAttribute.RADIUS_ATTR_MESSAGE_AUTH).getValue();
398 byte[] authenticator = radiusPacket.getAuthenticator();
399 radiusPacket.updateAttribute(RADIUSAttribute.RADIUS_ATTR_MESSAGE_AUTH, newHash);
400 radiusPacket.setAuthenticator(requestAuthenticator);
401 // Calculate the MD5 HMAC based on the message
402 try {
403 SecretKeySpec keySpec = new SecretKeySpec(key.getBytes(), "HmacMD5");
404 Mac mac = Mac.getInstance("HmacMD5");
405 mac.init(keySpec);
406 newHash = mac.doFinal(radiusPacket.serialize());
407 } catch (Exception e) {
408 log.error("Failed to generate message authenticator: {}", e.getMessage());
409 }
410 radiusPacket.updateAttribute(RADIUSAttribute.RADIUS_ATTR_MESSAGE_AUTH, messageAuthenticator);
411 radiusPacket.setAuthenticator(authenticator);
412 // Compare the calculated Message-Authenticator with the one in the message
413 return Arrays.equals(newHash, messageAuthenticator);
414 }
kartikey dubeye1545422019-05-22 12:53:45 +0000415 public void checkForPacketFromUnknownServer(String hostAddress) {
416 if (!hostAddress.equals(configuredAaaServerAddress)) {
Vijaykumar Kushwahafffd3d12019-08-01 11:09:59 +0000417 getConfiguredAaaServerAddress();
418 if (!hostAddress.equals(configuredAaaServerAddress)) {
419 aaaStatisticsManager.getAaaStats().incrementUnknownServerRx();
420 }
kartikey dubeye1545422019-05-22 12:53:45 +0000421 }
422 }
423
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100424 /**
425 * Send RADIUS packet to the RADIUS server.
426 *
427 * @param radiusPacket RADIUS packet to be sent to server.
428 * @param inPkt Incoming EAPOL packet
429 */
430 protected void sendRadiusPacket(RADIUS radiusPacket, InboundPacket inPkt) {
kartikey dubeye1545422019-05-22 12:53:45 +0000431 outPacketSet.add(radiusPacket.getIdentifier());
432 aaaStatisticsManager.getAaaStats().increaseOrDecreasePendingRequests(true);
433 aaaStatisticsManager.getAaaStats().increaseAccessRequestsTx();
Shubham Sharma4900ce62019-06-19 14:18:50 +0000434 aaaStatisticsManager.putOutgoingIdentifierToMap(radiusPacket.getIdentifier());
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100435 impl.sendRadiusPacket(radiusPacket, inPkt);
436 }
Ray Milkey967776a2015-10-07 14:37:17 -0700437
Shubham Sharma1e43c562019-06-19 14:18:12 +0000438 /**
439 * For scheduling the timer required for cleaning up StateMachine
440 * when no response
441 * from RADIUS SERVER.
442 *
443 * @param sessionId SessionId of the current session
444 * @param stateMachine StateMachine for the id
445 */
446 public void scheduleStateMachineCleanupTimer(String sessionId, StateMachine stateMachine) {
447 StateMachine.CleanupTimerTask cleanupTask = stateMachine.new CleanupTimerTask(sessionId, this);
448 ScheduledFuture<?> cleanupTimer = executor.schedule(cleanupTask, cleanupTimerTimeOutInMins, TimeUnit.MINUTES);
449 stateMachine.setCleanupTimer(cleanupTimer);
450
451 }
452
453 /**
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100454 * Handles RADIUS packets.
455 *
456 * @param radiusPacket RADIUS packet coming from the RADIUS server.
457 * @throws StateMachineException if an illegal state transition is triggered
Jonathan Hart4731dd92018-05-02 17:30:05 -0700458 * @throws DeserializationException if packet deserialization fails
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100459 */
Jonathan Hart4731dd92018-05-02 17:30:05 -0700460 public void handleRadiusPacket(RADIUS radiusPacket)
461 throws StateMachineException, DeserializationException {
Saurav Das987441a2018-09-18 16:33:47 -0700462 if (log.isTraceEnabled()) {
463 log.trace("Received RADIUS packet {}", radiusPacket);
464 }
Shubham Sharma4900ce62019-06-19 14:18:50 +0000465 if (radiusOperationalStatusService.isRadiusResponseForOperationalStatus(radiusPacket.getIdentifier())) {
466 radiusOperationalStatusService.handleRadiusPacketForOperationalStatus(radiusPacket);
467 return;
468 }
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100469 StateMachine stateMachine = StateMachine.lookupStateMachineById(radiusPacket.getIdentifier());
470 if (stateMachine == null) {
Saurav Das987441a2018-09-18 16:33:47 -0700471 log.error("Invalid packet identifier {}, could not find corresponding "
472 + "state machine ... exiting", radiusPacket.getIdentifier());
kartikey dubeye1545422019-05-22 12:53:45 +0000473 aaaStatisticsManager.getAaaStats().incrementNumberOfSessionsExpired();
474 aaaStatisticsManager.getAaaStats().countDroppedResponsesRx();
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100475 return;
Ray Milkey967776a2015-10-07 14:37:17 -0700476 }
Kartikey Dubeyadeb26e2019-10-01 12:18:35 +0000477
478 //instance of StateMachine using the sessionId for updating machine stats
479 StateMachine machineStats = StateMachine.lookupStateMachineBySessionId(stateMachine.sessionId());
480
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100481 EAP eapPayload;
482 Ethernet eth;
Vijaykumar Kushwaha056e4cd2019-08-06 13:16:25 +0000483 checkReceivedPacketForValidValidator(radiusPacket, stateMachine.requestAuthenticator());
Kartikey Dubeyadeb26e2019-10-01 12:18:35 +0000484
485 //increasing packets and octets received from server
486 machineStats.incrementTotalPacketsReceived();
487 machineStats.incrementTotalOctetReceived(radiusPacket.decapsulateMessage().getLength());
488
kartikey dubeye1545422019-05-22 12:53:45 +0000489 if (outPacketSet.contains(radiusPacket.getIdentifier())) {
490 aaaStatisticsManager.getAaaStats().increaseOrDecreasePendingRequests(false);
491 outPacketSet.remove(new Byte(radiusPacket.getIdentifier()));
492 }
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100493 switch (radiusPacket.getCode()) {
494 case RADIUS.RADIUS_CODE_ACCESS_CHALLENGE:
Matt Jeanneret2ff1a782018-06-13 15:24:25 -0400495 log.debug("RADIUS packet: RADIUS_CODE_ACCESS_CHALLENGE");
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100496 RADIUSAttribute radiusAttrState = radiusPacket.getAttribute(RADIUSAttribute.RADIUS_ATTR_STATE);
497 byte[] challengeState = null;
498 if (radiusAttrState != null) {
499 challengeState = radiusAttrState.getValue();
500 }
501 eapPayload = radiusPacket.decapsulateMessage();
502 stateMachine.setChallengeInfo(eapPayload.getIdentifier(), challengeState);
503 eth = buildEapolResponse(stateMachine.supplicantAddress(),
504 MacAddress.valueOf(nasMacAddress),
505 stateMachine.vlanId(),
506 EAPOL.EAPOL_PACKET,
507 eapPayload, stateMachine.priorityCode());
Matt Jeanneret2ff1a782018-06-13 15:24:25 -0400508 log.debug("Send EAP challenge response to supplicant {}", stateMachine.supplicantAddress().toString());
Shubham Sharma1f193582019-07-11 12:12:41 +0000509 sendPacketToSupplicant(eth, stateMachine.supplicantConnectpoint(), true);
kartikey dubeye1545422019-05-22 12:53:45 +0000510 aaaStatisticsManager.getAaaStats().increaseChallengeResponsesRx();
Shubham Sharma3c8c7022019-09-13 10:39:47 +0000511 outPacketSupp.add(eapPayload.getIdentifier());
512 aaaStatisticsManager.getAaaStats().incrementPendingResSupp();
Kartikey Dubeyadeb26e2019-10-01 12:18:35 +0000513 //increasing packets send to server
514 machineStats.incrementTotalPacketsSent();
515 machineStats.incrementTotalOctetSent(eapPayload.getLength());
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100516 break;
517 case RADIUS.RADIUS_CODE_ACCESS_ACCEPT:
Matt Jeanneret2ff1a782018-06-13 15:24:25 -0400518 log.debug("RADIUS packet: RADIUS_CODE_ACCESS_ACCEPT");
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100519 //send an EAPOL - Success to the supplicant.
520 byte[] eapMessageSuccess =
521 radiusPacket.getAttribute(RADIUSAttribute.RADIUS_ATTR_EAP_MESSAGE).getValue();
Jonathan Hart4731dd92018-05-02 17:30:05 -0700522 eapPayload = EAP.deserializer().deserialize(
523 eapMessageSuccess, 0, eapMessageSuccess.length);
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100524 eth = buildEapolResponse(stateMachine.supplicantAddress(),
525 MacAddress.valueOf(nasMacAddress),
526 stateMachine.vlanId(),
527 EAPOL.EAPOL_PACKET,
528 eapPayload, stateMachine.priorityCode());
Matt Jeanneret2ff1a782018-06-13 15:24:25 -0400529 log.info("Send EAP success message to supplicant {}", stateMachine.supplicantAddress().toString());
Shubham Sharma1f193582019-07-11 12:12:41 +0000530 sendPacketToSupplicant(eth, stateMachine.supplicantConnectpoint(), false);
531 aaaStatisticsManager.getAaaStats().incrementEapolAuthSuccessTrans();
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100532
533 stateMachine.authorizeAccess();
kartikey dubeye1545422019-05-22 12:53:45 +0000534 aaaStatisticsManager.getAaaStats().increaseAcceptResponsesRx();
Kartikey Dubeyadeb26e2019-10-01 12:18:35 +0000535 //increasing packets send to server
536 machineStats.incrementTotalPacketsSent();
537 machineStats.incrementTotalOctetSent(eapPayload.getLength());
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100538 break;
539 case RADIUS.RADIUS_CODE_ACCESS_REJECT:
Matt Jeanneret2ff1a782018-06-13 15:24:25 -0400540 log.debug("RADIUS packet: RADIUS_CODE_ACCESS_REJECT");
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100541 //send an EAPOL - Failure to the supplicant.
542 byte[] eapMessageFailure;
543 eapPayload = new EAP();
544 RADIUSAttribute radiusAttrEap = radiusPacket.getAttribute(RADIUSAttribute.RADIUS_ATTR_EAP_MESSAGE);
545 if (radiusAttrEap == null) {
546 eapPayload.setCode(EAP.FAILURE);
547 eapPayload.setIdentifier(stateMachine.challengeIdentifier());
548 eapPayload.setLength(EAP.EAP_HDR_LEN_SUC_FAIL);
549 } else {
550 eapMessageFailure = radiusAttrEap.getValue();
Jonathan Hart4731dd92018-05-02 17:30:05 -0700551 eapPayload = EAP.deserializer().deserialize(
552 eapMessageFailure, 0, eapMessageFailure.length);
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100553 }
554 eth = buildEapolResponse(stateMachine.supplicantAddress(),
555 MacAddress.valueOf(nasMacAddress),
556 stateMachine.vlanId(),
557 EAPOL.EAPOL_PACKET,
558 eapPayload, stateMachine.priorityCode());
Matt Jeanneret2ff1a782018-06-13 15:24:25 -0400559 log.warn("Send EAP failure message to supplicant {}", stateMachine.supplicantAddress().toString());
Shubham Sharma1f193582019-07-11 12:12:41 +0000560 sendPacketToSupplicant(eth, stateMachine.supplicantConnectpoint(), false);
561 aaaStatisticsManager.getAaaStats().incrementEapolauthFailureTrans();
562
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100563 stateMachine.denyAccess();
kartikey dubeye1545422019-05-22 12:53:45 +0000564 aaaStatisticsManager.getAaaStats().increaseRejectResponsesRx();
Kartikey Dubeyadeb26e2019-10-01 12:18:35 +0000565 //increasing packets send to server
566 machineStats.incrementTotalPacketsSent();
567 machineStats.incrementTotalOctetSent(eapPayload.getLength());
568 //pushing machine stats to kafka
569 AaaSupplicantMachineStats machineObj = aaaSupplicantStatsManager.getSupplicantStats(machineStats);
570 aaaSupplicantStatsManager.getMachineStatsDelegate()
571 .notify(new AaaMachineStatisticsEvent(AaaMachineStatisticsEvent.Type.STATS_UPDATE, machineObj));
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100572 break;
573 default:
574 log.warn("Unknown RADIUS message received with code: {}", radiusPacket.getCode());
kartikey dubeye1545422019-05-22 12:53:45 +0000575 aaaStatisticsManager.getAaaStats().increaseUnknownTypeRx();
Kartikey Dubeyadeb26e2019-10-01 12:18:35 +0000576 //increasing packets received to server
577 machineStats.incrementTotalPacketsReceived();
578 machineStats.incrementTotalOctetReceived(radiusPacket.decapsulateMessage().getLength());
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100579 }
kartikey dubeye1545422019-05-22 12:53:45 +0000580 aaaStatisticsManager.getAaaStats().countDroppedResponsesRx();
Aaron Kruglikovd39d99e2015-07-03 13:30:57 -0700581 }
582
Ray Milkey967776a2015-10-07 14:37:17 -0700583 /**
584 * Send the ethernet packet to the supplicant.
585 *
586 * @param ethernetPkt the ethernet packet
587 * @param connectPoint the connect point to send out
588 */
Shubham Sharma1f193582019-07-11 12:12:41 +0000589 private void sendPacketToSupplicant(Ethernet ethernetPkt, ConnectPoint connectPoint, boolean isChallengeResponse) {
Ray Milkey967776a2015-10-07 14:37:17 -0700590 TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(connectPoint.port()).build();
591 OutboundPacket packet = new DefaultOutboundPacket(connectPoint.deviceId(),
592 treatment, ByteBuffer.wrap(ethernetPkt.serialize()));
Shubham Sharma1f193582019-07-11 12:12:41 +0000593 EAPOL eap = ((EAPOL) ethernetPkt.getPayload());
594 EAP eapPkt = (EAP) eap.getPayload();
Saurav Das987441a2018-09-18 16:33:47 -0700595 if (log.isTraceEnabled()) {
Saurav Das987441a2018-09-18 16:33:47 -0700596 log.trace("Sending eapol payload {} enclosed in {} to supplicant at {}",
597 eap, ethernetPkt, connectPoint);
598 }
Ray Milkey967776a2015-10-07 14:37:17 -0700599 packetService.emit(packet);
Shubham Sharma1f193582019-07-11 12:12:41 +0000600 if (isChallengeResponse) {
601 aaaStatisticsManager.getAaaStats().incrementEapPktTxauthEap();
602 }
Shubham Sharma3c8c7022019-09-13 10:39:47 +0000603 aaaStatisticsManager.getAaaStats().incrementEapolFramesTx();
604 aaaStatisticsManager.getAaaStats().countReqEapFramesTx();
Ray Milkey967776a2015-10-07 14:37:17 -0700605 }
606
Matt Jeanneret2ff1a782018-06-13 15:24:25 -0400607 @Override
608 public String toString() {
609 return ToStringBuilder.reflectionToString(this);
610 }
611
Ari Saha89831742015-06-26 10:31:48 -0700612 // our handler defined as a private inner class
613
614 /**
615 * Packet processor responsible for forwarding packets along their paths.
616 */
617 private class ReactivePacketProcessor implements PacketProcessor {
618 @Override
619 public void process(PacketContext context) {
620
621 // Extract the original Ethernet frame from the packet information
622 InboundPacket pkt = context.inPacket();
623 Ethernet ethPkt = pkt.parsed();
624 if (ethPkt == null) {
625 return;
626 }
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100627
Ray Milkeyf51eba22015-09-25 10:24:23 -0700628 try {
629 // identify if incoming packet comes from supplicant (EAP) or RADIUS
630 switch (EthType.EtherType.lookup(ethPkt.getEtherType())) {
631 case EAPOL:
632 handleSupplicantPacket(context.inPacket());
633 break;
Ray Milkeyf51eba22015-09-25 10:24:23 -0700634 default:
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100635 // any other packets let the specific implementation handle
636 impl.handlePacketFromServer(context);
Ray Milkeyf51eba22015-09-25 10:24:23 -0700637 }
Ray Milkey967776a2015-10-07 14:37:17 -0700638 } catch (StateMachineException e) {
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100639 log.warn("Unable to process packet:", e);
Ari Saha89831742015-06-26 10:31:48 -0700640 }
641 }
642
Ray Milkey9eb293f2015-09-30 15:09:17 -0700643 /**
644 * Creates and initializes common fields of a RADIUS packet.
645 *
Ray Milkey967776a2015-10-07 14:37:17 -0700646 * @param stateMachine state machine for the request
Ray Milkeyfcb623d2015-10-01 16:48:18 -0700647 * @param eapPacket EAP packet
Ray Milkey9eb293f2015-09-30 15:09:17 -0700648 * @return RADIUS packet
649 */
Ray Milkey967776a2015-10-07 14:37:17 -0700650 private RADIUS getRadiusPayload(StateMachine stateMachine, byte identifier, EAP eapPacket) {
Ray Milkey9eb293f2015-09-30 15:09:17 -0700651 RADIUS radiusPayload =
652 new RADIUS(RADIUS.RADIUS_CODE_ACCESS_REQUEST,
653 eapPacket.getIdentifier());
Ray Milkey967776a2015-10-07 14:37:17 -0700654
655 // set Request Authenticator in StateMachine
656 stateMachine.setRequestAuthenticator(radiusPayload.generateAuthCode());
657
Ray Milkey9eb293f2015-09-30 15:09:17 -0700658 radiusPayload.setIdentifier(identifier);
659 radiusPayload.setAttribute(RADIUSAttribute.RADIUS_ATTR_USERNAME,
Ray Milkey967776a2015-10-07 14:37:17 -0700660 stateMachine.username());
Ray Milkey9eb293f2015-09-30 15:09:17 -0700661
662 radiusPayload.setAttribute(RADIUSAttribute.RADIUS_ATTR_NAS_IP,
Jonathan Hart092dfb22015-11-16 23:05:21 -0800663 AaaManager.this.nasIpAddress.getAddress());
Ray Milkey9eb293f2015-09-30 15:09:17 -0700664
665 radiusPayload.encapsulateMessage(eapPacket);
Ray Milkey9eb293f2015-09-30 15:09:17 -0700666
667 return radiusPayload;
668 }
Ari Saha89831742015-06-26 10:31:48 -0700669
670 /**
Jonathan Harta46dddf2015-06-30 15:31:20 -0700671 * Handles PAE packets (supplicant).
672 *
673 * @param inPacket Ethernet packet coming from the supplicant
Ari Saha89831742015-06-26 10:31:48 -0700674 */
Ray Milkeyf51eba22015-09-25 10:24:23 -0700675 private void handleSupplicantPacket(InboundPacket inPacket) throws StateMachineException {
Jonathan Harta46dddf2015-06-30 15:31:20 -0700676 Ethernet ethPkt = inPacket.parsed();
Ari Saha89831742015-06-26 10:31:48 -0700677 // Where does it come from?
Jonathan Hart092dfb22015-11-16 23:05:21 -0800678 MacAddress srcMac = ethPkt.getSourceMAC();
Ari Saha89831742015-06-26 10:31:48 -0700679
Jonathan Harta46dddf2015-06-30 15:31:20 -0700680 DeviceId deviceId = inPacket.receivedFrom().deviceId();
681 PortNumber portNumber = inPacket.receivedFrom().port();
Ari Saha89831742015-06-26 10:31:48 -0700682 String sessionId = deviceId.toString() + portNumber.toString();
Saurav Das987441a2018-09-18 16:33:47 -0700683 EAPOL eapol = (EAPOL) ethPkt.getPayload();
684 if (log.isTraceEnabled()) {
685 log.trace("Received EAPOL packet {} in enclosing packet {} from "
686 + "dev/port: {}/{}", eapol, ethPkt, deviceId,
687 portNumber);
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100688 }
Jonathan Harta46dddf2015-06-30 15:31:20 -0700689
Shubham Sharma3c8c7022019-09-13 10:39:47 +0000690 short pktlen = eapol.getPacketLength();
691 byte[] eapPayLoadBuffer = eapol.serialize();
692 int len = eapPayLoadBuffer.length;
693 if (len != (HEADER_LENGTH + pktlen)) {
694 aaaStatisticsManager.getAaaStats().incrementInvalidBodyLength();
695 return;
696 }
697 if (!VALID_EAPOL_TYPE.contains(eapol.getEapolType())) {
698 aaaStatisticsManager.getAaaStats().incrementInvalidPktType();
699 return;
700 }
701 if (pktlen >= 0 && ethPkt.getEtherType() == EthType.EtherType.EAPOL.ethType().toShort()) {
702 aaaStatisticsManager.getAaaStats().incrementValidEapolFramesRx();
703 }
Saurav Das987441a2018-09-18 16:33:47 -0700704 StateMachine stateMachine = StateMachine.lookupStateMachineBySessionId(sessionId);
705 if (stateMachine == null) {
706 log.debug("Creating new state machine for sessionId: {} for "
707 + "dev/port: {}/{}", sessionId, deviceId, portNumber);
708 stateMachine = new StateMachine(sessionId);
709 } else {
710 log.debug("Using existing state-machine for sessionId: {}", sessionId);
Kartikey Dubeyadeb26e2019-10-01 12:18:35 +0000711 stateMachine.setEapolTypeVal(eapol.getEapolType());
Saurav Das987441a2018-09-18 16:33:47 -0700712 }
713
Ari Saha89831742015-06-26 10:31:48 -0700714 switch (eapol.getEapolType()) {
715 case EAPOL.EAPOL_START:
Matt Jeanneret2ff1a782018-06-13 15:24:25 -0400716 log.debug("EAP packet: EAPOL_START");
Ray Milkeyf51eba22015-09-25 10:24:23 -0700717 stateMachine.setSupplicantConnectpoint(inPacket.receivedFrom());
Shubham Sharma1e43c562019-06-19 14:18:12 +0000718 if (stateMachine.getCleanupTimer() == null) {
719 scheduleStateMachineCleanupTimer(sessionId, stateMachine);
720 }
Jonathan Hart5db44532018-07-12 18:13:54 -0700721 stateMachine.start();
Shubham Sharma1f193582019-07-11 12:12:41 +0000722 aaaStatisticsManager.getAaaStats().incrementEapolStartReqTrans();
Ray Milkeyf51eba22015-09-25 10:24:23 -0700723 //send an EAP Request/Identify to the supplicant
724 EAP eapPayload = new EAP(EAP.REQUEST, stateMachine.identifier(), EAP.ATTR_IDENTITY, null);
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100725 if (ethPkt.getVlanID() != Ethernet.VLAN_UNTAGGED) {
726 stateMachine.setPriorityCode(ethPkt.getPriorityCode());
727 }
Jonathan Hart092dfb22015-11-16 23:05:21 -0800728 Ethernet eth = buildEapolResponse(srcMac, MacAddress.valueOf(nasMacAddress),
Ray Milkeyf51eba22015-09-25 10:24:23 -0700729 ethPkt.getVlanID(), EAPOL.EAPOL_PACKET,
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100730 eapPayload, stateMachine.priorityCode());
Matt Jeanneret2ff1a782018-06-13 15:24:25 -0400731
Jonathan Hart092dfb22015-11-16 23:05:21 -0800732 stateMachine.setSupplicantAddress(srcMac);
Ray Milkeyf51eba22015-09-25 10:24:23 -0700733 stateMachine.setVlanId(ethPkt.getVlanID());
Matt Jeanneret2ff1a782018-06-13 15:24:25 -0400734 log.debug("Getting EAP identity from supplicant {}", stateMachine.supplicantAddress().toString());
Shubham Sharma1f193582019-07-11 12:12:41 +0000735 sendPacketToSupplicant(eth, stateMachine.supplicantConnectpoint(), false);
Shubham Sharma3c8c7022019-09-13 10:39:47 +0000736 aaaStatisticsManager.getAaaStats().incrementRequestIdFramesTx();
Ari Saha89831742015-06-26 10:31:48 -0700737
738 break;
Qianqian Hub55a1ac2015-12-23 20:44:48 +0800739 case EAPOL.EAPOL_LOGOFF:
Matt Jeanneret2ff1a782018-06-13 15:24:25 -0400740 log.debug("EAP packet: EAPOL_LOGOFF");
Kartikey Dubeyadeb26e2019-10-01 12:18:35 +0000741 //posting the machine stat data for current supplicant device.
742 if (stateMachine.getSessionTerminateReason() == null ||
743 stateMachine.getSessionTerminateReason().equals("")) {
744 stateMachine.setSessionTerminateReason(
745 StateMachine.SessionTerminationReasons.SUPPLICANT_LOGOFF.getReason());
746 }
747 AaaSupplicantMachineStats obj = aaaSupplicantStatsManager.getSupplicantStats(stateMachine);
748 aaaSupplicantStatsManager.getMachineStatsDelegate()
749 .notify(new AaaMachineStatisticsEvent(AaaMachineStatisticsEvent.Type.STATS_UPDATE, obj));
Ray Milkeyb34b4962016-01-04 10:24:43 -0800750 if (stateMachine.state() == StateMachine.STATE_AUTHORIZED) {
751 stateMachine.logoff();
Shubham Sharma1f193582019-07-11 12:12:41 +0000752 aaaStatisticsManager.getAaaStats().incrementEapolLogoffRx();
Qianqian Hub55a1ac2015-12-23 20:44:48 +0800753 }
Shubham Sharma3c8c7022019-09-13 10:39:47 +0000754 if (stateMachine.state() == StateMachine.STATE_IDLE) {
755 aaaStatisticsManager.getAaaStats().incrementAuthStateIdle();
756 }
Qianqian Hub55a1ac2015-12-23 20:44:48 +0800757
758 break;
Ari Saha89831742015-06-26 10:31:48 -0700759 case EAPOL.EAPOL_PACKET:
Ray Milkeyf51eba22015-09-25 10:24:23 -0700760 RADIUS radiusPayload;
Ray Milkey9eb293f2015-09-30 15:09:17 -0700761 // check if this is a Response/Identify or a Response/TLS
Ari Saha89831742015-06-26 10:31:48 -0700762 EAP eapPacket = (EAP) eapol.getPayload();
Shubham Sharma3c8c7022019-09-13 10:39:47 +0000763 Byte identifier = new Byte(eapPacket.getIdentifier());
Ari Saha89831742015-06-26 10:31:48 -0700764
765 byte dataType = eapPacket.getDataType();
766 switch (dataType) {
Ari Saha89831742015-06-26 10:31:48 -0700767
Ray Milkey9eb293f2015-09-30 15:09:17 -0700768 case EAP.ATTR_IDENTITY:
Matt Jeanneret2ff1a782018-06-13 15:24:25 -0400769 log.debug("EAP packet: EAPOL_PACKET ATTR_IDENTITY");
Shubham Sharma1e43c562019-06-19 14:18:12 +0000770 //Setting the time of this response from RG, only when its not a re-transmission.
771 if (stateMachine.getLastPacketReceivedTime() == 0) {
772 stateMachine.setLastPacketReceivedTime(System.currentTimeMillis());
773 }
Ray Milkey9eb293f2015-09-30 15:09:17 -0700774 // request id access to RADIUS
775 stateMachine.setUsername(eapPacket.getData());
Ari Saha89831742015-06-26 10:31:48 -0700776
Ray Milkey967776a2015-10-07 14:37:17 -0700777 radiusPayload = getRadiusPayload(stateMachine, stateMachine.identifier(), eapPacket);
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100778 radiusPayload = pktCustomizer.customizePacket(radiusPayload, inPacket);
Jonathan Hart092dfb22015-11-16 23:05:21 -0800779 radiusPayload.addMessageAuthenticator(AaaManager.this.radiusSecret);
Ari Saha89831742015-06-26 10:31:48 -0700780
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100781 sendRadiusPacket(radiusPayload, inPacket);
Shubham Sharma1e43c562019-06-19 14:18:12 +0000782 stateMachine.setWaitingForRadiusResponse(true);
Shubham Sharma1f193582019-07-11 12:12:41 +0000783 aaaStatisticsManager.getAaaStats().incrementEapolAtrrIdentity();
Ray Milkey9eb293f2015-09-30 15:09:17 -0700784 // change the state to "PENDING"
kartikey dubeye1545422019-05-22 12:53:45 +0000785 if (stateMachine.state() == StateMachine.STATE_PENDING) {
786 aaaStatisticsManager.getAaaStats().increaseRequestReTx();
Kartikey Dubeyadeb26e2019-10-01 12:18:35 +0000787 stateMachine.incrementTotalPacketsSent();
788 stateMachine.incrementTotalOctetSent(eapol.getPacketLength());
kartikey dubeye1545422019-05-22 12:53:45 +0000789 }
Ray Milkey9eb293f2015-09-30 15:09:17 -0700790 stateMachine.requestAccess();
791 break;
Ari Saha89831742015-06-26 10:31:48 -0700792 case EAP.ATTR_MD5:
Shubham Sharma1e43c562019-06-19 14:18:12 +0000793 stateMachine.setLastPacketReceivedTime(System.currentTimeMillis());
Matt Jeanneret2ff1a782018-06-13 15:24:25 -0400794 log.debug("EAP packet: EAPOL_PACKET ATTR_MD5");
Ray Milkey9eb293f2015-09-30 15:09:17 -0700795 // verify if the EAP identifier corresponds to the
796 // challenge identifier from the client state
797 // machine.
Ray Milkeyf61a24e2015-09-24 16:34:02 -0700798 if (eapPacket.getIdentifier() == stateMachine.challengeIdentifier()) {
Ari Saha89831742015-06-26 10:31:48 -0700799 //send the RADIUS challenge response
Ray Milkey967776a2015-10-07 14:37:17 -0700800 radiusPayload =
801 getRadiusPayload(stateMachine,
802 stateMachine.identifier(),
803 eapPacket);
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100804 radiusPayload = pktCustomizer.customizePacket(radiusPayload, inPacket);
Ari Saha89831742015-06-26 10:31:48 -0700805
Qianqian Hub55a1ac2015-12-23 20:44:48 +0800806 if (stateMachine.challengeState() != null) {
807 radiusPayload.setAttribute(RADIUSAttribute.RADIUS_ATTR_STATE,
808 stateMachine.challengeState());
809 }
Jonathan Hart092dfb22015-11-16 23:05:21 -0800810 radiusPayload.addMessageAuthenticator(AaaManager.this.radiusSecret);
Shubham Sharma3c8c7022019-09-13 10:39:47 +0000811 if (outPacketSupp.contains(eapPacket.getIdentifier())) {
812 aaaStatisticsManager.getAaaStats().decrementPendingResSupp();
813 outPacketSupp.remove(identifier);
814 }
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100815 sendRadiusPacket(radiusPayload, inPacket);
Shubham Sharma1e43c562019-06-19 14:18:12 +0000816 stateMachine.setWaitingForRadiusResponse(true);
Shubham Sharma1f193582019-07-11 12:12:41 +0000817 aaaStatisticsManager.getAaaStats().incrementEapolMd5RspChall();
Ari Saha89831742015-06-26 10:31:48 -0700818 }
819 break;
820 case EAP.ATTR_TLS:
Matt Jeanneret2ff1a782018-06-13 15:24:25 -0400821 log.debug("EAP packet: EAPOL_PACKET ATTR_TLS");
Ray Milkey9eb293f2015-09-30 15:09:17 -0700822 // request id access to RADIUS
Ray Milkey967776a2015-10-07 14:37:17 -0700823 radiusPayload = getRadiusPayload(stateMachine, stateMachine.identifier(), eapPacket);
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100824 radiusPayload = pktCustomizer.customizePacket(radiusPayload, inPacket);
Ari Saha89831742015-06-26 10:31:48 -0700825
Qianqian Hub55a1ac2015-12-23 20:44:48 +0800826 if (stateMachine.challengeState() != null) {
827 radiusPayload.setAttribute(RADIUSAttribute.RADIUS_ATTR_STATE,
828 stateMachine.challengeState());
829 }
Ray Milkeyf51eba22015-09-25 10:24:23 -0700830 stateMachine.setRequestAuthenticator(radiusPayload.generateAuthCode());
Ari Saha89831742015-06-26 10:31:48 -0700831
Jonathan Hart092dfb22015-11-16 23:05:21 -0800832 radiusPayload.addMessageAuthenticator(AaaManager.this.radiusSecret);
Shubham Sharma3c8c7022019-09-13 10:39:47 +0000833 if (outPacketSupp.contains(eapPacket.getIdentifier())) {
834 aaaStatisticsManager.getAaaStats().decrementPendingResSupp();
835 outPacketSupp.remove(identifier);
836 }
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100837 sendRadiusPacket(radiusPayload, inPacket);
Shubham Sharma1e43c562019-06-19 14:18:12 +0000838 stateMachine.setWaitingForRadiusResponse(true);
Shubham Sharma1f193582019-07-11 12:12:41 +0000839 aaaStatisticsManager.getAaaStats().incrementEapolTlsRespChall();
Ray Milkey5493b512015-10-21 12:13:49 -0700840
Ray Milkeyf3790b82015-10-21 16:28:08 -0700841 if (stateMachine.state() != StateMachine.STATE_PENDING) {
842 stateMachine.requestAccess();
843 }
Ray Milkeyf51eba22015-09-25 10:24:23 -0700844
Ari Saha89831742015-06-26 10:31:48 -0700845 break;
846 default:
Matt Jeanneret2ff1a782018-06-13 15:24:25 -0400847 log.warn("Unknown EAP packet type");
Ari Saha89831742015-06-26 10:31:48 -0700848 return;
849 }
850 break;
851 default:
Matt Jeanneret2ff1a782018-06-13 15:24:25 -0400852 log.debug("Skipping EAPOL message {}", eapol.getEapolType());
Ari Saha89831742015-06-26 10:31:48 -0700853 }
Shubham Sharma1f193582019-07-11 12:12:41 +0000854 aaaStatisticsManager.getAaaStats().countTransRespNotNak();
855 aaaStatisticsManager.getAaaStats().countEapolResIdentityMsgTrans();
Ari Saha89831742015-06-26 10:31:48 -0700856 }
Ray Milkey967776a2015-10-07 14:37:17 -0700857 }
858
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100859 /**
Jonathan Hart5db44532018-07-12 18:13:54 -0700860 * Delegate allowing the StateMachine to notify us of events.
861 */
862 private class InternalStateMachineDelegate implements StateMachineDelegate {
863
864 @Override
865 public void notify(AuthenticationEvent authenticationEvent) {
866 log.info("Auth event {} for {}",
867 authenticationEvent.type(), authenticationEvent.subject());
868 post(authenticationEvent);
869 }
870 }
871
872 /**
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100873 * Configuration Listener, handles change in configuration.
874 */
Ray Milkeyfcb623d2015-10-01 16:48:18 -0700875 private class InternalConfigListener implements NetworkConfigListener {
876
877 /**
Ray Milkeyc9e8dcc2015-12-30 10:31:32 -0800878 * Reconfigures the AAA application according to the
879 * configuration parameters passed.
Ray Milkeyfcb623d2015-10-01 16:48:18 -0700880 *
881 * @param cfg configuration object
882 */
Jonathan Hart092dfb22015-11-16 23:05:21 -0800883 private void reconfigureNetwork(AaaConfig cfg) {
Matt Jeanneret2ff1a782018-06-13 15:24:25 -0400884 log.info("Reconfiguring AaaConfig from config: {}", cfg);
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100885
Ray Milkeyfcb623d2015-10-01 16:48:18 -0700886 if (cfg == null) {
Jonathan Hart092dfb22015-11-16 23:05:21 -0800887 newCfg = new AaaConfig();
Ray Milkeyfcb623d2015-10-01 16:48:18 -0700888 } else {
889 newCfg = cfg;
890 }
891 if (newCfg.nasIp() != null) {
892 nasIpAddress = newCfg.nasIp();
893 }
894 if (newCfg.radiusIp() != null) {
895 radiusIpAddress = newCfg.radiusIp();
896 }
897 if (newCfg.radiusMac() != null) {
898 radiusMacAddress = newCfg.radiusMac();
899 }
900 if (newCfg.nasMac() != null) {
901 nasMacAddress = newCfg.nasMac();
902 }
903 if (newCfg.radiusSecret() != null) {
904 radiusSecret = newCfg.radiusSecret();
905 }
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100906
Deepa Vaddireddye0e10722017-09-27 05:00:10 +0530907 boolean reconfigureCustomizer = false;
908 if (customizer == null || !customizer.equals(newCfg.radiusPktCustomizer())) {
909 customizer = newCfg.radiusPktCustomizer();
910 configurePacketCustomizer();
911 reconfigureCustomizer = true;
912 }
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100913
Deepa Vaddireddye0e10722017-09-27 05:00:10 +0530914 if (radiusConnectionType == null
915 || reconfigureCustomizer
916 || !radiusConnectionType.equals(newCfg.radiusConnectionType())) {
917 radiusConnectionType = newCfg.radiusConnectionType();
918 if (impl != null) {
919 impl.withdrawIntercepts();
920 impl.clearLocalState();
921 }
922 configureRadiusCommunication();
923 impl.initializeLocalState(newCfg);
924 impl.requestIntercepts();
925 } else if (impl != null) {
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100926 impl.clearLocalState();
927 impl.initializeLocalState(newCfg);
Ray Milkey5d99bd12015-10-06 15:41:30 -0700928 }
Ray Milkeyfcb623d2015-10-01 16:48:18 -0700929 }
930
931 @Override
932 public void event(NetworkConfigEvent event) {
933
934 if ((event.type() == NetworkConfigEvent.Type.CONFIG_ADDED ||
935 event.type() == NetworkConfigEvent.Type.CONFIG_UPDATED) &&
Jonathan Hart092dfb22015-11-16 23:05:21 -0800936 event.configClass().equals(AaaConfig.class)) {
Ray Milkeyfcb623d2015-10-01 16:48:18 -0700937
Jonathan Hart092dfb22015-11-16 23:05:21 -0800938 AaaConfig cfg = netCfgService.getConfig(appId, AaaConfig.class);
Ray Milkeyfcb623d2015-10-01 16:48:18 -0700939 reconfigureNetwork(cfg);
Amit Ghoshc9ac1e52017-07-28 12:31:18 +0100940
Matt Jeanneret2ff1a782018-06-13 15:24:25 -0400941 log.info("Reconfigured: {}", cfg.toString());
Ray Milkeyfcb623d2015-10-01 16:48:18 -0700942 }
943 }
944 }
Amit Ghoshf739be52017-09-21 15:49:37 +0100945
946 private class InternalDeviceListener implements DeviceListener {
947 @Override
948 public void event(DeviceEvent event) {
949
950 switch (event.type()) {
951 case PORT_REMOVED:
952 DeviceId devId = event.subject().id();
953 PortNumber portNumber = event.port().number();
954 String sessionId = devId.toString() + portNumber.toString();
955
Kartikey Dubeyadeb26e2019-10-01 12:18:35 +0000956 StateMachine stateMachine = StateMachine.lookupStateMachineBySessionId(sessionId);
957 if (stateMachine != null) {
958 stateMachine.setSessionTerminateReason(
959 StateMachine.SessionTerminationReasons.PORT_REMOVED.getReason());
960 }
961 //pushing captured machine stats to kafka
962 AaaSupplicantMachineStats obj = aaaSupplicantStatsManager.getSupplicantStats(stateMachine);
963 aaaSupplicantStatsManager.getMachineStatsDelegate()
964 .notify(new AaaMachineStatisticsEvent(AaaMachineStatisticsEvent.Type.STATS_UPDATE, obj));
965
Amit Ghoshf739be52017-09-21 15:49:37 +0100966 Map<String, StateMachine> sessionIdMap = StateMachine.sessionIdMap();
967 StateMachine removed = sessionIdMap.remove(sessionId);
968 if (removed != null) {
969 StateMachine.deleteStateMachineMapping(removed);
970 }
971
972 break;
973 default:
974 return;
975 }
976 }
977 }
kartikey dubeye1545422019-05-22 12:53:45 +0000978 private class AuthenticationStatisticsEventPublisher implements Runnable {
979 private final Logger log = getLogger(getClass());
980 public void run() {
981 log.info("Notifying AuthenticationStatisticsEvent");
982 aaaStatisticsManager.calculatePacketRoundtripTime();
983 log.debug("AcceptResponsesRx---" + aaaStatisticsManager.getAaaStats().getAcceptResponsesRx());
984 log.debug("AccessRequestsTx---" + aaaStatisticsManager.getAaaStats().getAccessRequestsTx());
985 log.debug("ChallengeResponsesRx---" + aaaStatisticsManager.getAaaStats().getChallengeResponsesRx());
986 log.debug("DroppedResponsesRx---" + aaaStatisticsManager.getAaaStats().getDroppedResponsesRx());
987 log.debug("InvalidValidatorsRx---" + aaaStatisticsManager.getAaaStats().getInvalidValidatorsRx());
988 log.debug("MalformedResponsesRx---" + aaaStatisticsManager.getAaaStats().getMalformedResponsesRx());
989 log.debug("PendingRequests---" + aaaStatisticsManager.getAaaStats().getPendingRequests());
990 log.debug("RejectResponsesRx---" + aaaStatisticsManager.getAaaStats().getRejectResponsesRx());
991 log.debug("RequestReTx---" + aaaStatisticsManager.getAaaStats().getRequestReTx());
992 log.debug("RequestRttMilis---" + aaaStatisticsManager.getAaaStats().getRequestRttMilis());
993 log.debug("UnknownServerRx---" + aaaStatisticsManager.getAaaStats().getUnknownServerRx());
994 log.debug("UnknownTypeRx---" + aaaStatisticsManager.getAaaStats().getUnknownTypeRx());
Shubham Sharma1e43c562019-06-19 14:18:12 +0000995 log.debug("TimedOutPackets----" + aaaStatisticsManager.getAaaStats().getTimedOutPackets());
Shubham Sharma1f193582019-07-11 12:12:41 +0000996 log.debug("EapolLogoffRx---" + aaaStatisticsManager.getAaaStats().getEapolLogoffRx());
997 log.debug("EapolAuthSuccessTrans---" + aaaStatisticsManager.getAaaStats().getEapolAuthSuccessTrans());
998 log.debug("EapolAuthFailureTrans---" +
999 aaaStatisticsManager.getAaaStats().getEapolAuthFailureTrans());
1000 log.debug("EapolStartReqTrans---" +
1001 aaaStatisticsManager.getAaaStats().getEapolStartReqTrans());
1002 log.debug("EapolTransRespNotNak---" +
1003 aaaStatisticsManager.getAaaStats().getEapolTransRespNotNak());
1004 log.debug("EapPktTxauthChooseEap---" +
1005 aaaStatisticsManager.getAaaStats().getEapPktTxauthChooseEap());
1006 log.debug("EapolResIdentityMsgTrans---" +
1007 aaaStatisticsManager.getAaaStats().getEapolResIdentityMsgTrans());
Shubham Sharma3c8c7022019-09-13 10:39:47 +00001008 log.debug("EapolFramesTx---" + aaaStatisticsManager.getAaaStats().getEapolFramesTx());
1009 log.debug("AuthStateIdle---" + aaaStatisticsManager.getAaaStats().getAuthStateIdle());
1010 log.debug("RequestIdFramesTx---" + aaaStatisticsManager.getAaaStats().getRequestIdFramesTx());
1011 log.debug("ReqEapFramesTx---" + aaaStatisticsManager.getAaaStats().getReqEapFramesTx());
1012 log.debug("InvalidPktType---" + aaaStatisticsManager.getAaaStats().getInvalidPktType());
1013 log.debug("InvalidBodyLength---" + aaaStatisticsManager.getAaaStats().getInvalidBodyLength());
1014 log.debug("ValidEapolFramesRx---" + aaaStatisticsManager.getAaaStats().getValidEapolFramesRx());
1015 log.debug("PendingResSupp---" + aaaStatisticsManager.getAaaStats().getPendingResSupp());
1016 log.debug("ResIdEapFramesRx---" + aaaStatisticsManager.getAaaStats().getEapolattrIdentity());
kartikey dubeye1545422019-05-22 12:53:45 +00001017 aaaStatisticsManager.getStatsDelegate().
1018 notify(new AuthenticationStatisticsEvent(AuthenticationStatisticsEvent.Type.STATS_UPDATE,
1019 aaaStatisticsManager.getAaaStats()));
1020 }
Shubham Sharma4900ce62019-06-19 14:18:50 +00001021 }
1022
1023 private class ServerStatusChecker implements Runnable {
1024 @Override
1025 public void run() {
Matteo Scandolo3498bc02020-01-08 09:54:12 -08001026 log.debug("Notifying RadiusOperationalStatusEvent");
Shubham Sharma4900ce62019-06-19 14:18:50 +00001027 radiusOperationalStatusService.checkServerOperationalStatus();
Matteo Scandolo3498bc02020-01-08 09:54:12 -08001028 log.trace("--POSTING--" + radiusOperationalStatusService.getRadiusServerOperationalStatus());
Shubham Sharma4900ce62019-06-19 14:18:50 +00001029 radiusOperationalStatusService.getRadiusOprStDelegate()
1030 .notify(new RadiusOperationalStatusEvent(
1031 RadiusOperationalStatusEvent.Type.RADIUS_OPERATIONAL_STATUS,
1032 radiusOperationalStatusService.
1033 getRadiusServerOperationalStatus()));
kartikey dubeye1545422019-05-22 12:53:45 +00001034 }
Shubham Sharma4900ce62019-06-19 14:18:50 +00001035
1036 }
1037}