David K. Bainbridge | 6201949 | 2017-07-28 17:02:10 -0700 | [diff] [blame] | 1 | /* |
David K. Bainbridge | c87de3e | 2017-08-17 09:54:39 -0700 | [diff] [blame] | 2 | * Copyright 2017-present Open Networking Foundation |
David K. Bainbridge | 6201949 | 2017-07-28 17:02:10 -0700 | [diff] [blame] | 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 | */ |
Carmelo Cascone | 58b5329 | 2019-09-30 12:35:31 -0700 | [diff] [blame] | 16 | package org.opencord.aaa.cli; |
David K. Bainbridge | 6201949 | 2017-07-28 17:02:10 -0700 | [diff] [blame] | 17 | |
Carmelo Cascone | 58b5329 | 2019-09-30 12:35:31 -0700 | [diff] [blame] | 18 | import org.apache.karaf.shell.api.action.Argument; |
| 19 | import org.apache.karaf.shell.api.action.Command; |
| 20 | import org.apache.karaf.shell.api.action.lifecycle.Service; |
David K. Bainbridge | 6201949 | 2017-07-28 17:02:10 -0700 | [diff] [blame] | 21 | import org.onlab.packet.MacAddress; |
Carmelo Cascone | 58b5329 | 2019-09-30 12:35:31 -0700 | [diff] [blame] | 22 | import org.onosproject.cli.AbstractShellCommand; |
Jonathan Hart | 612651f | 2019-11-25 09:21:43 -0800 | [diff] [blame] | 23 | import org.opencord.aaa.AuthenticationService; |
David K. Bainbridge | 6201949 | 2017-07-28 17:02:10 -0700 | [diff] [blame] | 24 | |
Jonathan Hart | 5db4453 | 2018-07-12 18:13:54 -0700 | [diff] [blame] | 25 | /** |
| 26 | * Removes a AAA state machine. |
| 27 | */ |
Carmelo Cascone | 58b5329 | 2019-09-30 12:35:31 -0700 | [diff] [blame] | 28 | @Service |
David K. Bainbridge | 6201949 | 2017-07-28 17:02:10 -0700 | [diff] [blame] | 29 | @Command(scope = "onos", name = "aaa-reset-device", |
| 30 | description = "Resets the authentication state machine for a given device") |
| 31 | public class AaaResetDeviceCommand extends AbstractShellCommand { |
| 32 | @Argument(index = 0, name = "mac", description = "MAC of device to reset authention state", |
| 33 | required = true, multiValued = true) |
| 34 | private String[] macs = null; |
| 35 | |
| 36 | @Override |
Carmelo Cascone | 58b5329 | 2019-09-30 12:35:31 -0700 | [diff] [blame] | 37 | protected void doExecute() { |
Jonathan Hart | 612651f | 2019-11-25 09:21:43 -0800 | [diff] [blame] | 38 | AuthenticationService service = get(AuthenticationService.class); |
| 39 | |
David K. Bainbridge | 6201949 | 2017-07-28 17:02:10 -0700 | [diff] [blame] | 40 | for (String mac : macs) { |
Jonathan Hart | 612651f | 2019-11-25 09:21:43 -0800 | [diff] [blame] | 41 | service.removeAuthenticationStateByMac(MacAddress.valueOf(mac)); |
David K. Bainbridge | 6201949 | 2017-07-28 17:02:10 -0700 | [diff] [blame] | 42 | } |
| 43 | } |
| 44 | } |