blob: af1265bdb50eae622c1b372cab5a2fbe63e6d8ff [file] [log] [blame]
David K. Bainbridge62019492017-07-28 17:02:10 -07001/*
David K. Bainbridgec87de3e2017-08-17 09:54:39 -07002 * Copyright 2017-present Open Networking Foundation
David K. Bainbridge62019492017-07-28 17:02:10 -07003 *
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 Cascone58b53292019-09-30 12:35:31 -070016package org.opencord.aaa.cli;
David K. Bainbridge62019492017-07-28 17:02:10 -070017
Carmelo Cascone58b53292019-09-30 12:35:31 -070018import org.apache.karaf.shell.api.action.Argument;
19import org.apache.karaf.shell.api.action.Command;
20import org.apache.karaf.shell.api.action.lifecycle.Service;
David K. Bainbridge62019492017-07-28 17:02:10 -070021import org.onlab.packet.MacAddress;
Carmelo Cascone58b53292019-09-30 12:35:31 -070022import org.onosproject.cli.AbstractShellCommand;
Jonathan Hart612651f2019-11-25 09:21:43 -080023import org.opencord.aaa.AuthenticationService;
David K. Bainbridge62019492017-07-28 17:02:10 -070024
Jonathan Hart5db44532018-07-12 18:13:54 -070025/**
26 * Removes a AAA state machine.
27 */
Carmelo Cascone58b53292019-09-30 12:35:31 -070028@Service
David K. Bainbridge62019492017-07-28 17:02:10 -070029@Command(scope = "onos", name = "aaa-reset-device",
30 description = "Resets the authentication state machine for a given device")
31public 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 Cascone58b53292019-09-30 12:35:31 -070037 protected void doExecute() {
Jonathan Hart612651f2019-11-25 09:21:43 -080038 AuthenticationService service = get(AuthenticationService.class);
39
David K. Bainbridge62019492017-07-28 17:02:10 -070040 for (String mac : macs) {
Jonathan Hart612651f2019-11-25 09:21:43 -080041 service.removeAuthenticationStateByMac(MacAddress.valueOf(mac));
David K. Bainbridge62019492017-07-28 17:02:10 -070042 }
43 }
44}