View Javadoc

    1   /*
    2    * Copyright [2007] [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 org.springframework.beans.factory.config.AbstractFactoryBean;
    22
    23  import edu.internet2.middleware.shibboleth.idp.authn.provider.AbstractLoginHandler;
    24
    25  /**
    26   * Base class for authentication handler factory beans.
    27   */
    28  public abstract class AbstractLoginHandlerFactoryBean extends AbstractFactoryBean {
    29
    30      /** Authentication methods supported by the handler. */
    31      private List<String> authenticationMethods;
    32
    33      /** Duration of the authentication, in minutes. */
    34      private int authenticationDuration;
    35
    36      /**
    37       * Gets the duration of the authentication, in minutes.
    38       *
    39       * @return duration of the authentication, in minutes
    40       */
    41      public int getAuthenticationDuration() {
    42          return authenticationDuration;
    43      }
    44
    45      /**
    46       * Sets the duration of the authentication, in minutes.
    47       *
    48       * @param duration duration of the authentication, in minutes
    49       */
    50      public void setAuthenticationDuration(int duration) {
    51          this.authenticationDuration = duration;
    52      }
    53
    54      /**
    55       * Gets the authentication methods supported by the handler.
    56       *
    57       * @return authentication methods supported by the handler
    58       */
    59      public List<String> getAuthenticationMethods() {
    60          return authenticationMethods;
    61      }
    62
    63      /**
    64       * Sets the authentication methods supported by the handler.
    65       *
    66       * @param methods authentication methods supported by the handler
    67       */
    68      public void setAuthenticationMethods(List<String> methods) {
    69          this.authenticationMethods = methods;
    70      }
    71
    72      /**
    73       * Populates the authentication duration and methods of the handler.
    74       *
    75       * @param handler the authentication handler to populate
    76       */
    77      protected void populateHandler(AbstractLoginHandler handler) {
    78          if (authenticationMethods != null) {
    79              handler.getSupportedAuthenticationMethods().addAll(authenticationMethods);
    80          }
    81          handler.setAuthenticationDuration(authenticationDuration * 60 * 1000);
    82      }
    83  }