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