2 * Copyright (c) 2016, 2017 Inocybe Technologies. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.aaa.cli.dmstore;
11 import org.apache.karaf.shell.api.action.Command;
12 import org.apache.karaf.shell.api.action.Option;
13 import org.apache.karaf.shell.api.action.lifecycle.Service;
14 import org.opendaylight.aaa.cli.AaaCliAbstractCommand;
15 import org.opendaylight.aaa.cli.utils.DataStoreUtils;
23 @Command(name = "remove-grant", scope = "aaa", description = "Remove grant.")
24 public class RemoveGrant extends AaaCliAbstractCommand {
25 @Option(name = "-uname",
26 aliases = { "--userName" },
27 description = "The user name",
30 private String userName;
32 @Option(name = "-dname",
33 aliases = { "--domainName" },
34 description = "The domain name",
37 private String domainName;
39 @Option(name = "-rname",
40 aliases = { "--roleName" },
41 description = "The role name",
44 private String roleName;
47 public Object execute() throws Exception {
48 if (super.execute() == null) {
49 return LOGIN_FAILED_MESS;
51 final String grantid = DataStoreUtils.getGrantId(identityStore, domainName, roleName, userName);
52 if (grantid == null) {
53 return "Grant does not exist";
55 if (identityStore.deleteGrant(grantid) == null) {
56 return "Failed to delete grant " + userName + " " + roleName + " " + domainName;
58 return "Grant has been deleted.";