1 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 26 public class RaSetPwdCommand extends BaseRaAdminCommand { 27 32 public RaSetPwdCommand(String [] args) { 33 super(args); 34 } 35 36 42 public void execute() throws IllegalAdminCommandException, ErrorAdminCommandException { 43 try { 44 if (args.length < 3) { 45 getOutputStream().println("Usage: RA setpwd <username> <password>"); 46 47 return; 48 } 49 50 String username = args[1]; 51 String password = args[2]; 52 getOutputStream().println("Setting password (hashed only) " + password + " for user " + 53 username); 54 55 try { 56 getAdminSession().setPassword(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 profile."); 61 } 62 } catch (Exception e) { 63 throw new ErrorAdminCommandException(e); 64 } 65 } 66 67 } 69 | Popular Tags |