1 /*******************************************************************************
\r
2 * ============LICENSE_START====================================================
\r
4 * * ===========================================================================
\r
5 * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * * Copyright © 2017 Amdocs
\r
7 * * ===========================================================================
\r
8 * * Licensed under the Apache License, Version 2.0 (the "License");
\r
9 * * you may not use this file except in compliance with the License.
\r
10 * * You may obtain a copy of the License at
\r
12 * * http://www.apache.org/licenses/LICENSE-2.0
\r
14 * * Unless required by applicable law or agreed to in writing, software
\r
15 * * distributed under the License is distributed on an "AS IS" BASIS,
\r
16 * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
17 * * See the License for the specific language governing permissions and
\r
18 * * limitations under the License.
\r
19 * * ============LICENSE_END====================================================
\r
21 * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
\r
23 ******************************************************************************/
\r
24 package com.att.cmd.user;
\r
26 import java.util.Collections;
\r
27 import java.util.Comparator;
\r
29 import com.att.cadi.CadiException;
\r
30 import com.att.cadi.LocatorException;
\r
31 import com.att.cadi.client.Future;
\r
32 import com.att.cadi.client.Rcli;
\r
33 import com.att.cadi.client.Retryable;
\r
34 import com.att.cmd.AAFcli;
\r
35 import com.att.cmd.Cmd;
\r
36 import com.att.cmd.Param;
\r
37 import com.att.cssa.rserv.HttpMethods;
\r
38 import com.att.inno.env.APIException;
\r
40 import aaf.v2_0.Users;
\r
41 import aaf.v2_0.Users.User;
\r
47 public class ListForPermission extends Cmd {
\r
48 private static final String HEADER = "List Users for Permission";
\r
49 public ListForPermission(List parent) {
\r
50 super(parent,"perm",
\r
51 new Param("type",true),
\r
52 new Param("instance",true),
\r
53 new Param("action",true));
\r
57 public int _exec(final int index, final String ... args) throws CadiException, APIException, LocatorException {
\r
58 return same(new Retryable<Integer>() {
\r
60 public Integer code(Rcli<?> client) throws CadiException, APIException {
\r
62 String type = args[idx++];
\r
63 String instance = args[idx++];
\r
64 if("\\*".equals(instance))instance="*";
\r
65 String action = args[idx++];
\r
66 if("\\*".equals(action))action="*";
\r
67 Future<Users> fp = client.read(
\r
68 "/authz/users/perm/"+type+'/'+instance+'/'+action,
\r
71 if(fp.get(AAFcli.timeout())) {
\r
72 if (aafcli.isTest())
\r
73 Collections.sort(fp.value.getUser(), new Comparator<User>() {
\r
75 public int compare(User u1, User u2) {
\r
76 return u1.getId().compareTo(u2.getId());
\r
79 ((com.att.cmd.user.List)parent).report(fp.value,false,HEADER,type+"|"+instance+"|"+action);
\r
80 if(fp.code()==404)return 200;
\r
90 public void detailedHelp(int _indent, StringBuilder sb) {
\r
91 int indent = _indent;
\r
92 detailLine(sb,indent,HEADER);
\r
94 detailLine(sb,indent,"This report lists the users associated to Permissions. Since Users");
\r
95 detailLine(sb,indent,"are associated to Roles, and Roles have Permissions, this report");
\r
96 detailLine(sb,indent,"accomodates all these linkages.");
\r
98 detailLine(sb,indent,"The URL must contain the Permission's type,instance and action, and ");
\r
99 detailLine(sb,indent,"may include \"*\"s (type in as \\\\*).");
\r
100 detailLine(sb,indent,"See Perm Create Documentation for definitions.");
\r
102 api(sb,indent,HttpMethods.GET,"authz/users/perm/<type>/<instance>/<action>",Users.class,true);
\r