View Javadoc

1   /*
2    * Licensed to the University Corporation for Advanced Internet Development, 
3    * Inc. (UCAID) under one or more contributor license agreements.  See the 
4    * NOTICE file distributed with this work for additional information regarding
5    * copyright ownership. The UCAID licenses this file to You under the Apache 
6    * License, Version 2.0 (the "License"); you may not use this file except in 
7    * compliance with the License.  You may obtain a copy of the License at
8    *
9    *    http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * 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 and
15   * limitations under the License.
16   */
17  
18  package edu.internet2.middleware.shibboleth.idp.config.profile.authn;
19  
20  import java.util.List;
21  
22  import org.springframework.beans.factory.config.AbstractFactoryBean;
23  
24  import edu.internet2.middleware.shibboleth.idp.authn.provider.AbstractLoginHandler;
25  
26  /**
27   * Base class for authentication handler factory beans.
28   */
29  public abstract class AbstractLoginHandlerFactoryBean extends AbstractFactoryBean {
30  
31      /** Authentication methods supported by the handler. */
32      private List<String> authenticationMethods;
33  
34      /** Duration of the authentication, in minutes. */
35      private long authenticationDuration;
36  
37      /**
38       * Gets the duration of the authentication, in milliseconds.
39       * 
40       * @return duration of the authentication, in milliseconds
41       */
42      public long getAuthenticationDuration() {
43          return authenticationDuration;
44      }
45  
46      /**
47       * Sets the duration of the authentication, in milliseconds.
48       * 
49       * @param duration duration of the authentication, in milliseconds
50       */
51      public void setAuthenticationDuration(long duration) {
52          this.authenticationDuration = duration;
53      }
54  
55      /**
56       * Gets the authentication methods supported by the handler.
57       * 
58       * @return authentication methods supported by the handler
59       */
60      public List<String> getAuthenticationMethods() {
61          return authenticationMethods;
62      }
63  
64      /**
65       * Sets the authentication methods supported by the handler.
66       * 
67       * @param methods authentication methods supported by the handler
68       */
69      public void setAuthenticationMethods(List<String> methods) {
70          this.authenticationMethods = methods;
71      }
72  
73      /**
74       * Populates the authentication duration and methods of the handler.
75       * 
76       * @param handler the authentication handler to populate
77       */
78      protected void populateHandler(AbstractLoginHandler handler) {
79          if (authenticationMethods != null) {
80              handler.getSupportedAuthenticationMethods().addAll(authenticationMethods);
81          }
82          handler.setAuthenticationDuration(authenticationDuration);
83      }
84  }