Committed by
Gerrit Code Review
adding cli for aaa to show users
Change-Id: I23092577a6da8f43b959a11b9590c282f4d50a5c
Showing
4 changed files
with
82 additions
and
0 deletions
| ... | @@ -64,6 +64,17 @@ | ... | @@ -64,6 +64,17 @@ |
| 64 | <classifier>tests</classifier> | 64 | <classifier>tests</classifier> |
| 65 | <scope>test</scope> | 65 | <scope>test</scope> |
| 66 | </dependency> | 66 | </dependency> |
| 67 | + | ||
| 68 | + <dependency> | ||
| 69 | + <groupId>org.onosproject</groupId> | ||
| 70 | + <artifactId>onos-cli</artifactId> | ||
| 71 | + <version>${project.version}</version> | ||
| 72 | + </dependency> | ||
| 73 | + | ||
| 74 | + <dependency> | ||
| 75 | + <groupId>org.apache.karaf.shell</groupId> | ||
| 76 | + <artifactId>org.apache.karaf.shell.console</artifactId> | ||
| 77 | + </dependency> | ||
| 67 | </dependencies> | 78 | </dependencies> |
| 68 | 79 | ||
| 69 | 80 | ... | ... |
| 1 | +/* | ||
| 2 | + * Copyright 2016 Open Networking Laboratory | ||
| 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 | +package org.onosproject.aaa; | ||
| 17 | + | ||
| 18 | +import org.apache.karaf.shell.commands.Command; | ||
| 19 | +import org.onosproject.cli.AbstractShellCommand; | ||
| 20 | + | ||
| 21 | +/** | ||
| 22 | + * Shows the users in the aaa. | ||
| 23 | + */ | ||
| 24 | +@Command(scope = "onos", name = "aaa-users", | ||
| 25 | + description = "Shows the aaa users") | ||
| 26 | +public class AaaShowUsersCommand extends AbstractShellCommand { | ||
| 27 | + @Override | ||
| 28 | + protected void execute() { | ||
| 29 | + String[] state = { | ||
| 30 | + "IDLE", | ||
| 31 | + "STARTED", | ||
| 32 | + "PENDING", | ||
| 33 | + "AUTHORIZED", | ||
| 34 | + "UNAUTHORIZED" | ||
| 35 | + }; | ||
| 36 | + for (StateMachine stateMachine : StateMachine.sessionIdMap().values()) { | ||
| 37 | + String deviceId = stateMachine.supplicantConnectpoint().deviceId().toString(); | ||
| 38 | + String portNum = stateMachine.supplicantConnectpoint().port().toString(); | ||
| 39 | + String username = new String(stateMachine.username()); | ||
| 40 | + print("UserName=%s,CurrentState=%s,DeviceId=%s,PortNumber=%s", | ||
| 41 | + username, state[stateMachine.state()], deviceId, portNum); | ||
| 42 | + } | ||
| 43 | + } | ||
| 44 | +} |
| ... | @@ -124,6 +124,10 @@ class StateMachine { | ... | @@ -124,6 +124,10 @@ class StateMachine { |
| 124 | identifierMap = null; | 124 | identifierMap = null; |
| 125 | } | 125 | } |
| 126 | 126 | ||
| 127 | + public static Map<String, StateMachine> sessionIdMap() { | ||
| 128 | + return sessionIdMap; | ||
| 129 | + } | ||
| 130 | + | ||
| 127 | public static StateMachine lookupStateMachineById(byte identifier) { | 131 | public static StateMachine lookupStateMachineById(byte identifier) { |
| 128 | return identifierMap.get((int) identifier); | 132 | return identifierMap.get((int) identifier); |
| 129 | } | 133 | } | ... | ... |
| 1 | +<!-- | ||
| 2 | + ~ Copyright 2016 Open Networking Laboratory | ||
| 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 | +<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"> | ||
| 17 | + | ||
| 18 | + <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0"> | ||
| 19 | + <command> | ||
| 20 | + <action class="org.onosproject.aaa.AaaShowUsersCommand"/> | ||
| 21 | + </command> | ||
| 22 | + </command-bundle> | ||
| 23 | +</blueprint> |
-
Please register or login to post a comment