KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejbca > ui > cli > RaListNewUsersCommand


1 /*************************************************************************
2  * *
3  * EJBCA: The OpenSource Certificate Authority *
4  * *
5  * This software is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU Lesser General Public *
7  * License as published by the Free Software Foundation; either *
8  * version 2.1 of the License, or any later version. *
9  * *
10  * See terms of license at gnu.org. *
11  * *
12  *************************************************************************/

13  
14 package org.ejbca.ui.cli;
15
16 import java.util.Collection JavaDoc;
17 import java.util.Iterator JavaDoc;
18
19 import org.ejbca.core.model.ra.UserDataConstants;
20 import org.ejbca.core.model.ra.UserDataVO;
21
22
23
24
25
26 /**
27  * List users with status NEW in the database.
28  *
29  * @version $Id: RaListNewUsersCommand.java,v 1.2 2006/01/26 14:17:57 anatom Exp $
30  *
31  * @see org.ejbca.core.ejb.ra.UserDataLocal
32  */

33 public class RaListNewUsersCommand extends BaseRaAdminCommand {
34     /**
35      * Creates a new instance of RaListNewUsersCommand
36      *
37      * @param args command line arguments
38      */

39     public RaListNewUsersCommand(String JavaDoc[] args) {
40         super(args);
41     }
42
43     /**
44      * Runs the command
45      *
46      * @throws IllegalAdminCommandException Error in command args
47      * @throws ErrorAdminCommandException Error running command
48      */

49     public void execute() throws IllegalAdminCommandException, ErrorAdminCommandException {
50         try {
51             Collection JavaDoc coll = getAdminSession().findAllUsersByStatus(administrator,
52                     UserDataConstants.STATUS_NEW);
53             Iterator JavaDoc iter = coll.iterator();
54
55             while (iter.hasNext()) {
56                 UserDataVO data = (UserDataVO) iter.next();
57                 getOutputStream().println("New User: " + data.getUsername() + ", \"" + data.getDN() +
58                     "\", \"" + data.getSubjectAltName() + "\", " + data.getEmail() + ", " +
59                     data.getStatus() + ", " + data.getType() + ", " + data.getTokenType());
60             }
61         } catch (Exception JavaDoc e) {
62             throw new ErrorAdminCommandException(e);
63         }
64     }
65
66     // execute
67
}
68
Popular Tags