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.common.config.attribute.resolver.attributeDefinition;
18  
19  import org.opensaml.util.storage.StorageService;
20  
21  import edu.internet2.middleware.shibboleth.common.attribute.resolver.provider.attributeDefinition.TransientIdAttributeDefinition;
22  import edu.internet2.middleware.shibboleth.common.attribute.resolver.provider.attributeDefinition.TransientIdEntry;
23  
24  /**
25   * Spring factory bean producing {@link TransientIdAttributeDefinition}s.
26   */
27  public class TransientIdAttributeDefinitionFactoryBean extends BaseAttributeDefinitionFactoryBean {
28  
29      /** Store used to map transient identifier tokens to principal names. */
30      private StorageService<String, TransientIdEntry> identifierStore;
31      
32      /** Length, in milliseconds, identifiers are valid. */
33      private long idLifetime = 1000 * 60 * 60 * 4;
34  
35      /** {@inheritDoc} */
36      public Class getObjectType() {
37          return TransientIdAttributeDefinition.class;
38      }
39  
40      /**
41       * Gets the store used to map transient identifier tokens to principal names.
42       * 
43       * @return store used to map transient identifier tokens to principal names
44       */
45      public StorageService<String, TransientIdEntry> getIdentifierStore() {
46          return identifierStore;
47      }
48  
49      /**
50       * Sets the store used to map transient identifier tokens to principal names.
51       * 
52       * @param store store used to map transient identifier tokens to principal names
53       */
54      public void setIdentifierStore(StorageService<String, TransientIdEntry> store) {
55          identifierStore = store;
56      }
57      
58      /**
59       * Gets the length of time, in milliseconds, the identifier are valid.
60       * 
61       * @return length of time, in milliseconds, the identifier are valid
62       */
63      public long getIdentifierLifetime() {
64          return idLifetime;
65      }
66      
67      /**
68       * Sets the length of time, in milliseconds, the identifier are valid.
69       * 
70       * @param lifetime length of time, in milliseconds, the identifier are valid
71       */
72      public void setIdentifierLifetime(long lifetime) {
73          idLifetime = lifetime;
74      }
75  
76      /** {@inheritDoc} */
77      protected Object createInstance() throws Exception {
78          TransientIdAttributeDefinition definition = new TransientIdAttributeDefinition(getIdentifierStore());
79          populateAttributeDefinition(definition);
80          definition.setTokenLiftetime(idLifetime);
81          return definition;
82      }
83  }