summaryrefslogtreecommitdiffstats
path: root/authz-cmd/src/main/java/com/att/cmd/perm
diff options
context:
space:
mode:
Diffstat (limited to 'authz-cmd/src/main/java/com/att/cmd/perm')
-rw-r--r--authz-cmd/src/main/java/com/att/cmd/perm/Create.java164
-rw-r--r--authz-cmd/src/main/java/com/att/cmd/perm/Delete.java89
-rw-r--r--authz-cmd/src/main/java/com/att/cmd/perm/Describe.java101
-rw-r--r--authz-cmd/src/main/java/com/att/cmd/perm/Grant.java150
-rw-r--r--authz-cmd/src/main/java/com/att/cmd/perm/List.java128
-rw-r--r--authz-cmd/src/main/java/com/att/cmd/perm/ListActivity.java76
-rw-r--r--authz-cmd/src/main/java/com/att/cmd/perm/ListByNS.java71
-rw-r--r--authz-cmd/src/main/java/com/att/cmd/perm/ListByName.java69
-rw-r--r--authz-cmd/src/main/java/com/att/cmd/perm/ListByRole.java72
-rw-r--r--authz-cmd/src/main/java/com/att/cmd/perm/ListByUser.java75
-rw-r--r--authz-cmd/src/main/java/com/att/cmd/perm/Perm.java43
-rw-r--r--authz-cmd/src/main/java/com/att/cmd/perm/Rename.java102
12 files changed, 0 insertions, 1140 deletions
diff --git a/authz-cmd/src/main/java/com/att/cmd/perm/Create.java b/authz-cmd/src/main/java/com/att/cmd/perm/Create.java
deleted file mode 100644
index 2c6231f9..00000000
--- a/authz-cmd/src/main/java/com/att/cmd/perm/Create.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package com.att.cmd.perm;
-
-import com.att.aft.dme2.internal.jetty.http.HttpStatus;
-import com.att.cadi.CadiException;
-import com.att.cadi.LocatorException;
-import com.att.cadi.client.Future;
-import com.att.cadi.client.Rcli;
-import com.att.cadi.client.Retryable;
-import com.att.cmd.AAFcli;
-import com.att.cmd.Cmd;
-import com.att.cmd.Param;
-import com.att.cssa.rserv.HttpMethods;
-import com.att.inno.env.APIException;
-
-import aaf.v2_0.PermRequest;
-import aaf.v2_0.RoleRequest;
-
-/**
- *
- *
- */
-public class Create extends Cmd {
- public Create(Perm parent) {
- super(parent,"create",
- new Param("type",true),
- new Param("instance",true),
- new Param("action", true),
- new Param("role[,role]* (to Grant to)", false)
- );
- }
-
- @Override
- public int _exec(final int index, final String ... args) throws CadiException, APIException, LocatorException {
- return same(new Retryable<Integer>() {
- @Override
- public Integer code(Rcli<?> client) throws CadiException, APIException {
- int idx = index;
- final PermRequest pr = new PermRequest();
- pr.setType(args[idx++]);
- pr.setInstance(args[idx++]);
- pr.setAction(args[idx++]);
- String roleCommas = (args.length>idx)?args[idx++]:null;
- String[] roles = roleCommas==null?null:roleCommas.split("\\s*,\\s*");
- boolean force = aafcli.forceString()!=null;
- int rv;
-
- if(roles!=null && force) { // Make sure Roles are Created
- RoleRequest rr = new RoleRequest();
- for(String role : roles) {
- rr.setName(role);;
- Future<RoleRequest> fr = client.create(
- "/authz/role",
- getDF(RoleRequest.class),
- rr
- );
- fr.get(AAFcli.timeout());
- switch(fr.code()){
- case 201:
- pw().println("Created Role [" + role + ']');
- break;
- case 409:
- break;
- default:
- pw().println("Role [" + role + "] does not exist, and cannot be created.");
- return HttpStatus.PARTIAL_CONTENT_206;
- }
- }
- }
-
- // Set Start/End commands
- setStartEnd(pr);
- setQueryParamsOn(client);
- Future<PermRequest> fp = client.create(
- "/authz/perm",
- getDF(PermRequest.class),
- pr
- );
- if(fp.get(AAFcli.timeout())) {
- rv = fp.code();
- pw().println("Created Permission");
- if(roles!=null) {
- if(aafcli.forceString()!=null) { // Make sure Roles are Created
- RoleRequest rr = new RoleRequest();
- for(String role : roles) {
- rr.setName(role);;
- Future<RoleRequest> fr = client.create(
- "/authz/role",
- getDF(RoleRequest.class),
- rr
- );
- fr.get(AAFcli.timeout());
- switch(fr.code()){
- case 201:
- case 409:break;
- default:
-
- }
- }
- }
-
- try {
- if(201!=(rv=((Perm)parent)._exec(0,
- new String[] {"grant",pr.getType(),pr.getInstance(),pr.getAction(),roleCommas}))) {
- rv = HttpStatus.PARTIAL_CONTENT_206;
- }
- } catch (LocatorException e) {
- throw new CadiException(e);
- }
- }
- } else {
- rv = fp.code();
- if(rv==409 && force) {
- rv = 201;
- } else if(rv==202) {
- pw().println("Permission Creation Accepted, but requires Approvals before actualizing");
- if (roles!=null)
- pw().println("You need to grant the roles after approval.");
- } else {
- error(fp);
- }
- }
- return rv;
- }
- });
- }
-
- @Override
- public void detailedHelp(int _indent, StringBuilder sb) {
- int indent = _indent;
- detailLine(sb,indent,"Create a Permission with:");
- detailLine(sb,indent+=2,"type - A Namespace qualified identifier identifying the kind of");
- detailLine(sb,indent+11,"resource to be protected");
- detailLine(sb,indent,"instance - A name that distinguishes a particular instance of resource");
- detailLine(sb,indent,"action - What kind of action is allowed");
- detailLine(sb,indent,"role(s) - Perms granted to these Comma separated Role(s)");
- detailLine(sb,indent+11,"Nonexistent role(s) will be created, if in same namespace");
- sb.append('\n');
- detailLine(sb,indent+2,"Note: Instance and Action can be a an '*' (enter \\\\* on Unix Shell)");
- api(sb,indent,HttpMethods.POST,"authz/perm",PermRequest.class,true);
- }
-
-}
diff --git a/authz-cmd/src/main/java/com/att/cmd/perm/Delete.java b/authz-cmd/src/main/java/com/att/cmd/perm/Delete.java
deleted file mode 100644
index b1f09959..00000000
--- a/authz-cmd/src/main/java/com/att/cmd/perm/Delete.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package com.att.cmd.perm;
-
-
-import com.att.cadi.CadiException;
-import com.att.cadi.LocatorException;
-import com.att.cadi.client.Future;
-import com.att.cadi.client.Rcli;
-import com.att.cadi.client.Retryable;
-import com.att.cmd.AAFcli;
-import com.att.cmd.Cmd;
-import com.att.cmd.Param;
-import com.att.cssa.rserv.HttpMethods;
-import com.att.inno.env.APIException;
-
-import aaf.v2_0.PermRequest;
-
-/**
- *
- */
-public class Delete extends Cmd {
- public Delete(Perm parent) {
- super(parent,"delete",
- new Param("type",true),
- new Param("instance",true),
- new Param("action", true));
- }
-
- @Override
- public int _exec(final int index, final String ... args) throws CadiException, APIException, LocatorException {
- return same(new Retryable<Integer>() {
- @Override
- public Integer code(Rcli<?> client) throws CadiException, APIException {
- int idx = index;
- // Object Style Delete
- PermRequest pk = new PermRequest();
- pk.setType(args[idx++]);
- pk.setInstance(args[idx++]);
- pk.setAction(args[idx++]);
-
- // Set "Force" if set
- setQueryParamsOn(client);
- Future<PermRequest> fp = client.delete(
- "/authz/perm",
- getDF(PermRequest.class),
- pk);
- if(fp.get(AAFcli.timeout())) {
- pw().println("Deleted Permission");
- } else {
- if(fp.code()==202) {
- pw().println("Permission Deletion Accepted, but requires Approvals before actualizing");
- } else {
- error(fp);
- }
- }
- return fp.code();
- }
- });
- }
-
- @Override
- public void detailedHelp(int indent, StringBuilder sb) {
- detailLine(sb,indent,"Delete a Permission with type,instance and action");
- detailLine(sb,indent+4,"see Create for definitions");
- api(sb,indent,HttpMethods.DELETE,"authz/perm",PermRequest.class,true);
- }
-
-}
diff --git a/authz-cmd/src/main/java/com/att/cmd/perm/Describe.java b/authz-cmd/src/main/java/com/att/cmd/perm/Describe.java
deleted file mode 100644
index 3d6646fa..00000000
--- a/authz-cmd/src/main/java/com/att/cmd/perm/Describe.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package com.att.cmd.perm;
-
-import com.att.cadi.CadiException;
-import com.att.cadi.LocatorException;
-import com.att.cadi.client.Future;
-import com.att.cadi.client.Rcli;
-import com.att.cadi.client.Retryable;
-import com.att.cmd.AAFcli;
-import com.att.cmd.Cmd;
-import com.att.cmd.Param;
-import com.att.cssa.rserv.HttpMethods;
-import com.att.inno.env.APIException;
-
-import aaf.v2_0.PermRequest;
-
-public class Describe extends Cmd {
- private static final String PERM_PATH = "/authz/perm";
- public Describe(Perm parent) {
- super(parent,"describe",
- new Param("type",true),
- new Param("instance", true),
- new Param("action", true),
- new Param("description",true));
- }
-
- @Override
- public int _exec(final int index, final String ... args) throws CadiException, APIException, LocatorException {
- return same(new Retryable<Integer>() {
- @Override
- public Integer code(Rcli<?> client) throws CadiException, APIException {
- int idx = index;
- String type = args[idx++];
- String instance = args[idx++];
- String action = args[idx++];
- StringBuilder desc = new StringBuilder();
- while (idx < args.length) {
- desc.append(args[idx++] + ' ');
- }
-
- PermRequest pr = new PermRequest();
- pr.setType(type);
- pr.setInstance(instance);
- pr.setAction(action);
- pr.setDescription(desc.toString());
-
- // Set Start/End commands
- setStartEnd(pr);
-
- Future<PermRequest> fp = null;
- int rv;
-
- fp = client.update(
- PERM_PATH,
- getDF(PermRequest.class),
- pr
- );
-
- if(fp.get(AAFcli.timeout())) {
- rv=fp.code();
- pw().println("Description added to Permission");
- } else {
- if((rv=fp.code())==202) {
- pw().print("Adding description");
- pw().println(" Accepted, but requires Approvals before actualizing");
- } else {
- error(fp);
- }
- }
- return rv;
- }
- });
- }
-
- @Override
- public void detailedHelp(int indent, StringBuilder sb) {
- detailLine(sb,indent,"Add a description to a permission");
- api(sb,indent,HttpMethods.PUT,"authz/perm",PermRequest.class,true);
- }
-}
diff --git a/authz-cmd/src/main/java/com/att/cmd/perm/Grant.java b/authz-cmd/src/main/java/com/att/cmd/perm/Grant.java
deleted file mode 100644
index 0b15fbe6..00000000
--- a/authz-cmd/src/main/java/com/att/cmd/perm/Grant.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package com.att.cmd.perm;
-
-import com.att.cadi.CadiException;
-import com.att.cadi.LocatorException;
-import com.att.cadi.client.Future;
-import com.att.cadi.client.Rcli;
-import com.att.cadi.client.Retryable;
-import com.att.cmd.AAFcli;
-import com.att.cmd.Cmd;
-import com.att.cmd.Param;
-import com.att.cssa.rserv.HttpMethods;
-import com.att.inno.env.APIException;
-
-import aaf.v2_0.Pkey;
-import aaf.v2_0.RolePermRequest;
-
-/**
- *
- *
- */
-public class Grant extends Cmd {
- private final static String[] options = {"grant","ungrant","setTo"};
-
- public Grant(Perm parent) {
- super(parent,null,
- new Param(optionsToString(options),true),
- new Param("type",true),
- new Param("instance",true),
- new Param("action",true),
- new Param("role[,role]* (!REQ S)",false)
- );
- }
-
- @Override
- public int _exec(final int index, final String ... args) throws CadiException, APIException, LocatorException {
- return same(new Retryable<Integer>() {
- @Override
- public Integer code(Rcli<?> client) throws CadiException, APIException {
- int idx = index;
- String action = args[idx++];
- int option = whichOption(options, action);
-
- RolePermRequest rpr = new RolePermRequest();
- Pkey pk = new Pkey();
- pk.setType(args[idx++]);
- pk.setInstance(args[idx++]);
- pk.setAction(args[idx++]);
- rpr.setPerm(pk);
- setStartEnd(rpr);
-
- Future<RolePermRequest> frpr = null;
-
- if (option != 2) {
- String[] roles = args[idx++].split(",");
- String strA,strB;
- for(String role : roles) {
- rpr.setRole(role);
- if(option==0) {
- // You can request to Grant Permission to a Role
- setQueryParamsOn(client);
- frpr = client.create(
- "/authz/role/perm",
- getDF(RolePermRequest.class),
- rpr
- );
- strA = "Granted Permission [";
- strB = "] to Role [";
- } else {
- // You can request to UnGrant Permission to a Role
- setQueryParamsOn(client);
- frpr = client.delete(
- "/authz/role/" + role + "/perm",
- getDF(RolePermRequest.class),
- rpr
- );
- strA = "UnGranted Permission [";
- strB = "] from Role [";
- }
- if(frpr.get(AAFcli.timeout())) {
- pw().println(strA + pk.getType() + '|' + pk.getInstance() + '|' + pk.getAction()
- + strB + role +']');
- } else {
- if (frpr.code()==202) {
- pw().print("Permission Role ");
- pw().print(option==0?"Granted":"Ungranted");
- pw().println(" Accepted, but requires Approvals before actualizing");
- } else {
- error(frpr);
- idx=Integer.MAX_VALUE;
- }
- }
- }
- } else {
- String allRoles = "";
- if (idx < args.length)
- allRoles = args[idx++];
-
- rpr.setRole(allRoles);
- frpr = client.update(
- "/authz/role/perm",
- getDF(RolePermRequest.class),
- rpr);
- if(frpr.get(AAFcli.timeout())) {
- pw().println("Set Permission's Roles to [" + allRoles + "]");
- } else {
- error(frpr);
- }
- }
- return frpr==null?0:frpr.code();
- }
- });
- }
-
- @Override
- public void detailedHelp(int indent, StringBuilder sb) {
- detailLine(sb,indent,"Grant a Permission to a Role or Roles OR");
- detailLine(sb,indent,"Ungrant a Permission from a Role or Roles OR");
- detailLine(sb,indent,"Set a Permission's roles to roles supplied.");
- detailLine(sb,indent+4,"WARNING: Roles supplied with setTo will be the ONLY roles attached to this permission");
- detailLine(sb,indent+8,"If no roles are supplied, permission's roles are reset.");
- detailLine(sb,indent,"see Create for definitions of type,instance and action");
- api(sb,indent,HttpMethods.POST,"authz/role/perm",RolePermRequest.class,true);
- api(sb,indent,HttpMethods.DELETE,"authz/role/<role>/perm",RolePermRequest.class,false);
- api(sb,indent,HttpMethods.PUT,"authz/role/perm",RolePermRequest.class,false);
-
- }
-
-}
diff --git a/authz-cmd/src/main/java/com/att/cmd/perm/List.java b/authz-cmd/src/main/java/com/att/cmd/perm/List.java
deleted file mode 100644
index d87c29e4..00000000
--- a/authz-cmd/src/main/java/com/att/cmd/perm/List.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package com.att.cmd.perm;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-
-import com.att.cadi.CadiException;
-import com.att.cadi.client.Future;
-import com.att.cadi.client.Rcli;
-import com.att.cadi.client.Retryable;
-import com.att.cmd.AAFcli;
-import com.att.cmd.BaseCmd;
-import com.att.inno.env.APIException;
-
-import aaf.v2_0.Nss;
-import aaf.v2_0.Perms;
-import aaf.v2_0.Pkey;
-
-
-public class List extends BaseCmd<Perm> {
-// private static final String LIST_PERM_DETAILS = "list permission details";
-
- public List(Perm parent) {
- super(parent,"list");
-
- cmds.add(new ListByUser(this));
- cmds.add(new ListByName(this));
- cmds.add(new ListByNS(this));
- cmds.add(new ListByRole(this));
- cmds.add(new ListActivity(this));
- }
- // Package Level on purpose
- abstract class ListPerms extends Retryable<Integer> {
- protected int list(Future<Perms> fp,Rcli<?> client, String header, String parentPerm) throws CadiException, APIException {
- if(fp.get(AAFcli.timeout())) {
- ArrayList<String> permNss = null;
- if (aafcli.isDetailed()) {
- permNss = new ArrayList<String>();
- String permNs = null;
- for(Pkey perm : fp.value.getPerm()) {
- if (permNs != null && perm.getType().contains(permNs)) {
- permNss.add(permNs);
- } else {
- Future<Nss> fpn = null;
- String permType = perm.getType();
- permNs = permType;
- do {
- permNs = permType.substring(0,permNs.lastIndexOf('.'));
- fpn = client.read("/authz/nss/"+permNs,getDF(Nss.class));
- } while (!fpn.get(AAFcli.timeout()));
- permNss.add(permNs);
- }
- }
- }
- report(fp,permNss,header, parentPerm);
- } else {
- error(fp);
- }
- return fp.code();
- }
- }
-
- private static final Comparator<aaf.v2_0.Perm> permCompare = new Comparator<aaf.v2_0.Perm>() {
- @Override
- public int compare(aaf.v2_0.Perm a, aaf.v2_0.Perm b) {
- int rc;
- if((rc=a.getType().compareTo(b.getType()))!=0) {
- return rc;
- }
- if((rc=a.getInstance().compareTo(b.getInstance()))!=0) {
- return rc;
- }
- return a.getAction().compareTo(b.getAction());
- }
- };
-
- void report(Future<Perms> fp, ArrayList<String> permNss, String ... str) {
- reportHead(str);
- if (this.aafcli.isDetailed()) {
- String format = reportColHead("%-20s %-15s %-30s %-15s\n %-75s\n","PERM NS","Type","Instance","Action", "Description");
- Collections.sort(fp.value.getPerm(),permCompare);
- for(aaf.v2_0.Perm p : fp.value.getPerm()) {
- String permNs = permNss.remove(0);
- pw().format(format,
- permNs,
- p.getType().substring(permNs.length()+1),
- p.getInstance(),
- p.getAction(),
- p.getDescription()==null?"":p.getDescription());
- }
- pw().println();
- } else {
- String format = reportColHead("%-30s %-30s %-10s\n","PERM Type","Instance","Action");
-
- Collections.sort(fp.value.getPerm(),permCompare);
- for(aaf.v2_0.Perm p : fp.value.getPerm()) {
- pw().format(format,
- p.getType(),
- p.getInstance(),
- p.getAction());
- }
- pw().println();
- }
- }
-
-}
diff --git a/authz-cmd/src/main/java/com/att/cmd/perm/ListActivity.java b/authz-cmd/src/main/java/com/att/cmd/perm/ListActivity.java
deleted file mode 100644
index 58affb24..00000000
--- a/authz-cmd/src/main/java/com/att/cmd/perm/ListActivity.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package com.att.cmd.perm;
-
-import com.att.cadi.CadiException;
-import com.att.cadi.LocatorException;
-import com.att.cadi.client.Future;
-import com.att.cadi.client.Rcli;
-import com.att.cadi.client.Retryable;
-import com.att.cmd.AAFcli;
-import com.att.cmd.Cmd;
-import com.att.cmd.Param;
-import com.att.cssa.rserv.HttpMethods;
-import com.att.inno.env.APIException;
-
-import aaf.v2_0.History;
-
-/**
- *
- */
-public class ListActivity extends Cmd {
- private static final String HEADER = "List Activity of Permission";
-
- public ListActivity(List parent) {
- super(parent,"activity",
- new Param("type",true));
- }
-
- @Override
- public int _exec(final int index, final String ... args) throws CadiException, APIException, LocatorException {
- return same(new Retryable<Integer>() {
- @Override
- public Integer code(Rcli<?> client) throws CadiException, APIException {
- int idx = index;
- String type = args[idx++];
- Future<History> fp = client.read(
- "/authz/hist/perm/"+type,
- getDF(History.class)
- );
- if(fp.get(AAFcli.timeout())) {
- activity(fp.value, HEADER + " [ " + type + " ]");
- } else {
- error(fp);
- }
- return fp.code();
- }
- });
- }
-
- @Override
- public void detailedHelp(int indent, StringBuilder sb) {
- detailLine(sb,indent,HEADER);
- api(sb,indent,HttpMethods.GET,"authz/hist/perm/<type>",History.class,true);
- }
-
-}
diff --git a/authz-cmd/src/main/java/com/att/cmd/perm/ListByNS.java b/authz-cmd/src/main/java/com/att/cmd/perm/ListByNS.java
deleted file mode 100644
index 44eefa38..00000000
--- a/authz-cmd/src/main/java/com/att/cmd/perm/ListByNS.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package com.att.cmd.perm;
-
-import com.att.cadi.CadiException;
-import com.att.cadi.LocatorException;
-import com.att.cadi.client.Future;
-import com.att.cadi.client.Rcli;
-import com.att.cmd.Cmd;
-import com.att.cmd.Param;
-import com.att.cssa.rserv.HttpMethods;
-import com.att.inno.env.APIException;
-
-import aaf.v2_0.Perms;
-
-/**
- * Return Perms by NS
- *
- *
- */
-public class ListByNS extends Cmd {
- private static final String HEADER = "List Perms by NS ";
-
- public ListByNS(List parent) {
- super(parent,"ns",
- new Param("name",true));
- }
-
- public int _exec( int idx, final String ... args) throws CadiException, APIException, LocatorException {
- final String ns=args[idx];
-
- return same(((List)parent).new ListPerms() {
- @Override
- public Integer code(Rcli<?> client) throws CadiException, APIException {
- Future<Perms> fp = client.read(
- "/authz/perms/ns/"+ns,
- getDF(Perms.class)
- );
- return list(fp,client, HEADER, ns);
- }
- });
- }
-
- @Override
- public void detailedHelp(int indent, StringBuilder sb) {
- detailLine(sb,indent,HEADER);
- api(sb,indent,HttpMethods.GET,"authz/perms/ns/<ns>",Perms.class,true);
- }
-
-
-}
diff --git a/authz-cmd/src/main/java/com/att/cmd/perm/ListByName.java b/authz-cmd/src/main/java/com/att/cmd/perm/ListByName.java
deleted file mode 100644
index 1a5566d1..00000000
--- a/authz-cmd/src/main/java/com/att/cmd/perm/ListByName.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package com.att.cmd.perm;
-
-import com.att.cadi.CadiException;
-import com.att.cadi.LocatorException;
-import com.att.cadi.client.Future;
-import com.att.cadi.client.Rcli;
-import com.att.cmd.Cmd;
-import com.att.cmd.Param;
-import com.att.cssa.rserv.HttpMethods;
-import com.att.inno.env.APIException;
-
-import aaf.v2_0.Perms;
-
-/**
- *
- *
- */
-public class ListByName extends Cmd {
- private static final String HEADER = "List Child Permissions";
-
- public ListByName(List parent) {
- super(parent,"name",
- new Param("root perm name",true));
- }
-
- public int _exec(final int index, final String ... args) throws CadiException, APIException, LocatorException {
- return same(((List)parent).new ListPerms() {
- @Override
- public Integer code(Rcli<?> client) throws CadiException, APIException {
- String parentPerm=args[index];
-
- Future<Perms> fp = client.read(
- "/authz/perms/"+parentPerm,
- getDF(Perms.class)
- );
- return list(fp,client,HEADER,parentPerm);
- }
- });
- }
-
- @Override
- public void detailedHelp(int indent, StringBuilder sb) {
- detailLine(sb,indent,HEADER);
- api(sb,indent,HttpMethods.GET,"authz/perms/<parent type>",Perms.class,true);
- }
-
-}
diff --git a/authz-cmd/src/main/java/com/att/cmd/perm/ListByRole.java b/authz-cmd/src/main/java/com/att/cmd/perm/ListByRole.java
deleted file mode 100644
index 143c2612..00000000
--- a/authz-cmd/src/main/java/com/att/cmd/perm/ListByRole.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package com.att.cmd.perm;
-
-import com.att.cadi.CadiException;
-import com.att.cadi.LocatorException;
-import com.att.cadi.client.Future;
-import com.att.cadi.client.Rcli;
-import com.att.cmd.Cmd;
-import com.att.cmd.Param;
-import com.att.cssa.rserv.HttpMethods;
-import com.att.inno.env.APIException;
-
-import aaf.v2_0.Perms;
-
-/**
- * Return Perms by Role
- *
- *
- */
-public class ListByRole extends Cmd {
- private static final String HEADER = "List Perms by Role ";
-
- public ListByRole(List parent) {
- super(parent,"role",
- new Param("name",true));
- }
-
- public int _exec(final int idx, final String ... args) throws CadiException, APIException, LocatorException {
- final String role=args[idx];
-
- return same(((List)parent).new ListPerms() {
- @Override
- public Integer code(Rcli<?> client) throws CadiException, APIException {
-
- Future<Perms> fp = client.read(
- "/authz/perms/role/"+role,
- getDF(Perms.class)
- );
- return list(fp,client, HEADER, role);
- }
- });
- }
-
- @Override
- public void detailedHelp(int indent, StringBuilder sb) {
- detailLine(sb,indent,HEADER);
- api(sb,indent,HttpMethods.GET,"authz/perms/role/<role>",Perms.class,true);
- }
-
-
-}
diff --git a/authz-cmd/src/main/java/com/att/cmd/perm/ListByUser.java b/authz-cmd/src/main/java/com/att/cmd/perm/ListByUser.java
deleted file mode 100644
index 31ce2275..00000000
--- a/authz-cmd/src/main/java/com/att/cmd/perm/ListByUser.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package com.att.cmd.perm;
-
-import com.att.cadi.CadiException;
-import com.att.cadi.LocatorException;
-import com.att.cadi.client.Future;
-import com.att.cadi.client.Rcli;
-import com.att.cmd.Cmd;
-import com.att.cmd.Param;
-import com.att.cssa.rserv.HttpMethods;
-import com.att.inno.env.APIException;
-
-import aaf.v2_0.Perms;
-
-/**
- *
- *
- */
-public class ListByUser extends Cmd {
- private static final String HEADER = "List Permissions by User";
- public ListByUser(List parent) {
- super(parent,"user",
- new Param("id",true));
- }
-
- public int _exec( int idx, final String ... args) throws CadiException, APIException, LocatorException {
- String user=args[idx];
- String realm = getOrgRealm();
- final String fullUser;
- if (user.indexOf('@') < 0 && realm != null)
- fullUser = user + '@' + realm;
- else
- fullUser = user;
-
- return same(((List)parent).new ListPerms() {
- @Override
- public Integer code(Rcli<?> client) throws CadiException, APIException {
- Future<Perms> fp = client.read(
- "/authz/perms/user/"+fullUser,
- getDF(Perms.class)
- );
- return list(fp, client, HEADER, fullUser);
- }
- });
- }
-
- @Override
- public void detailedHelp(int indent, StringBuilder sb) {
- detailLine(sb,indent,HEADER);
- api(sb,indent,HttpMethods.GET,"authz/perms/user/<user id>",Perms.class,true);
- }
-
-
-}
diff --git a/authz-cmd/src/main/java/com/att/cmd/perm/Perm.java b/authz-cmd/src/main/java/com/att/cmd/perm/Perm.java
deleted file mode 100644
index 0c331542..00000000
--- a/authz-cmd/src/main/java/com/att/cmd/perm/Perm.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package com.att.cmd.perm;
-
-import com.att.cmd.BaseCmd;
-import com.att.cmd.role.Role;
-import com.att.inno.env.APIException;
-
-public class Perm extends BaseCmd<Perm> {
- Role role;
-
- public Perm(Role role) throws APIException {
- super(role.aafcli, "perm");
- this.role = role;
-
- cmds.add(new Create(this));
- cmds.add(new Delete(this));
- cmds.add(new Grant(this));
- cmds.add(new Rename(this));
- cmds.add(new Describe(this));
- cmds.add(new List(this));
- }
-}
diff --git a/authz-cmd/src/main/java/com/att/cmd/perm/Rename.java b/authz-cmd/src/main/java/com/att/cmd/perm/Rename.java
deleted file mode 100644
index 7d22a2ec..00000000
--- a/authz-cmd/src/main/java/com/att/cmd/perm/Rename.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START====================================================
- * * org.onap.aaf
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package com.att.cmd.perm;
-
-import com.att.cadi.CadiException;
-import com.att.cadi.LocatorException;
-import com.att.cadi.client.Future;
-import com.att.cadi.client.Rcli;
-import com.att.cadi.client.Retryable;
-import com.att.cmd.AAFcli;
-import com.att.cmd.Cmd;
-import com.att.cmd.Param;
-import com.att.cssa.rserv.HttpMethods;
-import com.att.inno.env.APIException;
-
-import aaf.v2_0.PermRequest;
-
-public class Rename extends Cmd {
- public Rename(Perm parent) {
- super(parent,"rename",
- new Param("type",true),
- new Param("instance",true),
- new Param("action", true),
- new Param("new type",true),
- new Param("new instance",true),
- new Param("new action", true)
- );
- }
-
- @Override
- public int _exec(final int index, final String ... args) throws CadiException, APIException, LocatorException {
- return same(new Retryable<Integer>() {
- @Override
- public Integer code(Rcli<?> client) throws CadiException, APIException {
- int idx = index;
- String origType = args[idx++];
- String origInstance = args[idx++];
- String origAction = args[idx++];
-
- //Create new permission
- PermRequest pr = new PermRequest();
- pr.setType(args[idx++]);
- pr.setInstance(args[idx++]);
- pr.setAction(args[idx++]);
-
- // Set Start/End commands
- setStartEnd(pr);
- Future<PermRequest> fp = client.update(
- "/authz/perm/"+origType+"/"+origInstance+"/"+origAction,
- getDF(PermRequest.class),
- pr
- );
- int rv;
- if(fp.get(AAFcli.timeout())) {
- rv = fp.code();
- pw().println("Updated Permission");
- } else {
- rv = fp.code();
- if(rv==202) {
- pw().println("Permission Update Accepted, but requires Approvals before actualizing");
- } else {
- error(fp);
- }
- }
- return rv;
- }
- });
-
- }
-
- @Override
- public void detailedHelp(int indent, StringBuilder sb) {
- detailLine(sb,indent,"Rename a Permission from:");
- detailLine(sb,indent+2,"<type> <instance> <action>");
- detailLine(sb,indent,"to:");
- detailLine(sb,indent+2,"<new type> <new instance> <new action>");
- sb.append('\n');
- detailLine(sb,indent,"Namespace must be the same in <type> and <new type>");
- detailLine(sb,indent+4,"see Create for definitions of type,instance and action");
- api(sb,indent,HttpMethods.PUT,"authz/perm/<type>/<instance>/<action>",PermRequest.class,true);
- }
-}