1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
package org.apache.jetspeed.login; |
18 |
|
|
19 |
|
import java.io.IOException; |
20 |
|
|
21 |
|
import javax.servlet.ServletException; |
22 |
|
import javax.servlet.http.HttpServlet; |
23 |
|
import javax.servlet.http.HttpServletRequest; |
24 |
|
import javax.servlet.http.HttpServletResponse; |
25 |
|
import javax.servlet.http.HttpSession; |
26 |
|
|
27 |
|
import org.apache.commons.logging.Log; |
28 |
|
import org.apache.commons.logging.LogFactory; |
29 |
|
import org.apache.jetspeed.Jetspeed; |
30 |
|
import org.apache.jetspeed.PortalReservedParameters; |
31 |
|
import org.apache.jetspeed.engine.Engine; |
32 |
|
import org.apache.jetspeed.exception.JetspeedException; |
33 |
|
import org.apache.jetspeed.request.RequestContext; |
34 |
|
import org.apache.jetspeed.request.RequestContextComponent; |
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
0 |
public class LoginServlet extends HttpServlet |
44 |
|
{ |
45 |
0 |
private static final Log log = LogFactory.getLog(LoginServlet.class); |
46 |
|
|
47 |
|
public void doGet(HttpServletRequest request, |
48 |
|
HttpServletResponse response) throws IOException, ServletException |
49 |
|
{ |
50 |
0 |
HttpSession session = request.getSession(true); |
51 |
|
|
52 |
0 |
if (request.getUserPrincipal() != null) |
53 |
|
{ |
54 |
0 |
String destination = (String) session |
55 |
|
.getAttribute(LoginConstants.DESTINATION); |
56 |
0 |
if (destination == null) |
57 |
0 |
destination = request.getContextPath() + "/"; |
58 |
|
|
59 |
0 |
response.sendRedirect(response.encodeURL(destination)); |
60 |
|
} |
61 |
|
|
62 |
0 |
if (Jetspeed.getEngine() != null) |
63 |
|
{ |
64 |
0 |
request.setAttribute(PortalReservedParameters.PIPELINE, PortalReservedParameters.LOGIN_PIPELINE); |
65 |
0 |
Engine engine = Jetspeed.getEngine(); |
66 |
|
try |
67 |
|
{ |
68 |
0 |
RequestContextComponent contextComponent = (RequestContextComponent) Jetspeed.getComponentManager() |
69 |
|
.getComponent(RequestContextComponent.class); |
70 |
0 |
RequestContext context = contextComponent.create(request, response, getServletConfig()); |
71 |
0 |
engine.service(context); |
72 |
0 |
contextComponent.release(context); |
73 |
|
} |
74 |
0 |
catch (JetspeedException e) |
75 |
|
{ |
76 |
0 |
log.warn("Jetspeed engine does not work properly.", e); |
77 |
|
|
78 |
0 |
response.sendRedirect(response.encodeURL(request.getContextPath() + "/")); |
79 |
0 |
} |
80 |
0 |
} |
81 |
|
else |
82 |
|
{ |
83 |
|
|
84 |
0 |
response.sendRedirect(response.encodeURL(request.getContextPath() + "/")); |
85 |
|
} |
86 |
0 |
} |
87 |
|
|
88 |
|
public final void doPost(HttpServletRequest request, |
89 |
|
HttpServletResponse response) throws IOException, ServletException |
90 |
|
{ |
91 |
0 |
doGet(request, response); |
92 |
0 |
} |
93 |
|
} |