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