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