Bump ONOS to 2.2 and build with Java 11

Change-Id: I5300cecdaa991a9e238114d7cc47b2094835025a
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 35f880d..5804b78 100755
--- a/app/src/main/java/org/opencord/aaa/impl/AaaManager.java
+++ b/app/src/main/java/org/opencord/aaa/impl/AaaManager.java
@@ -27,12 +27,10 @@
 import java.util.Arrays;
 
 import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Deactivate;
-import org.apache.felix.scr.annotations.Property;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.ReferenceCardinality;
-import org.apache.felix.scr.annotations.Service;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
+import org.osgi.service.component.annotations.Reference;
+import org.osgi.service.component.annotations.ReferenceCardinality;
 import org.onlab.packet.DeserializationException;
 import org.onlab.packet.EAP;
 import org.onlab.packet.EAPOL;
@@ -77,8 +75,8 @@
 import org.opencord.sadis.SadisService;
 import org.opencord.sadis.SubscriberAndDeviceInformation;
 import org.osgi.service.component.ComponentContext;
-import org.apache.felix.scr.annotations.Modified;
-import org.apache.felix.scr.annotations.Activate;
+import org.osgi.service.component.annotations.Modified;
+import org.osgi.service.component.annotations.Activate;
 import org.slf4j.Logger;
 import com.google.common.base.Strings;
 
@@ -87,13 +85,17 @@
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 
+import static org.opencord.aaa.impl.OsgiPropertyConstants.STATISTICS_GENERATION_EVENT;
+import static org.opencord.aaa.impl.OsgiPropertyConstants.STATISTICS_GENERATION_EVENT_DEFAULT;
+
 import javax.crypto.Mac;
 import javax.crypto.spec.SecretKeySpec;
 /**
  * AAA application for ONOS.
  */
