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 | 932bedc | 2018-07-12 13:46:09 -0700 | [diff] [blame] | 19 | import org.apache.commons.lang3.builder.ToStringBuilder; |
Jonathan Hart | 4731dd9 | 2018-05-02 17:30:05 -0700 | [diff] [blame] | 20 | import org.onlab.packet.DeserializationException; |
Jonathan Hart | a46dddf | 2015-06-30 15:31:20 -0700 | [diff] [blame] | 21 | import org.onlab.packet.EAP; |
| 22 | import org.onlab.packet.EAPOL; |
| 23 | import org.onlab.packet.EthType; |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 24 | import org.onlab.packet.Ethernet; |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 25 | import org.onlab.packet.MacAddress; |
Jonathan Hart | a46dddf | 2015-06-30 15:31:20 -0700 | [diff] [blame] | 26 | import org.onlab.packet.RADIUS; |
| 27 | import org.onlab.packet.RADIUSAttribute; |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 28 | import org.onlab.util.Tools; |
| 29 | import org.onosproject.cfg.ComponentConfigService; |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 30 | import org.onosproject.core.ApplicationId; |
| 31 | import org.onosproject.core.CoreService; |
Jonathan Hart | 5db4453 | 2018-07-12 18:13:54 -0700 | [diff] [blame] | 32 | import org.onosproject.event.AbstractListenerManager; |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 33 | import org.onosproject.mastership.MastershipService; |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 34 | import org.onosproject.net.ConnectPoint; |
| 35 | import org.onosproject.net.DeviceId; |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 36 | import org.onosproject.net.PortNumber; |
Ray Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 37 | import org.onosproject.net.config.ConfigFactory; |
| 38 | import org.onosproject.net.config.NetworkConfigEvent; |
| 39 | import org.onosproject.net.config.NetworkConfigListener; |
| 40 | import org.onosproject.net.config.NetworkConfigRegistry; |
Amit Ghosh | f739be5 | 2017-09-21 15:49:37 +0100 | [diff] [blame] | 41 | import org.onosproject.net.device.DeviceEvent; |
| 42 | import org.onosproject.net.device.DeviceListener; |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 43 | import org.onosproject.net.device.DeviceService; |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 44 | import org.onosproject.net.flow.DefaultTrafficTreatment; |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 45 | import org.onosproject.net.flow.TrafficTreatment; |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 46 | import org.onosproject.net.packet.DefaultOutboundPacket; |
| 47 | import org.onosproject.net.packet.InboundPacket; |
| 48 | import org.onosproject.net.packet.OutboundPacket; |
| 49 | import org.onosproject.net.packet.PacketContext; |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 50 | import org.onosproject.net.packet.PacketProcessor; |
| 51 | import org.onosproject.net.packet.PacketService; |
Matteo Scandolo | cf847b8 | 2019-04-26 15:00:00 -0700 | [diff] [blame] | 52 | import org.opencord.aaa.AaaConfig; |
Kartikey Dubey | adeb26e | 2019-10-01 12:18:35 +0000 | [diff] [blame^] | 53 | import org.opencord.aaa.AaaMachineStatisticsEvent; |
| 54 | import org.opencord.aaa.AaaMachineStatisticsService; |
| 55 | import org.opencord.aaa.AaaSupplicantMachineStats; |
Matteo Scandolo | cf847b8 | 2019-04-26 15:00:00 -0700 | [diff] [blame] | 56 | import org.opencord.aaa.AuthenticationEvent; |
| 57 | import org.opencord.aaa.AuthenticationEventListener; |
| 58 | import org.opencord.aaa.AuthenticationService; |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 59 | import org.opencord.aaa.AuthenticationStatisticsEvent; |
| 60 | import org.opencord.aaa.AuthenticationStatisticsService; |
Matteo Scandolo | cf847b8 | 2019-04-26 15:00:00 -0700 | [diff] [blame] | 61 | import org.opencord.aaa.RadiusCommunicator; |
Shubham Sharma | 4900ce6 | 2019-06-19 14:18:50 +0000 | [diff] [blame] | 62 | import org.opencord.aaa.RadiusOperationalStatusEvent; |
| 63 | import org.opencord.aaa.RadiusOperationalStatusService; |
| 64 | import org.opencord.aaa.RadiusOperationalStatusService.RadiusOperationalStatusEvaluationMode; |
Matteo Scandolo | cf847b8 | 2019-04-26 15:00:00 -0700 | [diff] [blame] | 65 | import org.opencord.aaa.StateMachineDelegate; |
Gamze Abaka | 1cfdb19 | 2018-10-25 11:39:19 +0000 | [diff] [blame] | 66 | import org.opencord.sadis.BaseInformationService; |
| 67 | import org.opencord.sadis.SadisService; |
| 68 | import org.opencord.sadis.SubscriberAndDeviceInformation; |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 69 | import org.osgi.service.component.ComponentContext; |
Carmelo Cascone | 58b5329 | 2019-09-30 12:35:31 -0700 | [diff] [blame] | 70 | import org.osgi.service.component.annotations.Activate; |
Shubham Sharma | 4900ce6 | 2019-06-19 14:18:50 +0000 | [diff] [blame] | 71 | import org.osgi.service.component.annotations.Component; |
| 72 | import org.osgi.service.component.annotations.Deactivate; |
| 73 | import org.osgi.service.component.annotations.Modified; |
| 74 | import org.osgi.service.component.annotations.Reference; |
| 75 | import org.osgi.service.component.annotations.ReferenceCardinality; |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 76 | import org.slf4j.Logger; |
| 77 | |
Shubham Sharma | 4900ce6 | 2019-06-19 14:18:50 +0000 | [diff] [blame] | 78 | import javax.crypto.Mac; |
| 79 | import javax.crypto.spec.SecretKeySpec; |
| 80 | import java.net.InetAddress; |
| 81 | import java.net.UnknownHostException; |
| 82 | import java.nio.ByteBuffer; |
| 83 | import java.util.Arrays; |
| 84 | import java.util.Dictionary; |
| 85 | import java.util.HashSet; |
| 86 | import java.util.List; |
| 87 | import java.util.Map; |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 88 | import java.util.concurrent.Executors; |
| 89 | import java.util.concurrent.ScheduledExecutorService; |
| 90 | import java.util.concurrent.ScheduledFuture; |
| 91 | import java.util.concurrent.TimeUnit; |
Vijaykumar Kushwaha | 056e4cd | 2019-08-06 13:16:25 +0000 | [diff] [blame] | 92 | |
Shubham Sharma | 4900ce6 | 2019-06-19 14:18:50 +0000 | [diff] [blame] | 93 | import static org.onosproject.net.config.basics.SubjectFactories.APP_SUBJECT_FACTORY; |
| 94 | import static org.opencord.aaa.impl.OsgiPropertyConstants.OPERATIONAL_STATUS_SERVER_EVENT_GENERATION; |
| 95 | import static org.opencord.aaa.impl.OsgiPropertyConstants.OPERATIONAL_STATUS_SERVER_EVENT_GENERATION_DEFAULT; |
| 96 | import static org.opencord.aaa.impl.OsgiPropertyConstants.OPERATIONAL_STATUS_SERVER_TIMEOUT; |
| 97 | import static org.opencord.aaa.impl.OsgiPropertyConstants.OPERATIONAL_STATUS_SERVER_TIMEOUT_DEFAULT; |
| 98 | import static org.opencord.aaa.impl.OsgiPropertyConstants.STATISTICS_GENERATION_PERIOD; |
| 99 | import static org.opencord.aaa.impl.OsgiPropertyConstants.STATISTICS_GENERATION_PERIOD_DEFAULT; |
| 100 | import static org.opencord.aaa.impl.OsgiPropertyConstants.STATUS_SERVER_MODE; |
| 101 | import static org.opencord.aaa.impl.OsgiPropertyConstants.STATUS_SERVER_MODE_DEFAULT; |
| 102 | import static org.slf4j.LoggerFactory.getLogger; |
Carmelo Cascone | 58b5329 | 2019-09-30 12:35:31 -0700 | [diff] [blame] | 103 | |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 104 | /** |
Jonathan Hart | a46dddf | 2015-06-30 15:31:20 -0700 | [diff] [blame] | 105 | * AAA application for ONOS. |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 106 | */ |
Carmelo Cascone | 58b5329 | 2019-09-30 12:35:31 -0700 | [diff] [blame] | 107 | @Component(immediate = true, property = { |
Shubham Sharma | 4900ce6 | 2019-06-19 14:18:50 +0000 | [diff] [blame] | 108 | 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 Cascone | 58b5329 | 2019-09-30 12:35:31 -0700 | [diff] [blame] | 112 | }) |
Jonathan Hart | 5db4453 | 2018-07-12 18:13:54 -0700 | [diff] [blame] | 113 | public class AaaManager |
| 114 | extends AbstractListenerManager<AuthenticationEvent, AuthenticationEventListener> |
| 115 | implements AuthenticationService { |
| 116 | |
Charles Chan | df7ff86 | 2017-01-20 11:22:05 -0800 | [diff] [blame] | 117 | private static final String APP_NAME = "org.opencord.aaa"; |
Ray Milkey | f51eba2 | 2015-09-25 10:24:23 -0700 | [diff] [blame] | 118 | |
Ray Milkey | f61a24e | 2015-09-24 16:34:02 -0700 | [diff] [blame] | 119 | private final Logger log = getLogger(getClass()); |
Ray Milkey | f51eba2 | 2015-09-25 10:24:23 -0700 | [diff] [blame] | 120 | |
Carmelo Cascone | 58b5329 | 2019-09-30 12:35:31 -0700 | [diff] [blame] | 121 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
Ray Milkey | f61a24e | 2015-09-24 16:34:02 -0700 | [diff] [blame] | 122 | protected CoreService coreService; |
Ray Milkey | f51eba2 | 2015-09-25 10:24:23 -0700 | [diff] [blame] | 123 | |
Carmelo Cascone | 58b5329 | 2019-09-30 12:35:31 -0700 | [diff] [blame] | 124 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
Ray Milkey | f61a24e | 2015-09-24 16:34:02 -0700 | [diff] [blame] | 125 | protected PacketService packetService; |
Ray Milkey | f51eba2 | 2015-09-25 10:24:23 -0700 | [diff] [blame] | 126 | |
Carmelo Cascone | 58b5329 | 2019-09-30 12:35:31 -0700 | [diff] [blame] | 127 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
Ray Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 128 | protected NetworkConfigRegistry netCfgService; |
Ray Milkey | f51eba2 | 2015-09-25 10:24:23 -0700 | [diff] [blame] | 129 | |
Carmelo Cascone | 58b5329 | 2019-09-30 12:35:31 -0700 | [diff] [blame] | 130 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 131 | protected DeviceService deviceService; |
| 132 | |
Carmelo Cascone | 58b5329 | 2019-09-30 12:35:31 -0700 | [diff] [blame] | 133 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
Gamze Abaka | 1cfdb19 | 2018-10-25 11:39:19 +0000 | [diff] [blame] | 134 | protected SadisService sadisService; |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 135 | |
Carmelo Cascone | 58b5329 | 2019-09-30 12:35:31 -0700 | [diff] [blame] | 136 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 137 | protected MastershipService mastershipService; |
| 138 | |
Carmelo Cascone | 58b5329 | 2019-09-30 12:35:31 -0700 | [diff] [blame] | 139 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 140 | protected AuthenticationStatisticsService aaaStatisticsManager; |
Gamze Abaka | 1cfdb19 | 2018-10-25 11:39:19 +0000 | [diff] [blame] | 141 | |
Carmelo Cascone | 58b5329 | 2019-09-30 12:35:31 -0700 | [diff] [blame] | 142 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
Kartikey Dubey | adeb26e | 2019-10-01 12:18:35 +0000 | [diff] [blame^] | 143 | protected AaaMachineStatisticsService aaaSupplicantStatsManager; |
| 144 | |
| 145 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 146 | protected ComponentConfigService cfgService; |
| 147 | |
Shubham Sharma | 4900ce6 | 2019-06-19 14:18:50 +0000 | [diff] [blame] | 148 | @Reference(cardinality = ReferenceCardinality.MANDATORY) |
| 149 | protected RadiusOperationalStatusService radiusOperationalStatusService; |
| 150 | |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 151 | protected AuthenticationStatisticsEventPublisher authenticationStatisticsPublisher; |
| 152 | protected BaseInformationService<SubscriberAndDeviceInformation> subsService; |
Amit Ghosh | f739be5 | 2017-09-21 15:49:37 +0100 | [diff] [blame] | 153 | private final DeviceListener deviceListener = new InternalDeviceListener(); |
| 154 | |
Shubham Sharma | 4900ce6 | 2019-06-19 14:18:50 +0000 | [diff] [blame] | 155 | // 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 dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 160 | |
Ray Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 161 | // NAS IP address |
| 162 | protected InetAddress nasIpAddress; |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 163 | |
| 164 | // self MAC address |
Jonathan Hart | 5db4453 | 2018-07-12 18:13:54 -0700 | [diff] [blame] | 165 | protected String nasMacAddress; |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 166 | |
| 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 Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 172 | |
| 173 | // RADIUS server secret |
| 174 | protected String radiusSecret; |
| 175 | |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 176 | // bindings |
| 177 | protected CustomizationInfo customInfo; |
Ray Milkey | 5d99bd1 | 2015-10-06 15:41:30 -0700 | [diff] [blame] | 178 | |
Ray Milkey | f61a24e | 2015-09-24 16:34:02 -0700 | [diff] [blame] | 179 | // our application-specific event handler |
| 180 | private ReactivePacketProcessor processor = new ReactivePacketProcessor(); |
Ray Milkey | f51eba2 | 2015-09-25 10:24:23 -0700 | [diff] [blame] | 181 | |
Ray Milkey | f61a24e | 2015-09-24 16:34:02 -0700 | [diff] [blame] | 182 | // our unique identifier |
| 183 | private ApplicationId appId; |
Ray Milkey | f51eba2 | 2015-09-25 10:24:23 -0700 | [diff] [blame] | 184 | |
Shubham Sharma | 1e43c56 | 2019-06-19 14:18:12 +0000 | [diff] [blame] | 185 | // TimeOut time for cleaning up stateMachines stuck due to pending AAA/EAPOL message. |
| 186 | protected int cleanupTimerTimeOutInMins; |
| 187 | |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 188 | // Setup specific customization/attributes on the RADIUS packets |
| 189 | PacketCustomizer pktCustomizer; |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 190 | |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 191 | // 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 Hart | 5db4453 | 2018-07-12 18:13:54 -0700 | [diff] [blame] | 198 | // Object for the specific type of communication with the RADIUS |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 199 | // server, socket based or packet_out based |
| 200 | RadiusCommunicator impl = null; |
| 201 | |
| 202 | // latest configuration |
| 203 | AaaConfig newCfg; |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 204 | |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 205 | ScheduledFuture<?> scheduledFuture; |
Shubham Sharma | 4900ce6 | 2019-06-19 14:18:50 +0000 | [diff] [blame] | 206 | ScheduledFuture<?> scheduledStatusServerChecker; |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 207 | ScheduledExecutorService executor; |
| 208 | String configuredAaaServerAddress; |
| 209 | HashSet<Byte> outPacketSet = new HashSet<Byte>(); |
Shubham Sharma | 3c8c702 | 2019-09-13 10:39:47 +0000 | [diff] [blame] | 210 | 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 Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 213 | // Configuration properties factory |
| 214 | private final ConfigFactory factory = |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 215 | new ConfigFactory<ApplicationId, AaaConfig>(APP_SUBJECT_FACTORY, |
| 216 | AaaConfig.class, |
Ray Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 217 | "AAA") { |
| 218 | @Override |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 219 | public AaaConfig createConfig() { |
| 220 | return new AaaConfig(); |
Ray Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 221 | } |
| 222 | }; |
Ray Milkey | f51eba2 | 2015-09-25 10:24:23 -0700 | [diff] [blame] | 223 | |
Ray Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 224 | // Listener for config changes |
| 225 | private final InternalConfigListener cfgListener = new InternalConfigListener(); |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 226 | |
Jonathan Hart | 5db4453 | 2018-07-12 18:13:54 -0700 | [diff] [blame] | 227 | private StateMachineDelegate delegate = new InternalStateMachineDelegate(); |
| 228 | |
Ray Milkey | f61a24e | 2015-09-24 16:34:02 -0700 | [diff] [blame] | 229 | /** |
| 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 Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 240 | short vlan, byte eapolType, EAP eap, byte priorityCode) { |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 241 | |
Ray Milkey | f61a24e | 2015-09-24 16:34:02 -0700 | [diff] [blame] | 242 | 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 Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 248 | eth.setPriorityCode(priorityCode); |
Ray Milkey | f61a24e | 2015-09-24 16:34:02 -0700 | [diff] [blame] | 249 | } |
| 250 | //eapol header |
| 251 | EAPOL eapol = new EAPOL(); |
| 252 | eapol.setEapolType(eapolType); |
| 253 | eapol.setPacketLength(eap.getLength()); |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 254 | |
Ray Milkey | f61a24e | 2015-09-24 16:34:02 -0700 | [diff] [blame] | 255 | //eap part |
| 256 | eapol.setPayload(eap); |
| 257 | |
| 258 | eth.setPayload(eapol); |
| 259 | eth.setPad(true); |
| 260 | return eth; |
| 261 | } |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 262 | |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 263 | @Activate |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 264 | public void activate(ComponentContext context) { |
Charles Chan | df7ff86 | 2017-01-20 11:22:05 -0800 | [diff] [blame] | 265 | appId = coreService.registerApplication(APP_NAME); |
Jonathan Hart | 5db4453 | 2018-07-12 18:13:54 -0700 | [diff] [blame] | 266 | eventDispatcher.addSink(AuthenticationEvent.class, listenerRegistry); |
Matt Jeanneret | 2ff1a78 | 2018-06-13 15:24:25 -0400 | [diff] [blame] | 267 | netCfgService.addListener(cfgListener); |
| 268 | netCfgService.registerConfigFactory(factory); |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 269 | cfgService.registerProperties(getClass()); |
| 270 | modified(context); |
Gamze Abaka | 1cfdb19 | 2018-10-25 11:39:19 +0000 | [diff] [blame] | 271 | subsService = sadisService.getSubscriberInfoService(); |
Deepa Vaddireddy | e0e1072 | 2017-09-27 05:00:10 +0530 | [diff] [blame] | 272 | customInfo = new CustomizationInfo(subsService, deviceService); |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 273 | cfgListener.reconfigureNetwork(netCfgService.getConfig(appId, AaaConfig.class)); |
Matt Jeanneret | 2ff1a78 | 2018-06-13 15:24:25 -0400 | [diff] [blame] | 274 | log.info("Starting with config {} {}", this, newCfg); |
Deepa Vaddireddy | e0e1072 | 2017-09-27 05:00:10 +0530 | [diff] [blame] | 275 | configureRadiusCommunication(); |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 276 | // register our event handler |
Brian O'Connor | d9c7da0 | 2015-07-29 17:49:24 -0700 | [diff] [blame] | 277 | packetService.addProcessor(processor, PacketProcessor.director(2)); |
Ray Milkey | f61a24e | 2015-09-24 16:34:02 -0700 | [diff] [blame] | 278 | StateMachine.initializeMaps(); |
Jonathan Hart | 5db4453 | 2018-07-12 18:13:54 -0700 | [diff] [blame] | 279 | StateMachine.setDelegate(delegate); |
Shubham Sharma | 1e43c56 | 2019-06-19 14:18:12 +0000 | [diff] [blame] | 280 | cleanupTimerTimeOutInMins = newCfg.sessionCleanupTimer(); |
| 281 | StateMachine.setcleanupTimerTimeOutInMins(cleanupTimerTimeOutInMins); |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 282 | impl.initializeLocalState(newCfg); |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 283 | impl.requestIntercepts(); |
Amit Ghosh | f739be5 | 2017-09-21 15:49:37 +0100 | [diff] [blame] | 284 | deviceService.addListener(deviceListener); |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 285 | getConfiguredAaaServerAddress(); |
Shubham Sharma | 4900ce6 | 2019-06-19 14:18:50 +0000 | [diff] [blame] | 286 | radiusOperationalStatusService.initialize(nasIpAddress.getAddress(), radiusSecret, impl); |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 287 | authenticationStatisticsPublisher = |
| 288 | new AuthenticationStatisticsEventPublisher(); |
Shubham Sharma | 4900ce6 | 2019-06-19 14:18:50 +0000 | [diff] [blame] | 289 | executor = Executors.newScheduledThreadPool(3); |
| 290 | |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 291 | scheduledFuture = executor.scheduleAtFixedRate(authenticationStatisticsPublisher, |
Shubham Sharma | 4900ce6 | 2019-06-19 14:18:50 +0000 | [diff] [blame] | 292 | 0, statisticsGenerationPeriodInSeconds, TimeUnit.SECONDS); |
| 293 | scheduledStatusServerChecker = executor.scheduleAtFixedRate(new ServerStatusChecker(), 0, |
| 294 | operationalStatusEventGenerationPeriodInSeconds, TimeUnit.SECONDS); |
Amit Ghosh | f739be5 | 2017-09-21 15:49:37 +0100 | [diff] [blame] | 295 | |
Jian Li | 13c6716 | 2015-12-09 13:20:34 -0800 | [diff] [blame] | 296 | log.info("Started"); |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 297 | } |
| 298 | |
| 299 | @Deactivate |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 300 | public void deactivate(ComponentContext context) { |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 301 | impl.withdrawIntercepts(); |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 302 | packetService.removeProcessor(processor); |
Deepa Vaddireddy | b9c24c6 | 2017-09-21 13:45:30 +0530 | [diff] [blame] | 303 | netCfgService.removeListener(cfgListener); |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 304 | cfgService.unregisterProperties(getClass(), false); |
Jonathan Hart | 5db4453 | 2018-07-12 18:13:54 -0700 | [diff] [blame] | 305 | StateMachine.unsetDelegate(delegate); |
Deepa Vaddireddy | e0e1072 | 2017-09-27 05:00:10 +0530 | [diff] [blame] | 306 | StateMachine.destroyMaps(); |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 307 | impl.deactivate(); |
Amit Ghosh | f739be5 | 2017-09-21 15:49:37 +0100 | [diff] [blame] | 308 | deviceService.removeListener(deviceListener); |
Jonathan Hart | 5db4453 | 2018-07-12 18:13:54 -0700 | [diff] [blame] | 309 | eventDispatcher.removeSink(AuthenticationEvent.class); |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 310 | scheduledFuture.cancel(true); |
Shubham Sharma | 4900ce6 | 2019-06-19 14:18:50 +0000 | [diff] [blame] | 311 | scheduledStatusServerChecker.cancel(true); |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 312 | executor.shutdown(); |
Jian Li | 13c6716 | 2015-12-09 13:20:34 -0800 | [diff] [blame] | 313 | log.info("Stopped"); |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 314 | } |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 315 | @Modified |
| 316 | public void modified(ComponentContext context) { |
Shubham Sharma | 4900ce6 | 2019-06-19 14:18:50 +0000 | [diff] [blame] | 317 | 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 dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 345 | } |
| 346 | |
Shubham Sharma | cf5e503 | 2019-11-26 11:09:21 +0000 | [diff] [blame] | 347 | protected void configureRadiusCommunication() { |
Deepa Vaddireddy | e0e1072 | 2017-09-27 05:00:10 +0530 | [diff] [blame] | 348 | 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 Das | e72358a | 2018-11-13 21:56:46 -0800 | [diff] [blame] | 362 | case "att": |
| 363 | pktCustomizer = new AttPacketCustomizer(customInfo); |
| 364 | log.info("Created AttPacketCustomizer"); |
| 365 | break; |
Deepa Vaddireddy | e0e1072 | 2017-09-27 05:00:10 +0530 | [diff] [blame] | 366 | default: |
| 367 | pktCustomizer = new PacketCustomizer(customInfo); |
| 368 | log.info("Created default PacketCustomizer"); |
| 369 | break; |
| 370 | } |
| 371 | } |
| 372 | |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 373 | 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 Kushwaha | 056e4cd | 2019-08-06 13:16:25 +0000 | [diff] [blame] | 388 | private void checkReceivedPacketForValidValidator(RADIUS radiusPacket, byte[] requestAuthenticator) { |
| 389 | if (!checkResponseMessageAuthenticator(radiusSecret, radiusPacket, requestAuthenticator)) { |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 390 | aaaStatisticsManager.getAaaStats().increaseInvalidValidatorsRx(); |
| 391 | } |
| 392 | } |
Vijaykumar Kushwaha | 056e4cd | 2019-08-06 13:16:25 +0000 | [diff] [blame] | 393 | |
| 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 dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 415 | public void checkForPacketFromUnknownServer(String hostAddress) { |
| 416 | if (!hostAddress.equals(configuredAaaServerAddress)) { |
Vijaykumar Kushwaha | fffd3d1 | 2019-08-01 11:09:59 +0000 | [diff] [blame] | 417 | getConfiguredAaaServerAddress(); |
| 418 | if (!hostAddress.equals(configuredAaaServerAddress)) { |
| 419 | aaaStatisticsManager.getAaaStats().incrementUnknownServerRx(); |
| 420 | } |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 421 | } |
| 422 | } |
| 423 | |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 424 | /** |
| 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 dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 431 | outPacketSet.add(radiusPacket.getIdentifier()); |
| 432 | aaaStatisticsManager.getAaaStats().increaseOrDecreasePendingRequests(true); |
| 433 | aaaStatisticsManager.getAaaStats().increaseAccessRequestsTx(); |
Shubham Sharma | 4900ce6 | 2019-06-19 14:18:50 +0000 | [diff] [blame] | 434 | aaaStatisticsManager.putOutgoingIdentifierToMap(radiusPacket.getIdentifier()); |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 435 | impl.sendRadiusPacket(radiusPacket, inPkt); |
| 436 | } |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 437 | |
Shubham Sharma | 1e43c56 | 2019-06-19 14:18:12 +0000 | [diff] [blame] | 438 | /** |
| 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 Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 454 | * 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 Hart | 4731dd9 | 2018-05-02 17:30:05 -0700 | [diff] [blame] | 458 | * @throws DeserializationException if packet deserialization fails |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 459 | */ |
Jonathan Hart | 4731dd9 | 2018-05-02 17:30:05 -0700 | [diff] [blame] | 460 | public void handleRadiusPacket(RADIUS radiusPacket) |
| 461 | throws StateMachineException, DeserializationException { |
Saurav Das | 987441a | 2018-09-18 16:33:47 -0700 | [diff] [blame] | 462 | if (log.isTraceEnabled()) { |
| 463 | log.trace("Received RADIUS packet {}", radiusPacket); |
| 464 | } |
Shubham Sharma | 4900ce6 | 2019-06-19 14:18:50 +0000 | [diff] [blame] | 465 | if (radiusOperationalStatusService.isRadiusResponseForOperationalStatus(radiusPacket.getIdentifier())) { |
| 466 | radiusOperationalStatusService.handleRadiusPacketForOperationalStatus(radiusPacket); |
| 467 | return; |
| 468 | } |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 469 | StateMachine stateMachine = StateMachine.lookupStateMachineById(radiusPacket.getIdentifier()); |
| 470 | if (stateMachine == null) { |
Saurav Das | 987441a | 2018-09-18 16:33:47 -0700 | [diff] [blame] | 471 | log.error("Invalid packet identifier {}, could not find corresponding " |
| 472 | + "state machine ... exiting", radiusPacket.getIdentifier()); |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 473 | aaaStatisticsManager.getAaaStats().incrementNumberOfSessionsExpired(); |
| 474 | aaaStatisticsManager.getAaaStats().countDroppedResponsesRx(); |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 475 | return; |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 476 | } |
Kartikey Dubey | adeb26e | 2019-10-01 12:18:35 +0000 | [diff] [blame^] | 477 | |
| 478 | //instance of StateMachine using the sessionId for updating machine stats |
| 479 | StateMachine machineStats = StateMachine.lookupStateMachineBySessionId(stateMachine.sessionId()); |
| 480 | |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 481 | EAP eapPayload; |
| 482 | Ethernet eth; |
Vijaykumar Kushwaha | 056e4cd | 2019-08-06 13:16:25 +0000 | [diff] [blame] | 483 | checkReceivedPacketForValidValidator(radiusPacket, stateMachine.requestAuthenticator()); |
Kartikey Dubey | adeb26e | 2019-10-01 12:18:35 +0000 | [diff] [blame^] | 484 | |
| 485 | //increasing packets and octets received from server |
| 486 | machineStats.incrementTotalPacketsReceived(); |
| 487 | machineStats.incrementTotalOctetReceived(radiusPacket.decapsulateMessage().getLength()); |
| 488 | |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 489 | if (outPacketSet.contains(radiusPacket.getIdentifier())) { |
| 490 | aaaStatisticsManager.getAaaStats().increaseOrDecreasePendingRequests(false); |
| 491 | outPacketSet.remove(new Byte(radiusPacket.getIdentifier())); |
| 492 | } |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 493 | switch (radiusPacket.getCode()) { |
| 494 | case RADIUS.RADIUS_CODE_ACCESS_CHALLENGE: |
Matt Jeanneret | 2ff1a78 | 2018-06-13 15:24:25 -0400 | [diff] [blame] | 495 | log.debug("RADIUS packet: RADIUS_CODE_ACCESS_CHALLENGE"); |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 496 | 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 Jeanneret | 2ff1a78 | 2018-06-13 15:24:25 -0400 | [diff] [blame] | 508 | log.debug("Send EAP challenge response to supplicant {}", stateMachine.supplicantAddress().toString()); |
Shubham Sharma | 1f19358 | 2019-07-11 12:12:41 +0000 | [diff] [blame] | 509 | sendPacketToSupplicant(eth, stateMachine.supplicantConnectpoint(), true); |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 510 | aaaStatisticsManager.getAaaStats().increaseChallengeResponsesRx(); |
Shubham Sharma | 3c8c702 | 2019-09-13 10:39:47 +0000 | [diff] [blame] | 511 | outPacketSupp.add(eapPayload.getIdentifier()); |
| 512 | aaaStatisticsManager.getAaaStats().incrementPendingResSupp(); |
Kartikey Dubey | adeb26e | 2019-10-01 12:18:35 +0000 | [diff] [blame^] | 513 | //increasing packets send to server |
| 514 | machineStats.incrementTotalPacketsSent(); |
| 515 | machineStats.incrementTotalOctetSent(eapPayload.getLength()); |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 516 | break; |
| 517 | case RADIUS.RADIUS_CODE_ACCESS_ACCEPT: |
Matt Jeanneret | 2ff1a78 | 2018-06-13 15:24:25 -0400 | [diff] [blame] | 518 | log.debug("RADIUS packet: RADIUS_CODE_ACCESS_ACCEPT"); |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 519 | //send an EAPOL - Success to the supplicant. |
| 520 | byte[] eapMessageSuccess = |
| 521 | radiusPacket.getAttribute(RADIUSAttribute.RADIUS_ATTR_EAP_MESSAGE).getValue(); |
Jonathan Hart | 4731dd9 | 2018-05-02 17:30:05 -0700 | [diff] [blame] | 522 | eapPayload = EAP.deserializer().deserialize( |
| 523 | eapMessageSuccess, 0, eapMessageSuccess.length); |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 524 | eth = buildEapolResponse(stateMachine.supplicantAddress(), |
| 525 | MacAddress.valueOf(nasMacAddress), |
| 526 | stateMachine.vlanId(), |
| 527 | EAPOL.EAPOL_PACKET, |
| 528 | eapPayload, stateMachine.priorityCode()); |
Matt Jeanneret | 2ff1a78 | 2018-06-13 15:24:25 -0400 | [diff] [blame] | 529 | log.info("Send EAP success message to supplicant {}", stateMachine.supplicantAddress().toString()); |
Shubham Sharma | 1f19358 | 2019-07-11 12:12:41 +0000 | [diff] [blame] | 530 | sendPacketToSupplicant(eth, stateMachine.supplicantConnectpoint(), false); |
| 531 | aaaStatisticsManager.getAaaStats().incrementEapolAuthSuccessTrans(); |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 532 | |
| 533 | stateMachine.authorizeAccess(); |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 534 | aaaStatisticsManager.getAaaStats().increaseAcceptResponsesRx(); |
Kartikey Dubey | adeb26e | 2019-10-01 12:18:35 +0000 | [diff] [blame^] | 535 | //increasing packets send to server |
| 536 | machineStats.incrementTotalPacketsSent(); |
| 537 | machineStats.incrementTotalOctetSent(eapPayload.getLength()); |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 538 | break; |
| 539 | case RADIUS.RADIUS_CODE_ACCESS_REJECT: |
Matt Jeanneret | 2ff1a78 | 2018-06-13 15:24:25 -0400 | [diff] [blame] | 540 | log.debug("RADIUS packet: RADIUS_CODE_ACCESS_REJECT"); |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 541 | //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 Hart | 4731dd9 | 2018-05-02 17:30:05 -0700 | [diff] [blame] | 551 | eapPayload = EAP.deserializer().deserialize( |
| 552 | eapMessageFailure, 0, eapMessageFailure.length); |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 553 | } |
| 554 | eth = buildEapolResponse(stateMachine.supplicantAddress(), |
| 555 | MacAddress.valueOf(nasMacAddress), |
| 556 | stateMachine.vlanId(), |
| 557 | EAPOL.EAPOL_PACKET, |
| 558 | eapPayload, stateMachine.priorityCode()); |
Matt Jeanneret | 2ff1a78 | 2018-06-13 15:24:25 -0400 | [diff] [blame] | 559 | log.warn("Send EAP failure message to supplicant {}", stateMachine.supplicantAddress().toString()); |
Shubham Sharma | 1f19358 | 2019-07-11 12:12:41 +0000 | [diff] [blame] | 560 | sendPacketToSupplicant(eth, stateMachine.supplicantConnectpoint(), false); |
| 561 | aaaStatisticsManager.getAaaStats().incrementEapolauthFailureTrans(); |
| 562 | |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 563 | stateMachine.denyAccess(); |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 564 | aaaStatisticsManager.getAaaStats().increaseRejectResponsesRx(); |
Kartikey Dubey | adeb26e | 2019-10-01 12:18:35 +0000 | [diff] [blame^] | 565 | //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 Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 572 | break; |
| 573 | default: |
| 574 | log.warn("Unknown RADIUS message received with code: {}", radiusPacket.getCode()); |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 575 | aaaStatisticsManager.getAaaStats().increaseUnknownTypeRx(); |
Kartikey Dubey | adeb26e | 2019-10-01 12:18:35 +0000 | [diff] [blame^] | 576 | //increasing packets received to server |
| 577 | machineStats.incrementTotalPacketsReceived(); |
| 578 | machineStats.incrementTotalOctetReceived(radiusPacket.decapsulateMessage().getLength()); |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 579 | } |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 580 | aaaStatisticsManager.getAaaStats().countDroppedResponsesRx(); |
Aaron Kruglikov | d39d99e | 2015-07-03 13:30:57 -0700 | [diff] [blame] | 581 | } |
| 582 | |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 583 | /** |
| 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 Sharma | 1f19358 | 2019-07-11 12:12:41 +0000 | [diff] [blame] | 589 | private void sendPacketToSupplicant(Ethernet ethernetPkt, ConnectPoint connectPoint, boolean isChallengeResponse) { |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 590 | TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(connectPoint.port()).build(); |
| 591 | OutboundPacket packet = new DefaultOutboundPacket(connectPoint.deviceId(), |
| 592 | treatment, ByteBuffer.wrap(ethernetPkt.serialize())); |
Shubham Sharma | 1f19358 | 2019-07-11 12:12:41 +0000 | [diff] [blame] | 593 | EAPOL eap = ((EAPOL) ethernetPkt.getPayload()); |
| 594 | EAP eapPkt = (EAP) eap.getPayload(); |
Saurav Das | 987441a | 2018-09-18 16:33:47 -0700 | [diff] [blame] | 595 | if (log.isTraceEnabled()) { |
Saurav Das | 987441a | 2018-09-18 16:33:47 -0700 | [diff] [blame] | 596 | log.trace("Sending eapol payload {} enclosed in {} to supplicant at {}", |
| 597 | eap, ethernetPkt, connectPoint); |
| 598 | } |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 599 | packetService.emit(packet); |
Shubham Sharma | 1f19358 | 2019-07-11 12:12:41 +0000 | [diff] [blame] | 600 | if (isChallengeResponse) { |
| 601 | aaaStatisticsManager.getAaaStats().incrementEapPktTxauthEap(); |
| 602 | } |
Shubham Sharma | 3c8c702 | 2019-09-13 10:39:47 +0000 | [diff] [blame] | 603 | aaaStatisticsManager.getAaaStats().incrementEapolFramesTx(); |
| 604 | aaaStatisticsManager.getAaaStats().countReqEapFramesTx(); |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 605 | } |
| 606 | |
Matt Jeanneret | 2ff1a78 | 2018-06-13 15:24:25 -0400 | [diff] [blame] | 607 | @Override |
| 608 | public String toString() { |
| 609 | return ToStringBuilder.reflectionToString(this); |
| 610 | } |
| 611 | |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 612 | // 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 Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 627 | |
Ray Milkey | f51eba2 | 2015-09-25 10:24:23 -0700 | [diff] [blame] | 628 | 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 Milkey | f51eba2 | 2015-09-25 10:24:23 -0700 | [diff] [blame] | 634 | default: |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 635 | // any other packets let the specific implementation handle |
| 636 | impl.handlePacketFromServer(context); |
Ray Milkey | f51eba2 | 2015-09-25 10:24:23 -0700 | [diff] [blame] | 637 | } |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 638 | } catch (StateMachineException e) { |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 639 | log.warn("Unable to process packet:", e); |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 640 | } |
| 641 | } |
| 642 | |
Ray Milkey | 9eb293f | 2015-09-30 15:09:17 -0700 | [diff] [blame] | 643 | /** |
| 644 | * Creates and initializes common fields of a RADIUS packet. |
| 645 | * |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 646 | * @param stateMachine state machine for the request |
Ray Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 647 | * @param eapPacket EAP packet |
Ray Milkey | 9eb293f | 2015-09-30 15:09:17 -0700 | [diff] [blame] | 648 | * @return RADIUS packet |
| 649 | */ |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 650 | private RADIUS getRadiusPayload(StateMachine stateMachine, byte identifier, EAP eapPacket) { |
Ray Milkey | 9eb293f | 2015-09-30 15:09:17 -0700 | [diff] [blame] | 651 | RADIUS radiusPayload = |
| 652 | new RADIUS(RADIUS.RADIUS_CODE_ACCESS_REQUEST, |
| 653 | eapPacket.getIdentifier()); |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 654 | |
| 655 | // set Request Authenticator in StateMachine |
| 656 | stateMachine.setRequestAuthenticator(radiusPayload.generateAuthCode()); |
| 657 | |
Ray Milkey | 9eb293f | 2015-09-30 15:09:17 -0700 | [diff] [blame] | 658 | radiusPayload.setIdentifier(identifier); |
| 659 | radiusPayload.setAttribute(RADIUSAttribute.RADIUS_ATTR_USERNAME, |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 660 | stateMachine.username()); |
Ray Milkey | 9eb293f | 2015-09-30 15:09:17 -0700 | [diff] [blame] | 661 | |
| 662 | radiusPayload.setAttribute(RADIUSAttribute.RADIUS_ATTR_NAS_IP, |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 663 | AaaManager.this.nasIpAddress.getAddress()); |
Ray Milkey | 9eb293f | 2015-09-30 15:09:17 -0700 | [diff] [blame] | 664 | |
| 665 | radiusPayload.encapsulateMessage(eapPacket); |
Ray Milkey | 9eb293f | 2015-09-30 15:09:17 -0700 | [diff] [blame] | 666 | |
| 667 | return radiusPayload; |
| 668 | } |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 669 | |
| 670 | /** |
Jonathan Hart | a46dddf | 2015-06-30 15:31:20 -0700 | [diff] [blame] | 671 | * Handles PAE packets (supplicant). |
| 672 | * |
| 673 | * @param inPacket Ethernet packet coming from the supplicant |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 674 | */ |
Ray Milkey | f51eba2 | 2015-09-25 10:24:23 -0700 | [diff] [blame] | 675 | private void handleSupplicantPacket(InboundPacket inPacket) throws StateMachineException { |
Jonathan Hart | a46dddf | 2015-06-30 15:31:20 -0700 | [diff] [blame] | 676 | Ethernet ethPkt = inPacket.parsed(); |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 677 | // Where does it come from? |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 678 | MacAddress srcMac = ethPkt.getSourceMAC(); |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 679 | |
Jonathan Hart | a46dddf | 2015-06-30 15:31:20 -0700 | [diff] [blame] | 680 | DeviceId deviceId = inPacket.receivedFrom().deviceId(); |
| 681 | PortNumber portNumber = inPacket.receivedFrom().port(); |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 682 | String sessionId = deviceId.toString() + portNumber.toString(); |
Saurav Das | 987441a | 2018-09-18 16:33:47 -0700 | [diff] [blame] | 683 | 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 Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 688 | } |
Jonathan Hart | a46dddf | 2015-06-30 15:31:20 -0700 | [diff] [blame] | 689 | |
Shubham Sharma | 3c8c702 | 2019-09-13 10:39:47 +0000 | [diff] [blame] | 690 | 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 Das | 987441a | 2018-09-18 16:33:47 -0700 | [diff] [blame] | 704 | 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 Dubey | adeb26e | 2019-10-01 12:18:35 +0000 | [diff] [blame^] | 711 | stateMachine.setEapolTypeVal(eapol.getEapolType()); |
Saurav Das | 987441a | 2018-09-18 16:33:47 -0700 | [diff] [blame] | 712 | } |
| 713 | |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 714 | switch (eapol.getEapolType()) { |
| 715 | case EAPOL.EAPOL_START: |
Matt Jeanneret | 2ff1a78 | 2018-06-13 15:24:25 -0400 | [diff] [blame] | 716 | log.debug("EAP packet: EAPOL_START"); |
Ray Milkey | f51eba2 | 2015-09-25 10:24:23 -0700 | [diff] [blame] | 717 | stateMachine.setSupplicantConnectpoint(inPacket.receivedFrom()); |
Shubham Sharma | 1e43c56 | 2019-06-19 14:18:12 +0000 | [diff] [blame] | 718 | if (stateMachine.getCleanupTimer() == null) { |
| 719 | scheduleStateMachineCleanupTimer(sessionId, stateMachine); |
| 720 | } |
Jonathan Hart | 5db4453 | 2018-07-12 18:13:54 -0700 | [diff] [blame] | 721 | stateMachine.start(); |
Shubham Sharma | 1f19358 | 2019-07-11 12:12:41 +0000 | [diff] [blame] | 722 | aaaStatisticsManager.getAaaStats().incrementEapolStartReqTrans(); |
Ray Milkey | f51eba2 | 2015-09-25 10:24:23 -0700 | [diff] [blame] | 723 | //send an EAP Request/Identify to the supplicant |
| 724 | EAP eapPayload = new EAP(EAP.REQUEST, stateMachine.identifier(), EAP.ATTR_IDENTITY, null); |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 725 | if (ethPkt.getVlanID() != Ethernet.VLAN_UNTAGGED) { |
| 726 | stateMachine.setPriorityCode(ethPkt.getPriorityCode()); |
| 727 | } |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 728 | Ethernet eth = buildEapolResponse(srcMac, MacAddress.valueOf(nasMacAddress), |
Ray Milkey | f51eba2 | 2015-09-25 10:24:23 -0700 | [diff] [blame] | 729 | ethPkt.getVlanID(), EAPOL.EAPOL_PACKET, |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 730 | eapPayload, stateMachine.priorityCode()); |
Matt Jeanneret | 2ff1a78 | 2018-06-13 15:24:25 -0400 | [diff] [blame] | 731 | |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 732 | stateMachine.setSupplicantAddress(srcMac); |
Ray Milkey | f51eba2 | 2015-09-25 10:24:23 -0700 | [diff] [blame] | 733 | stateMachine.setVlanId(ethPkt.getVlanID()); |
Matt Jeanneret | 2ff1a78 | 2018-06-13 15:24:25 -0400 | [diff] [blame] | 734 | log.debug("Getting EAP identity from supplicant {}", stateMachine.supplicantAddress().toString()); |
Shubham Sharma | 1f19358 | 2019-07-11 12:12:41 +0000 | [diff] [blame] | 735 | sendPacketToSupplicant(eth, stateMachine.supplicantConnectpoint(), false); |
Shubham Sharma | 3c8c702 | 2019-09-13 10:39:47 +0000 | [diff] [blame] | 736 | aaaStatisticsManager.getAaaStats().incrementRequestIdFramesTx(); |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 737 | |
| 738 | break; |
Qianqian Hu | b55a1ac | 2015-12-23 20:44:48 +0800 | [diff] [blame] | 739 | case EAPOL.EAPOL_LOGOFF: |
Matt Jeanneret | 2ff1a78 | 2018-06-13 15:24:25 -0400 | [diff] [blame] | 740 | log.debug("EAP packet: EAPOL_LOGOFF"); |
Kartikey Dubey | adeb26e | 2019-10-01 12:18:35 +0000 | [diff] [blame^] | 741 | //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 Milkey | b34b496 | 2016-01-04 10:24:43 -0800 | [diff] [blame] | 750 | if (stateMachine.state() == StateMachine.STATE_AUTHORIZED) { |
| 751 | stateMachine.logoff(); |
Shubham Sharma | 1f19358 | 2019-07-11 12:12:41 +0000 | [diff] [blame] | 752 | aaaStatisticsManager.getAaaStats().incrementEapolLogoffRx(); |
Qianqian Hu | b55a1ac | 2015-12-23 20:44:48 +0800 | [diff] [blame] | 753 | } |
Shubham Sharma | 3c8c702 | 2019-09-13 10:39:47 +0000 | [diff] [blame] | 754 | if (stateMachine.state() == StateMachine.STATE_IDLE) { |
| 755 | aaaStatisticsManager.getAaaStats().incrementAuthStateIdle(); |
| 756 | } |
Qianqian Hu | b55a1ac | 2015-12-23 20:44:48 +0800 | [diff] [blame] | 757 | |
| 758 | break; |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 759 | case EAPOL.EAPOL_PACKET: |
Ray Milkey | f51eba2 | 2015-09-25 10:24:23 -0700 | [diff] [blame] | 760 | RADIUS radiusPayload; |
Ray Milkey | 9eb293f | 2015-09-30 15:09:17 -0700 | [diff] [blame] | 761 | // check if this is a Response/Identify or a Response/TLS |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 762 | EAP eapPacket = (EAP) eapol.getPayload(); |
Shubham Sharma | 3c8c702 | 2019-09-13 10:39:47 +0000 | [diff] [blame] | 763 | Byte identifier = new Byte(eapPacket.getIdentifier()); |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 764 | |
| 765 | byte dataType = eapPacket.getDataType(); |
| 766 | switch (dataType) { |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 767 | |
Ray Milkey | 9eb293f | 2015-09-30 15:09:17 -0700 | [diff] [blame] | 768 | case EAP.ATTR_IDENTITY: |
Matt Jeanneret | 2ff1a78 | 2018-06-13 15:24:25 -0400 | [diff] [blame] | 769 | log.debug("EAP packet: EAPOL_PACKET ATTR_IDENTITY"); |
Shubham Sharma | 1e43c56 | 2019-06-19 14:18:12 +0000 | [diff] [blame] | 770 | //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 Milkey | 9eb293f | 2015-09-30 15:09:17 -0700 | [diff] [blame] | 774 | // request id access to RADIUS |
| 775 | stateMachine.setUsername(eapPacket.getData()); |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 776 | |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 777 | radiusPayload = getRadiusPayload(stateMachine, stateMachine.identifier(), eapPacket); |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 778 | radiusPayload = pktCustomizer.customizePacket(radiusPayload, inPacket); |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 779 | radiusPayload.addMessageAuthenticator(AaaManager.this.radiusSecret); |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 780 | |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 781 | sendRadiusPacket(radiusPayload, inPacket); |
Shubham Sharma | 1e43c56 | 2019-06-19 14:18:12 +0000 | [diff] [blame] | 782 | stateMachine.setWaitingForRadiusResponse(true); |
Shubham Sharma | 1f19358 | 2019-07-11 12:12:41 +0000 | [diff] [blame] | 783 | aaaStatisticsManager.getAaaStats().incrementEapolAtrrIdentity(); |
Ray Milkey | 9eb293f | 2015-09-30 15:09:17 -0700 | [diff] [blame] | 784 | // change the state to "PENDING" |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 785 | if (stateMachine.state() == StateMachine.STATE_PENDING) { |
| 786 | aaaStatisticsManager.getAaaStats().increaseRequestReTx(); |
Kartikey Dubey | adeb26e | 2019-10-01 12:18:35 +0000 | [diff] [blame^] | 787 | stateMachine.incrementTotalPacketsSent(); |
| 788 | stateMachine.incrementTotalOctetSent(eapol.getPacketLength()); |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 789 | } |
Ray Milkey | 9eb293f | 2015-09-30 15:09:17 -0700 | [diff] [blame] | 790 | stateMachine.requestAccess(); |
| 791 | break; |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 792 | case EAP.ATTR_MD5: |
Shubham Sharma | 1e43c56 | 2019-06-19 14:18:12 +0000 | [diff] [blame] | 793 | stateMachine.setLastPacketReceivedTime(System.currentTimeMillis()); |
Matt Jeanneret | 2ff1a78 | 2018-06-13 15:24:25 -0400 | [diff] [blame] | 794 | log.debug("EAP packet: EAPOL_PACKET ATTR_MD5"); |
Ray Milkey | 9eb293f | 2015-09-30 15:09:17 -0700 | [diff] [blame] | 795 | // verify if the EAP identifier corresponds to the |
| 796 | // challenge identifier from the client state |
| 797 | // machine. |
Ray Milkey | f61a24e | 2015-09-24 16:34:02 -0700 | [diff] [blame] | 798 | if (eapPacket.getIdentifier() == stateMachine.challengeIdentifier()) { |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 799 | //send the RADIUS challenge response |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 800 | radiusPayload = |
| 801 | getRadiusPayload(stateMachine, |
| 802 | stateMachine.identifier(), |
| 803 | eapPacket); |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 804 | radiusPayload = pktCustomizer.customizePacket(radiusPayload, inPacket); |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 805 | |
Qianqian Hu | b55a1ac | 2015-12-23 20:44:48 +0800 | [diff] [blame] | 806 | if (stateMachine.challengeState() != null) { |
| 807 | radiusPayload.setAttribute(RADIUSAttribute.RADIUS_ATTR_STATE, |
| 808 | stateMachine.challengeState()); |
| 809 | } |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 810 | radiusPayload.addMessageAuthenticator(AaaManager.this.radiusSecret); |
Shubham Sharma | 3c8c702 | 2019-09-13 10:39:47 +0000 | [diff] [blame] | 811 | if (outPacketSupp.contains(eapPacket.getIdentifier())) { |
| 812 | aaaStatisticsManager.getAaaStats().decrementPendingResSupp(); |
| 813 | outPacketSupp.remove(identifier); |
| 814 | } |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 815 | sendRadiusPacket(radiusPayload, inPacket); |
Shubham Sharma | 1e43c56 | 2019-06-19 14:18:12 +0000 | [diff] [blame] | 816 | stateMachine.setWaitingForRadiusResponse(true); |
Shubham Sharma | 1f19358 | 2019-07-11 12:12:41 +0000 | [diff] [blame] | 817 | aaaStatisticsManager.getAaaStats().incrementEapolMd5RspChall(); |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 818 | } |
| 819 | break; |
| 820 | case EAP.ATTR_TLS: |
Matt Jeanneret | 2ff1a78 | 2018-06-13 15:24:25 -0400 | [diff] [blame] | 821 | log.debug("EAP packet: EAPOL_PACKET ATTR_TLS"); |
Ray Milkey | 9eb293f | 2015-09-30 15:09:17 -0700 | [diff] [blame] | 822 | // request id access to RADIUS |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 823 | radiusPayload = getRadiusPayload(stateMachine, stateMachine.identifier(), eapPacket); |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 824 | radiusPayload = pktCustomizer.customizePacket(radiusPayload, inPacket); |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 825 | |
Qianqian Hu | b55a1ac | 2015-12-23 20:44:48 +0800 | [diff] [blame] | 826 | if (stateMachine.challengeState() != null) { |
| 827 | radiusPayload.setAttribute(RADIUSAttribute.RADIUS_ATTR_STATE, |
| 828 | stateMachine.challengeState()); |
| 829 | } |
Ray Milkey | f51eba2 | 2015-09-25 10:24:23 -0700 | [diff] [blame] | 830 | stateMachine.setRequestAuthenticator(radiusPayload.generateAuthCode()); |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 831 | |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 832 | radiusPayload.addMessageAuthenticator(AaaManager.this.radiusSecret); |
Shubham Sharma | 3c8c702 | 2019-09-13 10:39:47 +0000 | [diff] [blame] | 833 | if (outPacketSupp.contains(eapPacket.getIdentifier())) { |
| 834 | aaaStatisticsManager.getAaaStats().decrementPendingResSupp(); |
| 835 | outPacketSupp.remove(identifier); |
| 836 | } |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 837 | sendRadiusPacket(radiusPayload, inPacket); |
Shubham Sharma | 1e43c56 | 2019-06-19 14:18:12 +0000 | [diff] [blame] | 838 | stateMachine.setWaitingForRadiusResponse(true); |
Shubham Sharma | 1f19358 | 2019-07-11 12:12:41 +0000 | [diff] [blame] | 839 | aaaStatisticsManager.getAaaStats().incrementEapolTlsRespChall(); |
Ray Milkey | 5493b51 | 2015-10-21 12:13:49 -0700 | [diff] [blame] | 840 | |
Ray Milkey | f3790b8 | 2015-10-21 16:28:08 -0700 | [diff] [blame] | 841 | if (stateMachine.state() != StateMachine.STATE_PENDING) { |
| 842 | stateMachine.requestAccess(); |
| 843 | } |
Ray Milkey | f51eba2 | 2015-09-25 10:24:23 -0700 | [diff] [blame] | 844 | |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 845 | break; |
| 846 | default: |
Matt Jeanneret | 2ff1a78 | 2018-06-13 15:24:25 -0400 | [diff] [blame] | 847 | log.warn("Unknown EAP packet type"); |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 848 | return; |
| 849 | } |
| 850 | break; |
| 851 | default: |
Matt Jeanneret | 2ff1a78 | 2018-06-13 15:24:25 -0400 | [diff] [blame] | 852 | log.debug("Skipping EAPOL message {}", eapol.getEapolType()); |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 853 | } |
Shubham Sharma | 1f19358 | 2019-07-11 12:12:41 +0000 | [diff] [blame] | 854 | aaaStatisticsManager.getAaaStats().countTransRespNotNak(); |
| 855 | aaaStatisticsManager.getAaaStats().countEapolResIdentityMsgTrans(); |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 856 | } |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 857 | } |
| 858 | |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 859 | /** |
Jonathan Hart | 5db4453 | 2018-07-12 18:13:54 -0700 | [diff] [blame] | 860 | * 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 Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 873 | * Configuration Listener, handles change in configuration. |
| 874 | */ |
Ray Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 875 | private class InternalConfigListener implements NetworkConfigListener { |
| 876 | |
| 877 | /** |
Ray Milkey | c9e8dcc | 2015-12-30 10:31:32 -0800 | [diff] [blame] | 878 | * Reconfigures the AAA application according to the |
| 879 | * configuration parameters passed. |
Ray Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 880 | * |
| 881 | * @param cfg configuration object |
| 882 | */ |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 883 | private void reconfigureNetwork(AaaConfig cfg) { |
Matt Jeanneret | 2ff1a78 | 2018-06-13 15:24:25 -0400 | [diff] [blame] | 884 | log.info("Reconfiguring AaaConfig from config: {}", cfg); |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 885 | |
Ray Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 886 | if (cfg == null) { |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 887 | newCfg = new AaaConfig(); |
Ray Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 888 | } 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 Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 906 | |
Deepa Vaddireddy | e0e1072 | 2017-09-27 05:00:10 +0530 | [diff] [blame] | 907 | boolean reconfigureCustomizer = false; |
| 908 | if (customizer == null || !customizer.equals(newCfg.radiusPktCustomizer())) { |
| 909 | customizer = newCfg.radiusPktCustomizer(); |
| 910 | configurePacketCustomizer(); |
| 911 | reconfigureCustomizer = true; |
| 912 | } |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 913 | |
Deepa Vaddireddy | e0e1072 | 2017-09-27 05:00:10 +0530 | [diff] [blame] | 914 | 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 Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 926 | impl.clearLocalState(); |
| 927 | impl.initializeLocalState(newCfg); |
Ray Milkey | 5d99bd1 | 2015-10-06 15:41:30 -0700 | [diff] [blame] | 928 | } |
Ray Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 929 | } |
| 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 Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 936 | event.configClass().equals(AaaConfig.class)) { |
Ray Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 937 | |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 938 | AaaConfig cfg = netCfgService.getConfig(appId, AaaConfig.class); |
Ray Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 939 | reconfigureNetwork(cfg); |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 940 | |
Matt Jeanneret | 2ff1a78 | 2018-06-13 15:24:25 -0400 | [diff] [blame] | 941 | log.info("Reconfigured: {}", cfg.toString()); |
Ray Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 942 | } |
| 943 | } |
| 944 | } |
Amit Ghosh | f739be5 | 2017-09-21 15:49:37 +0100 | [diff] [blame] | 945 | |
| 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 Dubey | adeb26e | 2019-10-01 12:18:35 +0000 | [diff] [blame^] | 956 | 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 Ghosh | f739be5 | 2017-09-21 15:49:37 +0100 | [diff] [blame] | 966 | 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 dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 978 | 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 Sharma | 1e43c56 | 2019-06-19 14:18:12 +0000 | [diff] [blame] | 995 | log.debug("TimedOutPackets----" + aaaStatisticsManager.getAaaStats().getTimedOutPackets()); |
Shubham Sharma | 1f19358 | 2019-07-11 12:12:41 +0000 | [diff] [blame] | 996 | 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 Sharma | 3c8c702 | 2019-09-13 10:39:47 +0000 | [diff] [blame] | 1008 | 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 dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 1017 | aaaStatisticsManager.getStatsDelegate(). |
| 1018 | notify(new AuthenticationStatisticsEvent(AuthenticationStatisticsEvent.Type.STATS_UPDATE, |
| 1019 | aaaStatisticsManager.getAaaStats())); |
| 1020 | } |
Shubham Sharma | 4900ce6 | 2019-06-19 14:18:50 +0000 | [diff] [blame] | 1021 | } |
| 1022 | |
| 1023 | private class ServerStatusChecker implements Runnable { |
| 1024 | @Override |
| 1025 | public void run() { |
| 1026 | log.info("Notifying RadiusOperationalStatusEvent"); |
| 1027 | radiusOperationalStatusService.checkServerOperationalStatus(); |
| 1028 | log.info("--POSTING--" + radiusOperationalStatusService.getRadiusServerOperationalStatus()); |
| 1029 | radiusOperationalStatusService.getRadiusOprStDelegate() |
| 1030 | .notify(new RadiusOperationalStatusEvent( |
| 1031 | RadiusOperationalStatusEvent.Type.RADIUS_OPERATIONAL_STATUS, |
| 1032 | radiusOperationalStatusService. |
| 1033 | getRadiusServerOperationalStatus())); |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 1034 | } |
Shubham Sharma | 4900ce6 | 2019-06-19 14:18:50 +0000 | [diff] [blame] | 1035 | |
| 1036 | } |
| 1037 | } |