1 package org.whatsitcalled.webflange;
2
3 import java.net.MalformedURLException;
4
5 import javax.servlet.http.HttpServletRequest;
6
7 import org.apache.log4j.Logger;
8 import org.apache.wicket.Application;
9 import org.apache.wicket.MarkupContainer;
10 import org.apache.wicket.WicketRuntimeException;
11 import org.apache.wicket.behavior.HeaderContributor;
12 import org.apache.wicket.extensions.ajax.markup.html.form.upload.UploadWebRequest;
13 import org.apache.wicket.protocol.http.WebRequest;
14 import org.apache.wicket.security.hive.HiveMind;
15 import org.apache.wicket.security.hive.authentication.LoginContext;
16 import org.apache.wicket.security.hive.config.PolicyFileHiveFactory;
17 import org.apache.wicket.security.swarm.SwarmWebApplication;
18 import org.apache.wicket.util.time.Duration;
19 import org.whatsitcalled.webflange.security.WebflangeLoginContext;
20 import org.whatsitcalled.webflange.webapp.HomePage;
21 import org.whatsitcalled.webflange.webapp.LoginPage;
22
23 public class WebflangeApplication extends SwarmWebApplication {
24
25
26
27
28
29
30
31
32
33 private static Logger LOGGER = Logger.getLogger(WebflangeApplication.class);
34 @Override
35 public Class getHomePage() {
36 return HomePage.class;
37 }
38
39 @Override
40 protected void init() {
41 super.init();
42 getApplicationSettings().setPageExpiredErrorPage(HomePage.class);
43 getApplicationSettings().setInternalErrorPage(HomePage.class);
44 getResourceSettings().setResourcePollFrequency(Duration.milliseconds(500));
45
46 ResourceFactory.getTestService().init();
47 }
48
49 @Override
50 protected WebRequest newWebRequest(HttpServletRequest servletRequest) {
51 return new UploadWebRequest(servletRequest);
52 }
53
54
55
56 public Class getLoginPage()
57 {
58 return LoginPage.class;
59 }
60
61
62
63
64
65 public LoginContext getLogoffContext()
66 {
67 return new WebflangeLoginContext();
68 }
69
70
71
72 protected Object getHiveKey()
73 {
74
75
76
77
78
79
80
81
82
83
84 return "webflange";
85
86 }
87
88
89
90
91 protected void setUpHive()
92 {
93
94 PolicyFileHiveFactory factory = new PolicyFileHiveFactory();
95 try
96 {
97
98
99 LOGGER.debug("Setting up Hive...");
100 factory.addPolicyFile(getServletContext().getResource("/WEB-INF/webflange.hive"));
101 }
102 catch (MalformedURLException e)
103 {
104 throw new WicketRuntimeException(e);
105 }
106
107 HiveMind.registerHive(getHiveKey(), factory);
108
109 }
110
111 public void addHeaders(MarkupContainer container) {
112
113 container.add(HeaderContributor.forCss("extjs/resources/css/ext-all.css"));
114 container.add(HeaderContributor.forJavaScript("extjs/ext-base.js"));
115 container.add(HeaderContributor.forJavaScript("extjs/ext-resize.js"));
116
117
118 container.add(HeaderContributor.forCss("style.css"));
119
120 }
121
122
123
124 }