-@Service
-@Component(immediate = true)
+@Component(immediate = true, property = {
+        STATISTICS_GENERATION_EVENT + ":Integer=" + STATISTICS_GENERATION_EVENT_DEFAULT,
+})
 public class AaaManager
         extends AbstractListenerManager<AuthenticationEvent, AuthenticationEventListener>
         implements AuthenticationService {
@@ -102,38 +104,36 @@
 
     private final Logger log = getLogger(getClass());
 
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    @Reference(cardinality = ReferenceCardinality.MANDATORY)
     protected CoreService coreService;
 
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    @Reference(cardinality = ReferenceCardinality.MANDATORY)
     protected PacketService packetService;
 
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    @Reference(cardinality = ReferenceCardinality.MANDATORY)
     protected NetworkConfigRegistry netCfgService;
 
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    @Reference(cardinality = ReferenceCardinality.MANDATORY)
     protected DeviceService deviceService;
 
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    @Reference(cardinality = ReferenceCardinality.MANDATORY)
     protected SadisService sadisService;
 
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    @Reference(cardinality = ReferenceCardinality.MANDATORY)
     protected MastershipService mastershipService;
 
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    @Reference(cardinality = ReferenceCardinality.MANDATORY)
     protected AuthenticationStatisticsService aaaStatisticsManager;
 
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    @Reference(cardinality = ReferenceCardinality.MANDATORY)
     protected ComponentConfigService cfgService;
 
     protected AuthenticationStatisticsEventPublisher authenticationStatisticsPublisher;
     protected BaseInformationService<SubscriberAndDeviceInformation> subsService;
     private final DeviceListener deviceListener = new InternalDeviceListener();
 
-    private static final int DEFAULT_REPEAT_DELAY = 20;
-    @Property(name = "statisticsGenerationEvent", intValue = DEFAULT_REPEAT_DELAY,
-              label = "statisticsGenerationEvent")
-    private int statisticsGenerationEvent = DEFAULT_REPEAT_DELAY;
+    /** Statistics generation interval. */
+    private int statisticsGenerationEvent = STATISTICS_GENERATION_EVENT_DEFAULT;
 
     // NAS IP address
     protected InetAddress nasIpAddress;
@@ -280,8 +280,9 @@
     @Modified
     public void modified(ComponentContext context) {
         Dictionary<?, ?> properties = context.getProperties();
-       String s = Tools.get(properties, "statisticsGenerationEvent");
-    statisticsGenerationEvent = Strings.isNullOrEmpty(s) ? DEFAULT_REPEAT_DELAY : Integer.parseInt(s.trim());
+        String s = Tools.get(properties, STATISTICS_GENERATION_EVENT);
+        statisticsGenerationEvent = Strings.isNullOrEmpty(s)
+                ? STATISTICS_GENERATION_EVENT_DEFAULT : Integer.parseInt(s.trim());
     }
 
     private void configureRadiusCommunication() {
diff --git a/app/src/main/java/org/opencord/aaa/impl/AaaResetCountersCommand.java b/app/src/main/java/org/opencord/aaa/impl/AaaResetCountersCommand.java
deleted file mode 100644
index 79ada3b..0000000
--- a/app/src/main/java/org/opencord/aaa/impl/AaaResetCountersCommand.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.opencord.aaa.impl;
-
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.opencord.aaa.AuthenticationStatisticsService;
-
-/**
- * Reset value of all aaa statistics counters to 0.
- */
-@Command(scope = "onos", name = "reset-aaa-counters", description = "Reset value of all aaa statistics counters to 0 ")
-public class AaaResetCountersCommand extends AbstractShellCommand {
-
-    @Override
-    protected void execute() {
-        AuthenticationStatisticsService aaaStatisticsManager = AbstractShellCommand
-                .get(AuthenticationStatisticsService.class);
-        aaaStatisticsManager.resetAllCounters();
-    }
-}
diff --git a/app/src/main/java/org/opencord/aaa/impl/AaaResetDeviceCommand.java b/app/src/main/java/org/opencord/aaa/impl/AaaResetDeviceCommand.java
deleted file mode 100644
index 14b0fe1..0000000
--- a/app/src/main/java/org/opencord/aaa/impl/AaaResetDeviceCommand.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0.
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.opencord.aaa.impl;
-
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Argument;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onlab.packet.MacAddress;
-
-/**
- * Removes a AAA state machine.
- */
-@Command(scope = "onos", name = "aaa-reset-device",
-         description = "Resets the authentication state machine for a given device")
-public class AaaResetDeviceCommand extends AbstractShellCommand {
-    @Argument(index = 0, name = "mac", description = "MAC of device to reset authention state",
-              required = true, multiValued = true)
-    private String[] macs = null;
-
-    @Override
-    protected void execute() {
-        for (String mac : macs) {
-            StateMachine.deleteByMac(MacAddress.valueOf(mac));
-        }
-    }
-}
diff --git a/app/src/main/java/org/opencord/aaa/impl/AaaShowCountersCommand.java b/app/src/main/java/org/opencord/aaa/impl/AaaShowCountersCommand.java
deleted file mode 100644
index 0717f9a..0000000
--- a/app/src/main/java/org/opencord/aaa/impl/AaaShowCountersCommand.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.opencord.aaa.impl;
-
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.opencord.aaa.AaaStatistics;
-import org.opencord.aaa.AuthenticationStatisticsService;
-
-/**
- * Display current value of all aaa statistics counters.
- */
-@Command(scope = "onos", name = "show-aaa-counters",
-description = "Display current value of all aaa statistics counters")
-public class AaaShowCountersCommand extends AbstractShellCommand {
-    @Override
-    protected void execute() {
-
-        AaaStatistics aaaStats = new AaaStatistics();
-
-        AuthenticationStatisticsService aaaStatisticsManager =
-                AbstractShellCommand.get(AuthenticationStatisticsService.class);
-        aaaStats = aaaStatisticsManager.getAaaStats();
-
-        System.out.format("%30s %10d\n", "AccessRequestsTx", aaaStats.getAccessRequestsTx());
-        System.out.format("%30s %10d\n", "ChallengeResponsesRx", aaaStats.getChallengeResponsesRx());
-        System.out.format("%30s %10d\n", "RequestReTx", aaaStats.getRequestReTx());
-        System.out.format("%30s %10d\n", "AcceptResponsesRx", aaaStats.getAcceptResponsesRx());
-        System.out.format("%30s %10d\n", "RejectResponsesRx", aaaStats.getRejectResponsesRx());
-        System.out.format("%30s %10d\n", "PendingRequests", aaaStats.getPendingRequests());
-        System.out.format("%30s %10d\n", "DroppedResponsesRx", aaaStats.getDroppedResponsesRx());
-        System.out.format("%30s %10d\n", "InvalidValidatorsRx", aaaStats.getInvalidValidatorsRx());
-        System.out.format("%30s %10d\n", "MalformedResponsesRx", aaaStats.getMalformedResponsesRx());
-        System.out.format("%30s %10d\n", "UnknownServerRx", aaaStats.getUnknownServerRx());
-        System.out.format("%30s %10d\n", "UnknownTypeRx", aaaStats.getUnknownTypeRx());
-        System.out.format("%30s %10d\n", "RequestRttMillis", aaaStats.getRequestRttMilis());
-
-  }
-}
diff --git a/app/src/main/java/org/opencord/aaa/impl/AaaShowUsersCommand.java b/app/src/main/java/org/opencord/aaa/impl/AaaShowUsersCommand.java
deleted file mode 100644
index ed117ac..0000000
--- a/app/src/main/java/org/opencord/aaa/impl/AaaShowUsersCommand.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.opencord.aaa.impl;
-
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.AnnotationKeys;
-import org.onosproject.net.device.DeviceService;
-
-import org.opencord.sadis.SadisService;
-import org.opencord.sadis.SubscriberAndDeviceInformation;
-
-/**
- * Shows the users in the aaa.
- */
-@Command(scope = "onos", name = "aaa-users",
-        description = "Shows the aaa users")
-public class AaaShowUsersCommand extends AbstractShellCommand {
-    @Override
-    protected void execute() {
-        String[] state = {
-                "IDLE",
-                "STARTED",
-                "PENDING",
-                "AUTHORIZED",
-                "UNAUTHORIZED"
-        };
-
-        DeviceService devService = AbstractShellCommand.get(DeviceService.class);
-        SadisService sadisService =
-                AbstractShellCommand.get(SadisService.class);
-
-        for (StateMachine stateMachine : StateMachine.sessionIdMap().values()) {
-            String deviceId = stateMachine.supplicantConnectpoint().deviceId().toString();
-            String portNum = stateMachine.supplicantConnectpoint().port().toString();
-
-            String username = "UNKNOWN";
-            if (stateMachine.username() != null) {
-                username = new String(stateMachine.username());
-            }
-            String mac = "UNKNOWN";
-            if (stateMachine.supplicantAddress() != null) {
-                mac = stateMachine.supplicantAddress().toString();
-            }
-
-            String nasPortId = devService.getPort(stateMachine.supplicantConnectpoint()).
-                    annotations().value(AnnotationKeys.PORT_NAME);
-
-            String subsId = "UNKNOWN";
-            SubscriberAndDeviceInformation subscriber = sadisService.getSubscriberInfoService().get(nasPortId);
-            if (subscriber != null) {
-                subsId = subscriber.nasPortId();
-            }
-
-            print("UserName=%s,CurrentState=%s,DeviceId=%s,MAC=%s,PortNumber=%s,SubscriberId=%s",
-                  username, state[stateMachine.state()], deviceId, mac, portNum, subsId);
-        }
-    }
-}
diff --git a/app/src/main/java/org/opencord/aaa/impl/AaaStatisticsManager.java b/app/src/main/java/org/opencord/aaa/impl/AaaStatisticsManager.java
index 31aad5b..5b3e439 100644
--- a/app/src/main/java/org/opencord/aaa/impl/AaaStatisticsManager.java
+++ b/app/src/main/java/org/opencord/aaa/impl/AaaStatisticsManager.java
@@ -22,20 +22,19 @@
 import java.util.Map;
 import java.util.concurrent.atomic.AtomicLong;
 
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Service;
+import org.osgi.service.component.annotations.Component;
 import org.onosproject.event.AbstractListenerManager;
 import org.opencord.aaa.AaaStatistics;
 import org.opencord.aaa.AuthenticationStatisticsDelegate;
 import org.opencord.aaa.AuthenticationStatisticsEvent;
 import org.opencord.aaa.AuthenticationStatisticsEventListener;
 import org.opencord.aaa.AuthenticationStatisticsService;
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Deactivate;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Deactivate;
 import org.slf4j.Logger;
 
 
-@Service
+
 @Component(immediate = true)
 public class AaaStatisticsManager
 extends AbstractListenerManager<AuthenticationStatisticsEvent, AuthenticationStatisticsEventListener>
diff --git a/app/src/main/java/org/opencord/aaa/impl/OsgiPropertyConstants.java b/app/src/main/java/org/opencord/aaa/impl/OsgiPropertyConstants.java
new file mode 100644
index 0000000..38f1a32
--- /dev/null
+++ b/app/src/main/java/org/opencord/aaa/impl/OsgiPropertyConstants.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2019-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.opencord.aaa.impl;
+
+/**
+ * Constants for default values of configurable properties.
+ */
+public final class OsgiPropertyConstants {
+
+    private OsgiPropertyConstants() {
+    }
+
+    public static final String STATISTICS_GENERATION_EVENT = "statisticsGenerationEvent";
+    public static final int STATISTICS_GENERATION_EVENT_DEFAULT = 20;
+}
diff --git a/app/src/main/java/org/opencord/aaa/impl/StateMachine.java b/app/src/main/java/org/opencord/aaa/impl/StateMachine.java
index 0b60c2e..9086846 100644
--- a/app/src/main/java/org/opencord/aaa/impl/StateMachine.java
+++ b/app/src/main/java/org/opencord/aaa/impl/StateMachine.java
@@ -32,7 +32,7 @@
  * AAA Finite State Machine.
  */
 
-class StateMachine {
+public class StateMachine {
     //INDEX to identify the state in the transition table
     static final int STATE_IDLE = 0;
     static final int STATE_STARTED = 1;
@@ -347,7 +347,7 @@
      *
      * @return The username.
      */
-    protected byte[] username() {
+    public byte[] username() {
         return this.username;
     }