View Javadoc

1   /*
2    * Copyright [2005] [University Corporation for Advanced Internet Development, Inc.] Licensed under the Apache License,
3    * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy
4    * of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in
5    * writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
6    * OF ANY KIND, either express or implied. See the License for the specific language governing permissions and
7    * limitations under the License.
8    */
9   
10  package edu.internet2.middleware.shibboleth.common.attribute.resolver.provider.dataConnector;
11  
12  import java.util.HashMap;
13  import java.util.List;
14  import java.util.Map;
15  
16  import edu.internet2.middleware.shibboleth.common.attribute.BaseAttribute;
17  import edu.internet2.middleware.shibboleth.common.attribute.resolver.AttributeResolutionException;
18  import edu.internet2.middleware.shibboleth.common.attribute.resolver.provider.ShibbolethResolutionContext;
19  
20  /**
21   * Data connector implementation that returns staticly defined attributes.
22   */
23  public class StaticDataConnector extends BaseDataConnector {
24  
25      /** Source Data. */
26      private Map<String, BaseAttribute> attributes;
27  
28      /**
29       * Constructor.
30       * 
31       * @param staticAttributes attributes this data connector will return
32       */
33      public StaticDataConnector(List<BaseAttribute<String>> staticAttributes) {
34          attributes = new HashMap<String, BaseAttribute>(staticAttributes.size());
35          if (staticAttributes != null) {            
36              for (BaseAttribute<String> attribute : staticAttributes) {
37                  attributes.put(attribute.getId(), attribute);
38              }
39          }
40      }
41  
42      /** {@inheritDoc} */
43      public Map<String, BaseAttribute> resolve(ShibbolethResolutionContext resolutionContext)
44              throws AttributeResolutionException {
45          return attributes;
46      }
47  
48      /** {@inheritDoc} */
49      public void validate() throws AttributeResolutionException {
50          // Do nothing
51      }
52  }