KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > enhydraManager > EnhydraManager


1 /*
2  * enhydraManager
3  * A sample Enhydra Application
4  *
5  */

6
7 package enhydraManager;
8
9 import com.lutris.appserver.server.*;
10 import com.lutris.appserver.server.httpPresentation.*;
11 import com.lutris.appserver.server.session.*;
12 import com.lutris.util.*;
13
14 import com.lutris.http.BasicAuth;
15 import com.lutris.http.BasicAuthResult;
16 import enhydraManager.spec.*;
17 /**
18  * Main application startup.
19  *
20  * Application-wide data would go here.
21  */

22 public class EnhydraManager extends StandardApplication {
23     
24
25    // The user who is allowed to run this application. Used with basic auth.
26
private String JavaDoc username, password, locale;
27    // For the password prompt. Used with basic auth.
28
private String JavaDoc relm = "EnhydraManager";
29
30
31
32     public static String JavaDoc refresh = "0";
33     /*
34      * A few methods you might want to add to.
35      * See StandardApplication for more details.
36      */

37     public void startup(Config appConfig) throws ApplicationException {
38       try {
39          username = appConfig.getString("enhydraManager.Username");
40          password = appConfig.getString("enhydraManager.Password");
41       } catch (ConfigException except) {
42          throw new ApplicationException(except);
43       }
44
45       super.startup(appConfig);
46       try {
47         refresh = appConfig.getString("enhydraManager.Refresh");
48         Integer.parseInt(refresh);
49       } catch (Exception JavaDoc ex){
50         refresh = "0";
51       }
52     
53     try{
54    // Global gl=GlobalFactory.getGlobal("enhydraManager.business.GlobalImpl");
55
// gl.initialize();
56
}catch(NullPointerException JavaDoc e){}
57       
58     }
59
60     public boolean requestPreprocessor(HttpPresentationComms comms)
61                    throws Exception JavaDoc {
62       super.requestPreprocessor(comms);
63       if (comms.session == null) {
64          // Session not setup; so its not a presentation object.
65
return false;
66       }
67
68    /* BasicAuthResult auth = BasicAuth.getAuthentication(comms.request);
69       if (((username.length() != 0) || (password.length() != 0)) &&
70             ((auth == null) ||
71             !username.equals(auth.username) ||
72             !password.equals(auth.password))) {
73          throw new PageUnauthorizedException(relm);
74        }
75        
76        if (comms.session.getUser() == null) {
77           comms.session.setUser(EnhydraManagerUser.sharedUser);
78        }
79     */

80     
81       String JavaDoc user = comms.request.getRemoteUser();
82      
83         if(user!=null)
84          {
85          if (comms.session.getUser() == null)
86           {
87             EnhydraManagerUser enhydraManagerUser = new EnhydraManagerUser(user);
88             comms.session.setUser(enhydraManagerUser);
89      
90           }
91          }
92          
93        // Proceed normally.
94
return false;
95    }
96    
97    
98     /**
99      * This is an optional function, used only by the Multiserver's graphical
100      * administration. This bit of HTML appears in the status page for this
101      * application. You could add extra status info, for example
102      * a list of currently logged in users.
103      *
104      * @return HTML that is displayed in the status page of the Multiserver.
105      */

106     public String JavaDoc toHtml() {
107         return "This is <I>SessionViewer</I>";
108     }
109 }
110
111
Popular Tags