    1   /* Copyright 2004 Acegi Technology Pty Limited
    2    *
    3    * Licensed under the Apache License, Version 2.0 (the "License");
    4    * you may not use this file except in compliance with the License.
    5    * You may obtain a copy of the License at
    6    *
    7    *     http://www.apache.org/licenses/LICENSE-2.0
    8    *
    9    * Unless required by applicable law or agreed to in writing, software
    10   * distributed under the License is distributed on an "AS IS" BASIS,
    11   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12   * See the License for the specific language governing permissions and
    13   * limitations under the License.
    14   */
    15
    16  package org.acegisecurity;
    17
    18  import org.acegisecurity.intercept.web.AuthenticationEntryPoint;
    19
    20  import java.io.IOException;
    21
    22  import javax.servlet.ServletException;
    23  import javax.servlet.ServletRequest;
    24  import javax.servlet.ServletResponse;
    25  import javax.servlet.http.HttpServletRequest;
    26  import javax.servlet.http.HttpServletResponse;
    27
    28
    29  /***
    30   * Performs a HTTP redirect to the constructor-indicated URL.
    31   *
    32   * @author Ben Alex
    33   * @version $Id: MockAuthenticationEntryPoint.java,v 1.3 2005/11/17 00:55:47 benalex Exp $
    34   */
    35  public class MockAuthenticationEntryPoint implements AuthenticationEntryPoint {
    36      //~ Instance fields ========================================================
    37
    38      private String url;
    39
    40      //~ Constructors ===========================================================
    41
    42      public MockAuthenticationEntryPoint(String url) {
    43          this.url = url;
    44      }
    45
    46      private MockAuthenticationEntryPoint() {
    47          super();
    48      }
    49
    50      //~ Methods ================================================================
    51
    52      public void commence(ServletRequest request, ServletResponse response,
    53          AuthenticationException authenticationException)
    54          throws IOException, ServletException {
    55          ((HttpServletResponse) response).sendRedirect(((HttpServletRequest) request)
    56              .getContextPath() + url);
    57      }
    58  }