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.authn.provider;
18  
19  import java.util.ArrayList;
20  import java.util.List;
21  
22  import edu.internet2.middleware.shibboleth.idp.authn.LoginHandler;
23  
24  /**
25   * Base class for authentication handlers.
26   */
27  public abstract class AbstractLoginHandler implements LoginHandler {
28      
29      /** Authentication methods this handler supports. */
30      private ArrayList<String> supportedAuthenticationMethods;
31  
32      /** Length of time, in milliseconds, after which a user should be re-authenticated. */
33      private long authenticationDuration;
34  
35      /** Whether this handler supports foreced re-authentication. */
36      private boolean supportsForceAuthentication;
37  
38      /** Whether this handler supports passive authentication. */
39      private boolean supportsPassive;
40      
41      /** Constructor. */
42      protected AbstractLoginHandler(){
43          supportedAuthenticationMethods = new ArrayList<String>();
44          supportsForceAuthentication = false;
45          supportsPassive = false;
46      }
47      
48      /** {@inheritDoc} */
49      public List<String> getSupportedAuthenticationMethods() {
50          return supportedAuthenticationMethods;
51      }
52  
53      /** {@inheritDoc} */
54      public long getAuthenticationDuration() {
55          return authenticationDuration;
56      }
57      
58      /**
59       * Sets the length of time, in milliseconds, after which a user should be re-authenticated.
60       * 
61       * @param duration length of time, in milliseconds, after which a user should be re-authenticated 
62       */
63      public void setAuthenticationDuration(long duration) {
64          authenticationDuration = duration;
65      }
66  
67      /**
68       * Sets the length of time, in milliseconds, after which a user should be re-authenticated.
69       * 
70       * @param duration length of time, in milliseconds, after which a user should be re-authenticated
71       * 
72       * @deprecated use {@link #setAuthenticationDuration(long)}
73       */
74      public void setAuthenticationDurection(long duration) {
75          authenticationDuration = duration;
76      }
77  
78      /** {@inheritDoc} */
79      public boolean supportsForceAuthentication() {
80          return supportsForceAuthentication;
81      }
82  
83      /**
84       * Sets whether this handler supports forced re-authentication.
85       * 
86       * @param supported whether this handler supports forced re-authentication
87       */
88      public void setSupportsForceAuthentication(boolean supported) {
89          supportsForceAuthentication = supported;
90      }
91  
92      /** {@inheritDoc} */
93      public boolean supportsPassive() {
94          return supportsPassive;
95      }
96  
97      /**
98       * Sets whether this handler supports passive authentication.
99       * 
100      * @param supported whether this handler supports passive authentication.
101      */
102     public void setSupportsPassive(boolean supported) {
103         supportsPassive = supported;
104     }
105 }