View Javadoc

    1   /*
    2    * Copyright 2008 University Corporation for Advanced Internet Development, Inc.
    3    *
    4    * Licensed under the Apache License, Version 2.0 (the "License");
    5    * you may not use this file except in compliance with the License.
    6    * You may obtain a copy of the License at
    7    *
    8    * http://www.apache.org/licenses/LICENSE-2.0
    9    *
    10   * Unless required by applicable law or agreed to in writing, software
    11   * distributed under the License is distributed on an "AS IS" BASIS,
    12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13   * See the License for the specific language governing permissions and
    14   * limitations under the License.
    15   */
    16
    17  package edu.internet2.middleware.shibboleth.idp.config.profile.authn;
    18
    19  import java.util.List;
    20
    21  import edu.internet2.middleware.shibboleth.idp.authn.provider.IPAddressLoginHandler;
    22  import edu.internet2.middleware.shibboleth.idp.util.IPRange;
    23
    24  /**
    25   * Spring factory for {@link IPAddressLoginHandler}.
    26   */
    27  public class IPAddressLoginHandlerFactoryBean extends AbstractLoginHandlerFactoryBean {
    28
    29      /** The username to use for IP-address "authenticated" users. */
    30      private String authenticatedUser;
    31
    32      /** List of configured IP ranged. */
    33      private List<IPRange> ipRanges;
    34
    35      /** Whether a user is "authenticated" if their IP address is within a configured IP range. */
    36      private boolean ipInRangeIsAuthenticated;
    37
    38      /** {@inheritDoc} */
    39      public Class getObjectType() {
    40          return IPAddressLoginHandler.class;
    41      }
    42
    43      /**
    44       * @param user The authenticatedUser to set.
    45       */
    46      public void setAuthenticatedUser(String user) {
    47          authenticatedUser = user;
    48      }
    49
    50      /**
    51       * @param ranges The ipRanges to set.
    52       */
    53      public void setIpRanges(List<IPRange> ranges) {
    54          ipRanges = ranges;
    55      }
    56
    57      /**
    58       * @param authenticated The ipInRangeIsAuthenticated to set.
    59       */
    60      public void setIpInRangeIsAuthenticated(boolean authenticated) {
    61          ipInRangeIsAuthenticated = authenticated;
    62      }
    63
    64      /** {@inheritDoc} */
    65      protected Object createInstance() throws Exception {
    66          IPAddressLoginHandler handler = new IPAddressLoginHandler(authenticatedUser, ipRanges, ipInRangeIsAuthenticated);
    67          populateHandler(handler);
    68          return handler;
    69      }
    70  }