Jonathan Hart | 612651f | 2019-11-25 09:21:43 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2020-present Open Networking Foundation |
| 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 | */ |
| 16 | |
| 17 | package org.opencord.aaa; |
| 18 | |
| 19 | import org.onlab.packet.MacAddress; |
| 20 | import org.onosproject.net.ConnectPoint; |
| 21 | |
| 22 | /** |
| 23 | * Describes state of an authentication attempt. |
| 24 | */ |
| 25 | public class AuthenticationRecord { |
| 26 | |
| 27 | private final ConnectPoint supplicantConnectPoint; |
| 28 | |
| 29 | private final byte[] username; |
| 30 | |
| 31 | private final MacAddress supplicantAddress; |
| 32 | |
| 33 | private final String state; |
| 34 | |
Jonathan Hart | 9d1ce80 | 2020-01-28 10:45:08 -0800 | [diff] [blame] | 35 | private final long lastChanged; |
| 36 | |
Jonathan Hart | 612651f | 2019-11-25 09:21:43 -0800 | [diff] [blame] | 37 | /** |
| 38 | * Creates a new authentication record. |
| 39 | * |
| 40 | * @param supplicantConnectPoint connect point |
| 41 | * @param username user name |
| 42 | * @param supplicantAddress MAC address of supplicant |
| 43 | * @param state authentication state |
Jonathan Hart | 9d1ce80 | 2020-01-28 10:45:08 -0800 | [diff] [blame] | 44 | * @param lastChanged timestamp of latest activity |
Jonathan Hart | 612651f | 2019-11-25 09:21:43 -0800 | [diff] [blame] | 45 | */ |
| 46 | public AuthenticationRecord(ConnectPoint supplicantConnectPoint, byte[] username, |
Jonathan Hart | 9d1ce80 | 2020-01-28 10:45:08 -0800 | [diff] [blame] | 47 | MacAddress supplicantAddress, String state, long lastChanged) { |
Jonathan Hart | 612651f | 2019-11-25 09:21:43 -0800 | [diff] [blame] | 48 | this.supplicantConnectPoint = supplicantConnectPoint; |
| 49 | this.username = username; |
| 50 | this.supplicantAddress = supplicantAddress; |
| 51 | this.state = state; |
Jonathan Hart | 9d1ce80 | 2020-01-28 10:45:08 -0800 | [diff] [blame] | 52 | this.lastChanged = lastChanged; |
Jonathan Hart | 612651f | 2019-11-25 09:21:43 -0800 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Gets the connect point of supplicant. |
| 57 | * |
| 58 | * @return connect point |
| 59 | */ |
| 60 | public ConnectPoint supplicantConnectPoint() { |
| 61 | return supplicantConnectPoint; |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * Gets the username of supplicant. |
| 66 | * |
| 67 | * @return username |
| 68 | */ |
| 69 | public byte[] username() { |
| 70 | return username; |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * Gets the MAC address of the supplicant. |
| 75 | * |
| 76 | * @return MAC address |
| 77 | */ |
| 78 | public MacAddress supplicantAddress() { |
| 79 | return supplicantAddress; |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * Gets the current state of the authentication attempt. |
| 84 | * |
| 85 | * @return state |
| 86 | */ |
| 87 | public String state() { |
| 88 | return state; |
| 89 | } |
Jonathan Hart | 9d1ce80 | 2020-01-28 10:45:08 -0800 | [diff] [blame] | 90 | |
| 91 | /** |
| 92 | * Gets the timestamp of the last activity on this authentication. |
| 93 | * |
| 94 | * @return timestamp |
| 95 | */ |
| 96 | public long lastChanged() { |
| 97 | return lastChanged; |
| 98 | } |
Jonathan Hart | 612651f | 2019-11-25 09:21:43 -0800 | [diff] [blame] | 99 | } |