1 13 14 package org.ejbca.ui.cli; 15 16 import org.ejbca.core.model.authorization.AuthorizationDeniedException; 17 18 19 24 public class RaDelUserCommand extends BaseRaAdminCommand { 25 30 public RaDelUserCommand(String [] args) { 31 super(args); 32 } 33 34 40 public void execute() throws IllegalAdminCommandException, ErrorAdminCommandException { 41 if (args.length < 2) { 42 throw new IllegalAdminCommandException("Usage: RA deluser <username>"); 43 } 44 45 try { 46 String username = args[1]; 47 getOutputStream().print("Have you revoked the user [y/N]? "); 48 49 int inp = System.in.read(); 50 51 if ((inp == 121) || (inp == 89)) { 52 try { 53 getAdminSession().deleteUser(administrator, username); 54 getOutputStream().println("Deleted user " + username); 55 } catch (AuthorizationDeniedException e) { 56 getOutputStream().println("Error : Not authorized to remove user."); 57 } 58 } else { 59 getOutputStream().println("Delete aborted!"); 60 getOutputStream().println("Please run 'ra revokeuser " + username + "'."); 61 } 62 } catch (Exception e) { 63 throw new ErrorAdminCommandException(e); 64 } 65 } 66 67 } 69 | Popular Tags |