KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejbca > ui > web > admin > configuration > GlobalConfigurationDataHandler


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.web.admin.configuration;
15
16 import javax.naming.Context JavaDoc;
17 import javax.naming.InitialContext JavaDoc;
18 import javax.naming.NamingException JavaDoc;
19
20 import org.ejbca.core.ejb.authorization.IAuthorizationSessionLocal;
21 import org.ejbca.core.ejb.ra.raadmin.IRaAdminSessionLocal;
22 import org.ejbca.core.model.authorization.AuthorizationDeniedException;
23 import org.ejbca.core.model.log.Admin;
24 import org.ejbca.core.model.ra.raadmin.GlobalConfiguration;
25
26 /**
27  * A class handling the saving and loading of global configuration data.
28  * By default all data are saved to a database.
29  *
30  * @author Philip Vendil
31  * @version $Id: GlobalConfigurationDataHandler.java,v 1.1 2006/01/17 20:32:19 anatom Exp $
32  */

33 public class GlobalConfigurationDataHandler implements java.io.Serializable JavaDoc {
34     
35     /** Creates a new instance of GlobalConfigurationDataHandler */
36     public GlobalConfigurationDataHandler(Admin administrator,IRaAdminSessionLocal raadminsession, IAuthorizationSessionLocal authorizationsession){
37         this.raadminsession = raadminsession;
38         this.authorizationsession = authorizationsession;
39         this.administrator = administrator;
40     }
41     
42     public GlobalConfiguration loadGlobalConfiguration() throws NamingException JavaDoc{
43         GlobalConfiguration ret = null;
44         
45         ret = raadminsession.loadGlobalConfiguration(administrator);
46         InitialContext JavaDoc ictx = new InitialContext JavaDoc();
47         Context JavaDoc myenv = (Context JavaDoc) ictx.lookup("java:comp/env");
48         ret.initialize( (String JavaDoc) myenv.lookup("ADMINDIRECTORY"),
49                 (String JavaDoc) myenv.lookup("AVAILABLELANGUAGES"), (String JavaDoc) myenv.lookup("AVAILABLETHEMES"),
50                 (String JavaDoc) myenv.lookup("PUBLICPORT"),(String JavaDoc) myenv.lookup("PRIVATEPORT"),
51                 (String JavaDoc) myenv.lookup("PUBLICPROTOCOL"),(String JavaDoc) myenv.lookup("PRIVATEPROTOCOL"));
52         return ret;
53     }
54     
55     public void saveGlobalConfiguration(GlobalConfiguration gc) throws AuthorizationDeniedException {
56         if(this.authorizationsession.isAuthorizedNoLog(administrator, "/super_administrator"))
57             raadminsession.saveGlobalConfiguration(administrator, gc);
58     }
59     
60     // private IRaAdminSessionHome raadminsessionhome;
61
private IRaAdminSessionLocal raadminsession;
62     private IAuthorizationSessionLocal authorizationsession;
63     private Admin administrator;
64 }
65
Popular Tags