1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
/**
* ============LICENSE_START====================================================
* org.onap.aaf
* ===========================================================================
* Copyright (c) 2018 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====================================================
*
*/
package org.onap.aaf.auth.cmd.user;
import java.util.Collections;
import java.util.Comparator;
import org.onap.aaf.auth.cmd.BaseCmd;
import org.onap.aaf.misc.env.util.Chrono;
import aaf.v2_0.Approval;
import aaf.v2_0.Approvals;
import aaf.v2_0.Delg;
import aaf.v2_0.Delgs;
import aaf.v2_0.Users;
public class List extends BaseCmd<User> {
public List(User parent) {
super(parent,"list");
cmds.add(new ListForRoles(this));
cmds.add(new ListForPermission(this));
cmds.add(new ListForCreds(this));
cmds.add(new ListDelegates(this));
cmds.add(new ListApprovals(this));
cmds.add(new ListActivity(this));
}
void report(Users users, boolean count, String ... str) {
reportHead(str);
java.util.List<aaf.v2_0.Users.User> sorted = users.getUser();
Collections.sort(sorted, (Comparator<aaf.v2_0.Users.User>) (u1, u2) -> {
if (u1==null || u2 == null) {
return -1;
}
return u1.getId().compareTo(u2.getId());
});
String format = reportColHead("%-36s %-5s %-20s %-16s\n","User","Type","Expires","Tag");
String date = "XXXX-XX-XX";
for (aaf.v2_0.Users.User user : sorted) {
if (!aafcli.isTest()) {
date = Chrono.niceUTCStamp(user.getExpires());
}
String tag=user.getTag();
Integer type = user.getType();
if(tag==null) {
tag="";
} else if(type!=null && type>=200) {
tag = "\n\tfingerprint: " + tag;
}
pw().format(format,
user.getId(),
org.onap.aaf.auth.cmd.ns.List.getType(user),
date,
tag);
}
pw().println();
}
public void report(Approvals approvals, String title, String id) {
reportHead(title,id);
String format = reportColHead(" %-20s %-20s %-11s %-6s %12s\n","User","Approver","Type","Status","Updated");
java.util.List<Approval> lapp = approvals.getApprovals();
Collections.sort(lapp, (Comparator<Approval>) (a1, a2) -> a1.getTicket().compareTo(a2.getTicket()));
String ticket = null;
String prev = null;
for (Approval app : lapp ) {
ticket = app.getTicket();
if (!ticket.equals(prev)) {
pw().print("Ticket: ");
pw().println(ticket);
}
prev = ticket;
pw().format(format,
app.getUser(),
app.getApprover(),
app.getType(),
app.getStatus(),
Chrono.niceDateStamp(app.getUpdated())
);
}
}
public void report(Delgs delgs, String title, String id) {
reportHead(title,id);
String format = reportColHead(" %-25s %-25s %-10s\n","User","Delegate","Expires");
String date = "XXXX-XX-XX";
for (Delg delg : delgs.getDelgs()) {
if (!this.aafcli.isTest())
date = Chrono.dateOnlyStamp(delg.getExpires());
pw().printf(format,
delg.getUser(),
delg.getDelegate(),
date
);
}
}
}
|