SEBA-1010-Minor version upgrade
Change-Id: Ia4a30b505c8d7718c8dcc41ecbe5b408fd617f18
diff --git a/api/pom.xml b/api/pom.xml
index d1a4c32..3b878ad 100644
--- a/api/pom.xml
+++ b/api/pom.xml
@@ -25,7 +25,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>aaa-api</artifactId>
-
+ <version>${aaa.api.version}</version>
<packaging>bundle</packaging>
<description>AAA application API</description>
diff --git a/app/app.xml b/app/app.xml
index be7371b..bd064f1 100644
--- a/app/app.xml
+++ b/app/app.xml
@@ -17,8 +17,9 @@
<app name="org.opencord.aaa" origin="ON.Lab" version="${project.version}"
category="Traffic Steering" url="http://onosproject.org" title="AAA application for CORD"
featuresRepo="mvn:${project.groupId}/${project.artifactId}/${project.version}/xml/features"
- features="${project.artifactId}" apps="org.opencord.sadis">
+ features="${project.artifactId}">
<description>${project.description}</description>
<artifact>mvn:${project.groupId}/${project.artifactId}/${project.version}</artifact>
- <artifact>mvn:${project.groupId}/aaa-api/${project.version}</artifact>
+ <artifact>mvn:${project.groupId}/aaa-api/${aaa.api.version}</artifact>
+ <artifact>mvn:${project.groupId}/sadis-api/${sadis.api.version}</artifact>
</app>
diff --git a/app/features.xml b/app/features.xml
index b90eba4..16bea48 100644
--- a/app/features.xml
+++ b/app/features.xml
@@ -18,7 +18,8 @@
<feature name="${project.artifactId}" version="${project.version}"
description="${project.description}">
<feature>onos-api</feature>
- <bundle>mvn:${project.groupId}/aaa-api/${project.version}</bundle>
+ <bundle>mvn:${project.groupId}/aaa-api/${aaa.api.version}</bundle>
<bundle>mvn:${project.groupId}/${project.artifactId}/${project.version}</bundle>
+ <bundle>mvn:${project.groupId}/sadis-api/${sadis.api.version}</bundle>
</feature>
</features>
diff --git a/app/pom.xml b/app/pom.xml
index d0f4df8..39856de 100644
--- a/app/pom.xml
+++ b/app/pom.xml
@@ -35,10 +35,6 @@
<onos.app.category>Security</onos.app.category>
<onos.app.url>http://opencord.org</onos.app.url>
<onos.app.readme>802.1x authentication service.</onos.app.readme>
- <onos.app.requires>
- org.opencord.sadis
- </onos.app.requires>
- <sadis.api.version>5.2.0</sadis.api.version>
</properties>
<dependencies>
@@ -59,7 +55,7 @@
<dependency>
<groupId>org.opencord</groupId>
<artifactId>aaa-api</artifactId>
- <version>${project.version}</version>
+ <version>${aaa.api.version}</version>
<scope>compile</scope>
</dependency>
diff --git a/app/src/main/java/org/opencord/aaa/cli/AaaShowUsersCommand.java b/app/src/main/java/org/opencord/aaa/cli/AaaShowUsersCommand.java
index 2aff8e5..e484ffa 100644
--- a/app/src/main/java/org/opencord/aaa/cli/AaaShowUsersCommand.java
+++ b/app/src/main/java/org/opencord/aaa/cli/AaaShowUsersCommand.java
@@ -93,7 +93,6 @@
annotations().value(AnnotationKeys.PORT_NAME);
}
-
String subsId = UNKNOWN;
SubscriberAndDeviceInformation subscriber = sadisService.getSubscriberInfoService().get(nasPortId);
if (subscriber != null) {
diff --git a/app/src/main/java/org/opencord/aaa/impl/AaaManager.java b/app/src/main/java/org/opencord/aaa/impl/AaaManager.java
index 02b5105..a7aeddb 100644
--- a/app/src/main/java/org/opencord/aaa/impl/AaaManager.java
+++ b/app/src/main/java/org/opencord/aaa/impl/AaaManager.java
@@ -16,7 +16,6 @@
package org.opencord.aaa.impl;
import com.google.common.base.Strings;
-import com.google.common.collect.Maps;
import static java.util.concurrent.Executors.newSingleThreadExecutor;
import static org.onlab.util.Tools.groupedThreads;
@@ -24,6 +23,7 @@
import static org.opencord.aaa.impl.OsgiPropertyConstants.*;
import static org.slf4j.LoggerFactory.getLogger;
+import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import java.net.InetAddress;
@@ -101,6 +101,7 @@
import org.osgi.service.component.annotations.Modified;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferenceCardinality;
+import org.osgi.service.component.annotations.ReferencePolicy;
import org.slf4j.Logger;
import javax.crypto.Mac;
@@ -126,7 +127,7 @@
public class AaaManager
extends AbstractListenerManager<AuthenticationEvent, AuthenticationEventListener>
implements AuthenticationService {
-
+ private static final String SADIS_NOT_RUNNING = "Sadis is not running.";
private static final String APP_NAME = "org.opencord.aaa";
private static final int STATE_MACHINE_THREADS = 3;
@@ -147,8 +148,11 @@
@Reference(cardinality = ReferenceCardinality.MANDATORY)
protected DeviceService deviceService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY)
- protected SadisService sadisService;
+ @Reference(cardinality = ReferenceCardinality.OPTIONAL,
+ bind = "bindSadisService",
+ unbind = "unbindSadisService",
+ policy = ReferencePolicy.DYNAMIC)
+ protected volatile SadisService sadisService;
@Reference(cardinality = ReferenceCardinality.MANDATORY)
protected MastershipService mastershipService;
@@ -245,8 +249,8 @@
// Configuration properties factory
private final ConfigFactory factory =
new ConfigFactory<ApplicationId, AaaConfig>(APP_SUBJECT_FACTORY,
- AaaConfig.class,
- "AAA") {
+ AaaConfig.class,
+ "AAA") {
@Override
public AaaConfig createConfig() {
return new AaaConfig();
@@ -322,11 +326,17 @@
netCfgService.registerConfigFactory(factory);
cfgService.registerProperties(getClass());
modified(context);
- subsService = sadisService.getSubscriberInfoService();
- customInfo = new CustomizationInfo(subsService, deviceService);
+ if (sadisService != null) {
+ subsService = sadisService.getSubscriberInfoService();
+ } else {
+ log.warn(SADIS_NOT_RUNNING);
+ }
+ if (customInfo == null) {
+ customInfo = new CustomizationInfo(subsService, deviceService);
+ }
cfgListener.reconfigureNetwork(netCfgService.getConfig(appId, AaaConfig.class));
log.info("Starting with config {} {}", this, newCfg);
- configureRadiusCommunication();
+ configureRadiusCommunication(false);
// register our event handler
packetService.addProcessor(processor, PacketProcessor.director(2));
StateMachine.setDelegate(delegate);
@@ -343,7 +353,6 @@
scheduledStatusServerChecker = serverStatusAndStateMachineTimeoutExecutor.scheduleAtFixedRate(
new ServerStatusChecker(), 0,
operationalStatusEventGenerationPeriodInSeconds, TimeUnit.SECONDS);
-
log.info("Started");
}
@@ -355,6 +364,7 @@
cfgService.unregisterProperties(getClass(), false);
StateMachine.unsetDelegate(delegate);
impl.deactivate();
+ impl = null;
deviceService.removeListener(deviceListener);
eventDispatcher.removeSink(AuthenticationEvent.class);
scheduledStatusServerChecker.cancel(true);
@@ -408,12 +418,53 @@
}
}
- protected void configureRadiusCommunication() {
+ protected void bindSadisService(SadisService service) {
+ sadisService = service;
+ subsService = sadisService.getSubscriberInfoService();
+ if (customInfo == null) {
+ customInfo = new CustomizationInfo(subsService, deviceService);
+ } else {
+ customInfo.updateSubscriberService(subsService);
+ }
+ if (radiusConnectionType == null) {
+ log.debug("Configuration is not init yet.");
+ } else {
+ refreshRadiusCommunication();
+ }
+ log.info("Sadis-service binds to onos.");
+ }
+
+ protected void unbindSadisService(SadisService service) {
+ sadisService = null;
+ subsService = null;
+ customInfo.updateSubscriberService(subsService);
+ refreshRadiusCommunication();
+ log.info("Sadis-service unbinds from onos.");
+ }
+
+ private void refreshRadiusCommunication() {
+ if (!radiusConnectionType.toLowerCase().equals("socket")) {
+ if (impl != null) {
+ impl.withdrawIntercepts();
+ impl.clearLocalState();
+ }
+ configureRadiusCommunication(true);
+ impl.initializeLocalState(newCfg);
+ impl.requestIntercepts();
+ }
+ }
+
+ protected void configureRadiusCommunication(boolean isUpdate) {
if (radiusConnectionType.toLowerCase().equals("socket")) {
impl = new SocketBasedRadiusCommunicator(appId, packetService, this);
} else {
- impl = new PortBasedRadiusCommunicator(appId, packetService, mastershipService,
- deviceService, subsService, pktCustomizer, this);
+ if (impl != null && isUpdate) {
+ //update subsService
+ ((PortBasedRadiusCommunicator) impl).updateSubsService(subsService);
+ } else {
+ impl = new PortBasedRadiusCommunicator(appId, packetService, mastershipService,
+ deviceService, subsService, pktCustomizer, this);
+ }
}
}
@@ -1283,7 +1334,7 @@
impl.withdrawIntercepts();
impl.clearLocalState();
}
- configureRadiusCommunication();
+ configureRadiusCommunication(false);
impl.initializeLocalState(newCfg);
impl.requestIntercepts();
} else if (impl != null) {
diff --git a/app/src/main/java/org/opencord/aaa/impl/CustomizationInfo.java b/app/src/main/java/org/opencord/aaa/impl/CustomizationInfo.java
index 9277056..ef07e65 100755
--- a/app/src/main/java/org/opencord/aaa/impl/CustomizationInfo.java
+++ b/app/src/main/java/org/opencord/aaa/impl/CustomizationInfo.java
@@ -35,6 +35,10 @@
this.devService = devService;
}
+ public void updateSubscriberService(BaseInformationService<SubscriberAndDeviceInformation> subscriberService) {
+ this.subscriberService = subscriberService;
+ }
+
public DeviceService deviceService() {
return devService;
}
diff --git a/app/src/main/java/org/opencord/aaa/impl/PortBasedRadiusCommunicator.java b/app/src/main/java/org/opencord/aaa/impl/PortBasedRadiusCommunicator.java
index 8973a5f..831a8db 100755
--- a/app/src/main/java/org/opencord/aaa/impl/PortBasedRadiusCommunicator.java
+++ b/app/src/main/java/org/opencord/aaa/impl/PortBasedRadiusCommunicator.java
@@ -62,6 +62,7 @@
* of the SDN switches.
*/
public class PortBasedRadiusCommunicator implements RadiusCommunicator {
+ private static final String SADIS_NOT_RUNNING = "Sadis is not running.";
// for verbose output
private final Logger log = getLogger(getClass());
@@ -76,7 +77,7 @@
MastershipService mastershipService;
- BaseInformationService<SubscriberAndDeviceInformation> subsService;
+ protected BaseInformationService<SubscriberAndDeviceInformation> subsService;
// to store local mapping of IP Address and Serial No of Device
private Map<Ip4Address, String> ipToSnMap;
@@ -134,7 +135,7 @@
radiusServerConnectPoint = null;
if (radiusConnectPoints != null) {
// find a connect point through a device for which we are master
- for (ConnectPoint cp: radiusConnectPoints) {
+ for (ConnectPoint cp : radiusConnectPoints) {
if (mastershipService.isLocalMaster(cp.deviceId())) {
if (deviceService.isAvailable(cp.deviceId())) {
radiusServerConnectPoint = cp;
@@ -152,6 +153,10 @@
}
}
+ public void updateSubsService(BaseInformationService<SubscriberAndDeviceInformation> subsService) {
+ this.subsService = subsService;
+ }
+
@Override
public void initializeLocalState(AaaConfig newCfg) {
if (newCfg.nasIp() != null) {
@@ -252,6 +257,12 @@
String serialNo = deviceService.getDevice(inPkt.
receivedFrom().deviceId()).serialNumber();
+ if (subsService == null) {
+ log.warn(SADIS_NOT_RUNNING);
+ aaaManager.radiusOperationalStatusService.setStatusServerReqSent(false);
+ return;
+ }
+
SubscriberAndDeviceInformation deviceInfo = subsService.get(serialNo);
if (deviceInfo == null) {
@@ -345,6 +356,12 @@
targetAddress);
return;
}
+
+ if (subsService == null) {
+ log.warn(SADIS_NOT_RUNNING);
+ return;
+ }
+
MacAddress senderMac = subsService.get(serialNo).hardwareIdentifier();
if (senderMac == null) {
log.warn("ARP resolution, MAC address not found for SN {}", serialNo);
diff --git a/app/src/main/java/org/opencord/aaa/impl/SamplePacketCustomizer.java b/app/src/main/java/org/opencord/aaa/impl/SamplePacketCustomizer.java
index 52536d1..75f23dd 100755
--- a/app/src/main/java/org/opencord/aaa/impl/SamplePacketCustomizer.java
+++ b/app/src/main/java/org/opencord/aaa/impl/SamplePacketCustomizer.java
@@ -34,9 +34,9 @@
/**
* Sample RADIUS Packet Customization.
- *
*/
-public class SamplePacketCustomizer extends PacketCustomizer {
+public class SamplePacketCustomizer extends PacketCustomizer {
+ private static final String SADIS_NOT_RUNNING = "Sadis is not running.";
private final Logger log = getLogger(getClass());
@@ -70,6 +70,11 @@
log.info("Customizing packet Port received for {}", id);
+ if (customInfo.subscriberService() == null) {
+ log.warn(SADIS_NOT_RUNNING);
+ return inPkt;
+ }
+
SubscriberAndDeviceInformation subscriber = customInfo.
subscriberService().get(id);
@@ -88,6 +93,7 @@
receivedFrom().deviceId()).serialNumber();
log.info("SampleRadiusCustomizer serial = {}", serialNo);
+
SubscriberAndDeviceInformation deviceInfo = customInfo.
subscriberService().get(serialNo);
@@ -150,6 +156,12 @@
receivedFrom().deviceId()).serialNumber();
log.info("SampleRadiusCustomzer customizer serial = {}", serialNo);
+
+ if (customInfo.subscriberService() == null) {
+ log.warn(SADIS_NOT_RUNNING);
+ return inPkt;
+ }
+
SubscriberAndDeviceInformation deviceInfo = customInfo.
subscriberService().get(serialNo);
diff --git a/app/src/test/java/org/opencord/aaa/impl/AaaStatisticsTest.java b/app/src/test/java/org/opencord/aaa/impl/AaaStatisticsTest.java
index 4442f65..e70393a 100644
--- a/app/src/test/java/org/opencord/aaa/impl/AaaStatisticsTest.java
+++ b/app/src/test/java/org/opencord/aaa/impl/AaaStatisticsTest.java
@@ -90,7 +90,7 @@
}
// changed the configuration of parent method to protected
- protected void configureRadiusCommunication() {
+ protected void configureRadiusCommunication(boolean isUpdate) {
PacketService pktService = new MockPacketService();
ApplicationId appId = new CoreServiceAdapter().registerApplication("org.opencord.aaa");
aaaManager.impl = new TestSocketBasedRadiusCommunicator(appId, pktService, aaaManager);
diff --git a/app/src/test/java/org/opencord/aaa/impl/AaaTestBase.java b/app/src/test/java/org/opencord/aaa/impl/AaaTestBase.java
index 09f5e97..61ea566 100644
--- a/app/src/test/java/org/opencord/aaa/impl/AaaTestBase.java
+++ b/app/src/test/java/org/opencord/aaa/impl/AaaTestBase.java
@@ -357,6 +357,11 @@
}
@Override
+ public void clearLocalData() {
+
+ }
+
+ @Override
public void invalidateAll() {
}
diff --git a/pom.xml b/pom.xml
index 7bf79dc..f93b08a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -30,6 +30,11 @@
<version>2.3.0-SNAPSHOT</version>
<packaging>pom</packaging>
+ <properties>
+ <sadis.api.version>5.3.0-SNAPSHOT</sadis.api.version>
+ <aaa.api.version>2.3.0-SNAPSHOT</aaa.api.version>
+ </properties>
+
<modules>
<module>app</module>
<module>api</module>
@@ -71,8 +76,10 @@
<effort>Max</effort>
<threshold>Low</threshold>
<failOnError>false</failOnError>
- <includeFilterFile>${session.executionRootDirectory}/spotbugs-security-include.xml</includeFilterFile>
- <excludeFilterFile>${session.executionRootDirectory}/spotbugs-security-exclude.xml</excludeFilterFile>
+ <includeFilterFile>${session.executionRootDirectory}/spotbugs-security-include.xml
+ </includeFilterFile>
+ <excludeFilterFile>${session.executionRootDirectory}/spotbugs-security-exclude.xml
+ </excludeFilterFile>
<plugins>
<plugin>
<groupId>com.h3xstream.findsecbugs</groupId>