+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package com.att.cmd.mgmt;\r
-\r
-import com.att.cadi.CadiException;\r
-import com.att.cadi.LocatorException;\r
-import com.att.cadi.client.Future;\r
-import com.att.cadi.client.Rcli;\r
-import com.att.cadi.client.Retryable;\r
-import com.att.cmd.AAFcli;\r
-import com.att.cmd.BaseCmd;\r
-import com.att.cmd.Cmd;\r
-import com.att.cmd.Param;\r
-import com.att.inno.env.APIException;\r
-\r
-public class Deny extends BaseCmd<Mgmt> {\r
- private final static String[] options = {"add","del"};\r
-\r
- public Deny(Mgmt mgmt) throws APIException {\r
- super(mgmt, "deny");\r
- cmds.add(new DenySomething(this,"ip","ipv4or6[,ipv4or6]*"));\r
- cmds.add(new DenySomething(this,"id","identity[,identity]*"));\r
- }\r
- \r
- public class DenySomething extends Cmd {\r
-\r
- private boolean isID;\r
-\r
- public DenySomething(Deny deny, String type, String repeatable) {\r
- super(deny, type,\r
- new Param(optionsToString(options),true),\r
- new Param(repeatable,true));\r
- isID = "id".equals(type);\r
- }\r
-\r
- @Override\r
- protected int _exec(int _idx, String... args) throws CadiException, APIException, LocatorException {\r
- int idx = _idx;\r
- String action = args[idx++];\r
- final int option = whichOption(options, action);\r
- int rv=409;\r
- for(final String name : args[idx++].split(COMMA)) {\r
- final String append;\r
- if(isID && name.indexOf("@")<0) {\r
- append='@'+ env.getProperty(AAFcli.AAF_DEFAULT_REALM);\r
- } else {\r
- append = "";\r
- }\r
- final String path = "/mgmt/deny/"+getName() + '/'+ name + append;\r
- rv = all(new Retryable<Integer>() {\r
- @Override\r
- public Integer code(Rcli<?> client) throws APIException, CadiException {\r
- int rv = 409;\r
- Future<Void> fp;\r
- String resp;\r
- switch(option) {\r
- case 0: \r
- fp = client.create(path, Void.class);\r
- resp = " added";\r
- break;\r
- default: \r
- fp = client.delete(path, Void.class);\r
- resp = " deleted";\r
- }\r
- if(fp.get(AAFcli.timeout())) {\r
- pw().println(name + append + resp + " on " + client);\r
- rv=fp.code();\r
- } else {\r
- if(rv==409)rv = fp.code();\r
- error(fp);\r
- }\r
- return rv;\r
- }\r
- });\r
- }\r
- return rv;\r
- }\r
-\r
- }\r
-\r
-}\r