Sonar Fixes, Formatting
[aaf/authz.git] / auth / auth-cmd / src / main / java / org / onap / aaf / auth / cmd / ns / ListUsers.java
1 /**
2  * ============LICENSE_START====================================================
3  * org.onap.aaf
4  * ===========================================================================
5  * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
6  *
7  * Modifications Copyright (C) 2018 IBM.
8  * ===========================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * ============LICENSE_END====================================================
21  *
22  */
23
24 package org.onap.aaf.auth.cmd.ns;
25
26 import javax.xml.datatype.XMLGregorianCalendar;
27
28 import org.onap.aaf.auth.cmd.BaseCmd;
29 import org.onap.aaf.cadi.CadiException;
30 import org.onap.aaf.cadi.client.Future;
31
32 import aaf.v2_0.Nss;
33 import aaf.v2_0.Users.User;
34
35 public class ListUsers extends BaseCmd<List> {
36
37     private static final Future<Nss> dummy = new Future<Nss>(){
38
39         @Override
40         public boolean get(int timeout) throws CadiException {
41             return false;
42         }
43
44         @Override
45         public int code() {
46             return 0;
47         }
48
49         @Override
50         public String body() {
51             return null;
52         }
53
54         @Override
55         public String header(String tag) {
56             return null;
57         }
58     };
59
60     private static final String uformat = "%s%-50s expires:%02d/%02d/%04d\n";
61
62     public ListUsers(List parent) {
63         super(parent,"user");
64         cmds.add(new ListUsersWithPerm(this));
65         cmds.add(new ListUsersInRole(this));
66     }
67
68     public void report(String header, String ns) {
69         ((List)parent).report(dummy, header,ns);
70     }
71
72     public void report(String subHead) {
73         pw().println(subHead);
74     }
75
76     public void report(String prefix, User u) {
77         XMLGregorianCalendar xgc = u.getExpires();
78         pw().format(uformat,prefix,u.getId(),xgc.getMonth()+1,xgc.getDay(),xgc.getYear());
79     }
80
81 }