KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.ejbca.core.model.authorization.AuthorizationDeniedException;
17 import org.ejbca.core.model.ra.raadmin.UserDoesntFullfillEndEntityProfile;
18
19
20
21 /**
22  * Set the clear text password for a user in the database. Clear text passwords are used for batch
23  * generation of keystores (pkcs12/pem).
24  *
25  * @version $Id: RaSetClearPwdCommand.java,v 1.1 2006/01/17 20:28:05 anatom Exp $
26  */

27 public class RaSetClearPwdCommand extends BaseRaAdminCommand {
28     /**
29      * Creates a new instance of RaSetClearPwdCommand
30      *
31      * @param args command line arguments
32      */

33     public RaSetClearPwdCommand(String JavaDoc[] args) {
34         super(args);
35     }
36
37     /**
38      * Runs the command
39      *
40      * @throws IllegalAdminCommandException Error in command args
41      * @throws ErrorAdminCommandException Error running command
42      */

43     public void execute() throws IllegalAdminCommandException, ErrorAdminCommandException {
44         try {
45             if (args.length < 3) {
46                 getOutputStream().println("Usage: RA setclearpwd <username> <password>");
47
48                 return;
49             }
50
51             String JavaDoc username = args[1];
52             String JavaDoc password = args[2];
53             getOutputStream().println("Setting clear text password " + password + " for user " + username);
54
55             try {
56                 getAdminSession().setClearTextPassword(administrator, username, password);
57             } catch (AuthorizationDeniedException e) {
58                 getOutputStream().println("Error : Not authorized to change userdata.");
59             } catch (UserDoesntFullfillEndEntityProfile e) {
60                 getOutputStream().println("Error : Given userdata doesn't fullfill end entity profile. : " +
61                     e.getMessage());
62             }
63         } catch (Exception JavaDoc e) {
64             throw new ErrorAdminCommandException(e);
65         }
66     }
67
68     // execute
69
}
70
Popular Tags