blob: fd57f830efedaf3f3bb918eb24dbeb1993e70b9f [file] [log] [blame]
Matteo Scandolo13b28122020-05-01 10:08:07 -07001/*
2 * Copyright 2017-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 */
16package org.opencord.aaa.cli;
17
18import org.apache.karaf.shell.api.action.Command;
19import org.apache.karaf.shell.api.action.lifecycle.Service;
20import org.onosproject.cli.AbstractShellCommand;
21import org.opencord.aaa.AuthenticationRecord;
22import org.opencord.aaa.AuthenticationService;
23
24import java.util.List;
25
26import static com.google.common.collect.Lists.newArrayList;
27
28/**
29 * Removes a AAA state machine.
30 */
31@Service
32@Command(scope = "onos", name = "aaa-reset-all-devices",
33 description = "Resets the authentication state machine for a all known entries")
34public class AaaResetAllCommand extends AbstractShellCommand {
35
36 @Override
37 protected void doExecute() {
38
39 AuthenticationService authService = get(AuthenticationService.class);
40 List<AuthenticationRecord> authentications = newArrayList(authService.getAuthenticationRecords());
41
42 for (AuthenticationRecord auth : authentications) {
43 authService.removeAuthenticationStateByMac(auth.supplicantAddress());
44 }
45 }
46}