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