Refactor AAA app in preparation for clustered operation.
* Add formal API for accessing auth state information rather than directly
looking up static maps.
* Move static maps in StateMachine to non-static maps in AaaManager
* Manage identifier space used for requests/replies better
* Refactored state machine timeout mechansim
Change-Id: Ie53c3a66ac1619e10607d9926b71747a333317f3
diff --git a/api/src/main/java/org/opencord/aaa/AuthenticationEvent.java b/api/src/main/java/org/opencord/aaa/AuthenticationEvent.java
index da02ec2..87054c0 100644
--- a/api/src/main/java/org/opencord/aaa/AuthenticationEvent.java
+++ b/api/src/main/java/org/opencord/aaa/AuthenticationEvent.java
@@ -47,7 +47,12 @@
/**
* Authentication request was denied.
*/
- DENIED
+ DENIED,
+
+ /**
+ * Authentication flow timed out.
+ */
+ TIMEOUT
}
/**
diff --git a/api/src/main/java/org/opencord/aaa/AuthenticationRecord.java b/api/src/main/java/org/opencord/aaa/AuthenticationRecord.java
new file mode 100644
index 0000000..5433fd9
--- /dev/null
+++ b/api/src/main/java/org/opencord/aaa/AuthenticationRecord.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2020-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;
+
+import org.onlab.packet.MacAddress;
+import org.onosproject.net.ConnectPoint;
+
+/**
+ * Describes state of an authentication attempt.
+ */
+public class AuthenticationRecord {
+
+ private final ConnectPoint supplicantConnectPoint;
+
+ private final byte[] username;
+
+ private final MacAddress supplicantAddress;
+
+ private final String state;
+
+ /**
+ * Creates a new authentication record.
+ *
+ * @param supplicantConnectPoint connect point
+ * @param username user name
+ * @param supplicantAddress MAC address of supplicant
+ * @param state authentication state
+ */
+ public AuthenticationRecord(ConnectPoint supplicantConnectPoint, byte[] username,
+ MacAddress supplicantAddress, String state) {
+ this.supplicantConnectPoint = supplicantConnectPoint;
+ this.username = username;
+ this.supplicantAddress = supplicantAddress;
+ this.state = state;
+ }
+
+ /**
+ * Gets the connect point of supplicant.
+ *
+ * @return connect point
+ */
+ public ConnectPoint supplicantConnectPoint() {
+ return supplicantConnectPoint;
+ }
+
+ /**
+ * Gets the username of supplicant.
+ *
+ * @return username
+ */
+ public byte[] username() {
+ return username;
+ }
+
+ /**
+ * Gets the MAC address of the supplicant.
+ *
+ * @return MAC address
+ */
+ public MacAddress supplicantAddress() {
+ return supplicantAddress;
+ }
+
+ /**
+ * Gets the current state of the authentication attempt.
+ *
+ * @return state
+ */
+ public String state() {
+ return state;
+ }
+}
diff --git a/api/src/main/java/org/opencord/aaa/AuthenticationService.java b/api/src/main/java/org/opencord/aaa/AuthenticationService.java
index 82aabbd..c474203 100644
--- a/api/src/main/java/org/opencord/aaa/AuthenticationService.java
+++ b/api/src/main/java/org/opencord/aaa/AuthenticationService.java
@@ -16,11 +16,30 @@
package org.opencord.aaa;
+import org.onlab.packet.MacAddress;
import org.onosproject.event.ListenerService;
+import java.util.List;
+
/**
- * Service for interacting with authentication module.
+ * Service for interacting with authentication state.
*/
public interface AuthenticationService extends
ListenerService<AuthenticationEvent, AuthenticationEventListener> {
+
+ /**
+ * Gets records of authentications that are completed or in progress.
+ *
+ * @return list of authentication records
+ */
+ List<AuthenticationRecord> getAuthenticationRecords();
+
+ /**
+ * Removes an authentication record.
+ *
+ * @param mac MAC address of record to remove
+ * @return true if a record was remove, otherwise false
+ */
+ boolean removeAuthenticationStateByMac(MacAddress mac);
+
}