1/*2 * Licensed to the Apache Software Foundation (ASF) under one or more3 * contributor license agreements. See the NOTICE file distributed with4 * this work for additional information regarding copyright ownership.5 * The ASF licenses this file to You under the Apache License, Version 2.06 * (the "License"); you may not use this file except in compliance with7 * the License. You may obtain a copy of the License at8 * 9 * http://www.apache.org/licenses/LICENSE-2.010 * 11 * Unless required by applicable law or agreed to in writing, software12 * 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 and15 * limitations under the License.16 */17packageorg.apache.jetspeed.login;
1819import java.io.IOException;
2021import javax.servlet.ServletException;
22import javax.servlet.http.HttpServlet;
23import javax.servlet.http.HttpServletRequest;
24import javax.servlet.http.HttpServletResponse;
25import javax.servlet.http.HttpSession;
2627import org.apache.jetspeed.Jetspeed;
28import org.apache.jetspeed.audit.AuditActivity;
2930/***31 * LoginErrorServlet32 * 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 */36publicclassLoginErrorServletextends HttpServlet
37 {
3839publicvoid doGet(HttpServletRequest request,
40 HttpServletResponse response) throws IOException, ServletException
41 {
42 HttpSession session = request.getSession();
43 String destination = (String) session
44 .getAttribute(LoginConstants.DESTINATION);
45if (destination == null)
46 destination = request.getContextPath() + "/";
47else48 session.removeAttribute(LoginConstants.DESTINATION);
4950 Integer retryCount = (Integer) session
51 .getAttribute(LoginConstants.RETRYCOUNT);
52if (retryCount == null)
53 retryCount = new Integer(1);
54else55 retryCount = new Integer(retryCount.intValue() + 1);
56 session.setAttribute(LoginConstants.RETRYCOUNT, retryCount);
5758 String username = (String)session.getAttribute(LoginConstants.USERNAME);
59 AuditActivity audit = (AuditActivity)Jetspeed.getComponentManager().getComponent("org.apache.jetspeed.audit.AuditActivity");
60if (audit != null)
61 {
62 audit.logUserActivity(username, request.getRemoteAddr(), AuditActivity.AUTHENTICATION_FAILURE, "Active Authentication");
63 }
64 response.sendRedirect(response.encodeURL(destination));
65 }
6667publicfinalvoid doPost(HttpServletRequest request,
68 HttpServletResponse response) throws IOException, ServletException
69 {
70 doGet(request, response);
71 }
72 }