2 * External class so it can be configured as a plugin in XML.
4 * <CustomDataConnector id="jutest" class="edu.internet2.middleware.shibboleth.runner.AttributeSourceForTests"/>
9 * Copyright [2005] [University Corporation for Advanced Internet Development, Inc.]
11 * Licensed under the Apache License, Version 2.0 (the "License");
12 * you may not use this file except in compliance with the License.
13 * You may obtain a copy of the License at
15 * http://www.apache.org/licenses/LICENSE-2.0
17 * Unless required by applicable law or agreed to in writing, software
18 * distributed under the License is distributed on an "AS IS" BASIS,
19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 * See the License for the specific language governing permissions and
21 * limitations under the License.
24 package edu.internet2.middleware.shibboleth.runner;
26 import java.security.Principal;
28 import javax.naming.directory.Attributes;
29 import javax.naming.directory.BasicAttribute;
31 import org.w3c.dom.Element;
33 import edu.internet2.middleware.shibboleth.aa.attrresolv.DataConnectorPlugIn;
34 import edu.internet2.middleware.shibboleth.aa.attrresolv.Dependencies;
35 import edu.internet2.middleware.shibboleth.aa.attrresolv.ResolutionPlugInException;
36 import edu.internet2.middleware.shibboleth.aa.attrresolv.provider.BaseResolutionPlugIn;
39 * An in-memory Attribute source for JUnit tests. This class exposes
40 * a static collection to which a parent test case can add attributes.
41 * When the IdP requests attributes for any principal, the static
42 * collection is returned and is then processed into SAML. This allows
43 * a Test Case to create attributes that pass or fail the ARP and AAP
44 * without a complex LDAP, JDBC, or file to produce them
47 public class AttributeSourceForTests
48 extends BaseResolutionPlugIn
49 implements DataConnectorPlugIn {
52 * The test case adds Attributes to this collection, or can
53 * clear it and refill it.
56 public AttributeSourceForTests(Element e) throws ResolutionPlugInException {
61 * When called to return attributes for a particular principal,
62 * return the static collection plus one for the Principal name.
64 public Attributes resolve(Principal principal, String requester, String responder, Dependencies depends) {
65 ShibbolethRunner.attributes.put(new BasicAttribute("eduPersonPrincipalName", principal.getName()));
66 return ShibbolethRunner.attributes;
69 public String getFailoverDependencyId() {