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.attribute.resolver.provider.dataConnector;
19  
20  import java.util.HashMap;
21  import java.util.List;
22  import java.util.Map;
23  
24  import edu.internet2.middleware.shibboleth.common.attribute.BaseAttribute;
25  import edu.internet2.middleware.shibboleth.common.attribute.resolver.AttributeResolutionException;
26  import edu.internet2.middleware.shibboleth.common.attribute.resolver.provider.ShibbolethResolutionContext;
27  
28  /** Data connector implementation that returns statically defined attributes. */
29  public class StaticDataConnector extends BaseDataConnector {
30  
31      /** Source Data. */
32      private Map<String, BaseAttribute> attributes;
33  
34      /**
35       * Constructor.
36       * 
37       * @param staticAttributes attributes this data connector will return
38       */
39      public StaticDataConnector(List<BaseAttribute<String>> staticAttributes) {
40          attributes = new HashMap<String, BaseAttribute>(staticAttributes.size());
41          if (staticAttributes != null) {            
42              for (BaseAttribute<String> attribute : staticAttributes) {
43                  attributes.put(attribute.getId(), attribute);
44              }
45          }
46      }
47  
48      /** {@inheritDoc} */
49      public Map<String, BaseAttribute> resolve(ShibbolethResolutionContext resolutionContext)
50              throws AttributeResolutionException {
51          return attributes;
52      }
53  
54      /** {@inheritDoc} */
55      public void validate() throws AttributeResolutionException {
56          // Do nothing
57      }
58  }