View Javadoc

1   /*
2    * Copyright 2011 The Ohio State University
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 edu.internet2.middleware.shibboleth.common.attribute.resolver.provider.attributeDefinition.CryptoTransientIdAttributeDefinition;
20  import edu.internet2.middleware.shibboleth.common.util.DataSealer;
21  
22  /**
23   * Spring factory bean producing {@link CryptoTransientIdAttributeDefinition}s.
24   */
25  public class CryptoTransientIdAttributeDefinitionFactoryBean extends BaseAttributeDefinitionFactoryBean {
26  
27      /** Object used to protect and encrypt identifiers. */
28      private DataSealer dataSealer;
29  
30      /** Length, in milliseconds, identifiers are valid. */
31      private long idLifetime = 1000 * 60 * 60 * 4;
32    
33      /** {@inheritDoc} */
34      public Class<CryptoTransientIdAttributeDefinition> getObjectType() {
35          return CryptoTransientIdAttributeDefinition.class;
36      }
37  
38      /**
39       * Gets the object used to protect and encrypt identifiers.
40       * 
41       * @return object used to protect and encrypt identifiers
42       */
43      public DataSealer getDataSealer() {
44          return dataSealer;
45      }
46  
47      /**
48       * Sets the object used to protect and encrypt identifiers.
49       * 
50       * @param sealer object used to protect and encrypt identifiers
51       */
52      public void setDataSealer(DataSealer sealer) {
53          dataSealer = sealer;
54      }
55  
56      /**
57       * Gets the time, in milliseconds, ids are valid.
58       * 
59       * @return time, in milliseconds, ids are valid
60       */
61      public long getIdLifetime() {
62          return idLifetime;
63      }
64  
65      /**
66       * Sets the time, in milliseconds, ids are valid.
67       * 
68       * @param lifetime time, in milliseconds, ids are valid
69       */
70      public void setIdLifetime(long lifetime) {
71          idLifetime = lifetime;
72      }
73      
74      /** {@inheritDoc} */
75      protected Object createInstance() throws Exception {
76          CryptoTransientIdAttributeDefinition definition = new CryptoTransientIdAttributeDefinition(getDataSealer());
77          definition.setIdLifetime(idLifetime);
78          populateAttributeDefinition(definition);
79  
80          return definition;
81      }
82  }