2 * ============LICENSE_START====================================================
4 * ===========================================================================
5 * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
6 * ===========================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END====================================================
22 package org.onap.aaf.auth.cmd.mgmt;
24 import org.onap.aaf.auth.cmd.AAFcli;
25 import org.onap.aaf.auth.cmd.BaseCmd;
26 import org.onap.aaf.auth.cmd.Cmd;
27 import org.onap.aaf.auth.cmd.Param;
28 import org.onap.aaf.cadi.CadiException;
29 import org.onap.aaf.cadi.LocatorException;
30 import org.onap.aaf.cadi.client.Future;
31 import org.onap.aaf.cadi.client.Rcli;
32 import org.onap.aaf.cadi.client.Retryable;
33 import org.onap.aaf.cadi.config.Config;
34 import org.onap.aaf.misc.env.APIException;
36 public class Deny extends BaseCmd<Mgmt> {
37 private static final String[] options = {"add","del"};
39 public Deny(Mgmt mgmt) {
41 cmds.add(new DenySomething(this,"ip","ipv4or6[,ipv4or6]*"));
42 cmds.add(new DenySomething(this,"id","identity[,identity]*"));
45 public class DenySomething extends Cmd {
49 public DenySomething(Deny deny, String type, String repeatable) {
51 new Param(optionsToString(options),true),
52 new Param(repeatable,true));
53 isID = "id".equals(type);
57 protected int _exec(int idxValue, String... args) throws CadiException, APIException, LocatorException {
59 String action = args[idx++];
60 final int option = whichOption(options, action);
62 for (final String name : args[idx++].split(COMMA)) {
64 if (isID && name.indexOf("@")<0) {
65 append='@'+ access.getProperty(Config.AAF_DEFAULT_REALM,null);
69 final String path = "/mgmt/deny/"+getName() + '/'+ name + append;
70 rv = all(new Retryable<Integer>() {
72 public Integer code(Rcli<?> client) throws APIException, CadiException {
77 fp = client.create(path, Void.class);
80 fp = client.delete(path, Void.class);
83 if (fp.get(AAFcli.timeout())) {
84 pw().println(name + append + resp + " on " + client);