01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
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.jetspeed.Jetspeed;
28: import org.apache.jetspeed.PortalReservedParameters;
29: import org.apache.jetspeed.audit.AuditActivity;
30:
31: /**
32: * LoginRedirectorServlet
33: *
34: * @author <a href="mailto:ate@douma.nu">Ate Douma </a>
35: * @version $Id: LoginRedirectorServlet.java 553804 2007-07-06 09:15:49Z taylor $
36: */
37: public class LoginRedirectorServlet extends HttpServlet {
38:
39: public void doGet(HttpServletRequest request,
40: HttpServletResponse response) throws IOException,
41: ServletException {
42: HttpSession session = request.getSession(true);
43: String destination = (String) session
44: .getAttribute(LoginConstants.DESTINATION);
45: if (destination == null
46: || destination.equals(request.getContextPath()))
47: destination = request.getContextPath() + "/";
48: else
49: session.removeAttribute(LoginConstants.DESTINATION);
50:
51: String username = (String) session
52: .getAttribute(LoginConstants.USERNAME);
53:
54: session.removeAttribute(LoginConstants.USERNAME);
55: session.removeAttribute(LoginConstants.PASSWORD);
56: session.removeAttribute(LoginConstants.RETRYCOUNT);
57: session
58: .removeAttribute(PortalReservedParameters.PREFERED_LOCALE_ATTRIBUTE);
59:
60: AuditActivity audit = (AuditActivity) Jetspeed
61: .getComponentManager().getComponent(
62: "org.apache.jetspeed.audit.AuditActivity");
63: if (audit != null) {
64: audit.logUserActivity(username, request.getRemoteAddr(),
65: AuditActivity.AUTHENTICATION_SUCCESS,
66: "Active Authentication");
67: }
68: response.sendRedirect(response.encodeURL(destination));
69: }
70:
71: public final void doPost(HttpServletRequest request,
72: HttpServletResponse response) throws IOException,
73: ServletException {
74: doGet(request, response);
75: }
76: }
|