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 java.util.List;
21  
22  import org.apache.velocity.app.VelocityEngine;
23  
24  import edu.internet2.middleware.shibboleth.common.attribute.resolver.provider.attributeDefinition.TemplateAttributeDefinition;
25  
26  /**
27   * Spring factory bean that produces {@link TemplateAttributeDefinition}s.
28   */
29  public class TemplateAttributeDefinitionFactoryBean extends BaseAttributeDefinitionFactoryBean {
30  
31      /** Attribute template string. */
32      private String attributeTemplate;
33  
34      /** IDs of source attributes. */
35      private List<String> sourceAttributes;
36  
37      /** Velocity engine instance. */
38      private VelocityEngine velocityEngine;
39  
40      /** {@inheritDoc} */
41      public Class getObjectType() {
42          return TemplateAttributeDefinition.class;
43      }
44  
45      /** {@inheritDoc} */
46      protected Object createInstance() throws Exception {
47          TemplateAttributeDefinition definition = new TemplateAttributeDefinition(velocityEngine);
48          populateAttributeDefinition(definition);
49  
50          definition.setAttributeTemplate(attributeTemplate);
51          definition.setSourceAttributes(sourceAttributes);
52  
53          definition.initialize();
54  
55          return definition;
56      }
57  
58      /**
59       * Get the attribute template.
60       * 
61       * @return the attribute template
62       */
63      public String getAttributeTemplate() {
64          return attributeTemplate;
65      }
66  
67      /**
68       * Set the attribute template.
69       * 
70       * @param newAttributeTemplate the attribute template
71       */
72      public void setAttributeTemplate(String newAttributeTemplate) {
73          attributeTemplate = newAttributeTemplate;
74      }
75  
76      /**
77       * Get the source attribute IDs.
78       * 
79       * @return the source attribute IDs
80       */
81      public List<String> getSourceAttributes() {
82          return sourceAttributes;
83      }
84  
85      /**
86       * Set the source attribute IDs.
87       * 
88       * @param newSourceAttributes the source attribute IDs
89       */
90      public void setSourceAttributes(List<String> newSourceAttributes) {
91          sourceAttributes = newSourceAttributes;
92      }
93  
94      /**
95       * Get velocity engine instance.
96       * 
97       * @return velocity engine instance
98       */
99      public VelocityEngine getVelocityEngine() {
100         return velocityEngine;
101     }
102 
103     /**
104      * Set velocity engine instance.
105      * 
106      * @param newVelocityEngine velocity engine instance
107      */
108     public void setVelocityEngine(VelocityEngine newVelocityEngine) {
109         velocityEngine = newVelocityEngine;
110     }
111 
112 }