01: /*************************************************************************
02: * *
03: * EJBCA: The OpenSource Certificate Authority *
04: * *
05: * This software is free software; you can redistribute it and/or *
06: * modify it under the terms of the GNU Lesser General Public *
07: * License as published by the Free Software Foundation; either *
08: * version 2.1 of the License, or any later version. *
09: * *
10: * See terms of license at gnu.org. *
11: * *
12: *************************************************************************/package org.ejbca.ui.cli;
13:
14: import javax.naming.InitialContext;
15:
16: import org.ejbca.core.ejb.ra.raadmin.IRaAdminSessionHome;
17: import org.ejbca.core.ejb.ra.raadmin.IRaAdminSessionRemote;
18: import org.ejbca.core.model.log.Admin;
19:
20: /**
21: * Sets the base url of the web interface
22: *
23: * @version $Id: SetupSetBaseURLCommand.java,v 1.4 2007/01/03 14:49:35 anatom Exp $
24: */
25: public class SetupSetBaseURLCommand extends BaseAdminCommand {
26: /**
27: * Creates a new instance of CaCreateCrlCommand
28: *
29: * @param args command line arguments
30: */
31: public SetupSetBaseURLCommand(String[] args) {
32: super (args, Admin.TYPE_CACOMMANDLINE_USER, "cli");
33: }
34:
35: /**
36: * Runs the command
37: *
38: * @throws IllegalAdminCommandException Error in command args
39: * @throws ErrorAdminCommandException Error running command
40: */
41: public void execute() throws IllegalAdminCommandException,
42: ErrorAdminCommandException {
43: if (args.length < 3) {
44: throw new IllegalAdminCommandException(
45: "Usage: SETUP setdefaultbaseurl <computername> <applicationname>\n"
46: + "Example: setup setbaseurl localhost ejbca \n\n");
47: }
48: try {
49: //InitialContext jndicontext = new InitialContext();
50: InitialContext jndicontext = getInitialContext();
51:
52: String computername = args[1];
53: String applicationpath = args[2];
54: IRaAdminSessionHome raadminsessionhome = (IRaAdminSessionHome) javax.rmi.PortableRemoteObject
55: .narrow(jndicontext.lookup("RaAdminSession"),
56: IRaAdminSessionHome.class);
57:
58: IRaAdminSessionRemote raadminsession = raadminsessionhome
59: .create();
60:
61: raadminsession.initGlobalConfigurationBaseURL(new Admin(
62: Admin.TYPE_CACOMMANDLINE_USER), computername,
63: applicationpath);
64:
65: } catch (Exception e) {
66: throw new ErrorAdminCommandException(e);
67: }
68: }
69:
70: // execute
71: }
|