Distribute authentication state amongst the cluster

Change-Id: I63f36b3e2e5830241a2cb4e1c084d9e214995d2b
diff --git a/api/src/main/java/org/opencord/aaa/AuthenticationEvent.java b/api/src/main/java/org/opencord/aaa/AuthenticationEvent.java
index 87054c0..580e10c 100644
--- a/api/src/main/java/org/opencord/aaa/AuthenticationEvent.java
+++ b/api/src/main/java/org/opencord/aaa/AuthenticationEvent.java
@@ -55,6 +55,8 @@
         TIMEOUT
     }
 
+    private AuthenticationRecord authRecord;
+
     /**
      * Creates a new authentication event.
      *
@@ -65,4 +67,25 @@
         super(type, connectPoint);
     }
 
+    /**
+     * Creates a new authentication event.
+     *
+     * @param type event type
+     * @param connectPoint port
+     * @param record information about the authentication state
+     */
+    public AuthenticationEvent(Type type, ConnectPoint connectPoint, AuthenticationRecord record) {
+        super(type, connectPoint);
+        this.authRecord = record;
+    }
+
+    /**
+     * Gets information about the authentication state.
+     *
+     * @return authentication record
+     */
+    public AuthenticationRecord authenticationRecord() {
+        return this.authRecord;
+    }
+
 }
diff --git a/api/src/main/java/org/opencord/aaa/AuthenticationRecord.java b/api/src/main/java/org/opencord/aaa/AuthenticationRecord.java
index 5433fd9..a0d099f 100644
--- a/api/src/main/java/org/opencord/aaa/AuthenticationRecord.java
+++ b/api/src/main/java/org/opencord/aaa/AuthenticationRecord.java
@@ -32,6 +32,8 @@
 
     private final String state;
 
+    private final long lastChanged;
+
     /**
      * Creates a new authentication record.
      *
@@ -39,13 +41,15 @@
      * @param username user name
      * @param supplicantAddress MAC address of supplicant
      * @param state authentication state
+     * @param lastChanged timestamp of latest activity
      */
     public AuthenticationRecord(ConnectPoint supplicantConnectPoint, byte[] username,
-                                MacAddress supplicantAddress, String state) {
+                                MacAddress supplicantAddress, String state, long lastChanged) {
         this.supplicantConnectPoint = supplicantConnectPoint;
         this.username = username;
         this.supplicantAddress = supplicantAddress;
         this.state = state;
+        this.lastChanged = lastChanged;
     }
 
     /**
@@ -83,4 +87,13 @@
     public String state() {
         return state;
     }
+
+    /**
+     * Gets the timestamp of the last activity on this authentication.
+     *
+     * @return timestamp
+     */
+    public long lastChanged() {
+        return lastChanged;
+    }
 }
diff --git a/api/src/main/java/org/opencord/aaa/AuthenticationService.java b/api/src/main/java/org/opencord/aaa/AuthenticationService.java
index c474203..3399966 100644
--- a/api/src/main/java/org/opencord/aaa/AuthenticationService.java
+++ b/api/src/main/java/org/opencord/aaa/AuthenticationService.java
@@ -19,8 +19,6 @@
 import org.onlab.packet.MacAddress;
 import org.onosproject.event.ListenerService;
 
-import java.util.List;
-
 /**
  * Service for interacting with authentication state.
  */
@@ -32,13 +30,13 @@
      *
      * @return list of authentication records
      */
-    List<AuthenticationRecord> getAuthenticationRecords();
+    Iterable<AuthenticationRecord> getAuthenticationRecords();
 
     /**
      * Removes an authentication record.
      *
      * @param mac MAC address of record to remove
-     * @return true if a record was remove, otherwise false
+     * @return true if a record was removed, otherwise false
      */
     boolean removeAuthenticationStateByMac(MacAddress mac);