View Javadoc

    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.providers;
    17
    18  import org.acegisecurity.Authentication;
    19  import org.acegisecurity.AuthenticationException;
    20
    21
    22  /***
    23   * An {@link AuthenticationProvider} implementation for the  {@link
    24   * TestingAuthenticationToken}.
    25   *
    26   * <p>
    27   * It simply accepts as valid whatever is contained within the
    28   * <code>TestingAuthenticationToken</code>.
    29   * </p>
    30   *
    31   * <p>
    32   * The purpose of this implementation is to facilitate unit testing. This
    33   * provider should <B>never be enabled on a production system</b>.
    34   * </p>
    35   *
    36   * @author Ben Alex
    37   * @version $Id: TestingAuthenticationProvider.java,v 1.3 2005/11/17 00:55:49 benalex Exp $
    38   */
    39  public class TestingAuthenticationProvider implements AuthenticationProvider {
    40      //~ Methods ================================================================
    41
    42      public Authentication authenticate(Authentication authentication)
    43          throws AuthenticationException {
    44          return authentication;
    45      }
    46
    47      public boolean supports(Class authentication) {
    48          if (TestingAuthenticationToken.class.isAssignableFrom(authentication)) {
    49              return true;
    50          } else {
    51              return false;
    52          }
    53      }
    54  }