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.audit.AuditActivity;
29:
30: /**
31: * LoginErrorServlet
32: *
33: * @author <a href="mailto:ate@douma.nu">Ate Douma </a>
34: * @version $Id: LoginErrorServlet.java 553804 2007-07-06 09:15:49Z taylor $
35: */
36: public class LoginErrorServlet extends HttpServlet {
37:
38: public void doGet(HttpServletRequest request,
39: HttpServletResponse response) throws IOException,
40: ServletException {
41: HttpSession session = request.getSession();
42: String destination = (String) session
43: .getAttribute(LoginConstants.DESTINATION);
44: if (destination == null)
45: destination = request.getContextPath() + "/";
46: else
47: session.removeAttribute(LoginConstants.DESTINATION);
48:
49: Integer retryCount = (Integer) session
50: .getAttribute(LoginConstants.RETRYCOUNT);
51: if (retryCount == null)
52: retryCount = new Integer(1);
53: else
54: retryCount = new Integer(retryCount.intValue() + 1);
55: session.setAttribute(LoginConstants.RETRYCOUNT, retryCount);
56:
57: String username = (String) session
58: .getAttribute(LoginConstants.USERNAME);
59: AuditActivity audit = (AuditActivity) Jetspeed
60: .getComponentManager().getComponent(
61: "org.apache.jetspeed.audit.AuditActivity");
62: if (audit != null) {
63: audit.logUserActivity(username, request.getRemoteAddr(),
64: AuditActivity.AUTHENTICATION_FAILURE,
65: "Active Authentication");
66: }
67: response.sendRedirect(response.encodeURL(destination));
68: }
69:
70: public final void doPost(HttpServletRequest request,
71: HttpServletResponse response) throws IOException,
72: ServletException {
73: doGet(request, response);
74: }
75: }
|