Completed Type 2 artifact support.
[java-idp.git] / src / edu / internet2 / middleware / shibboleth / common / ServiceProviderMapper.java
1 /*
2  * The Shibboleth License, Version 1. Copyright (c) 2002 University Corporation for Advanced Internet Development, Inc.
3  * All rights reserved Redistribution and use in source and binary forms, with or without modification, are permitted
4  * provided that the following conditions are met: Redistributions of source code must retain the above copyright
5  * notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above
6  * copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials
7  * provided with the distribution, if any, must include the following acknowledgment: "This product includes software
8  * developed by the University Corporation for Advanced Internet Development <http://www.ucaid.edu> Internet2 Project.
9  * Alternately, this acknowledegement may appear in the software itself, if and wherever such third-party
10  * acknowledgments normally appear. Neither the name of Shibboleth nor the names of its contributors, nor Internet2, nor
11  * the University Corporation for Advanced Internet Development, Inc., nor UCAID may be used to endorse or promote
12  * products derived from this software without specific prior written permission. For written permission, please contact
13  * shibboleth@shibboleth.org Products derived from this software may not be called Shibboleth, Internet2, UCAID, or the
14  * University Corporation for Advanced Internet Development, nor may Shibboleth appear in their name, without prior
15  * written permission of the University Corporation for Advanced Internet Development. THIS SOFTWARE IS PROVIDED BY THE
16  * COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND WITH ALL FAULTS. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT ARE
18  * DISCLAIMED AND THE ENTIRE RISK OF SATISFACTORY QUALITY, PERFORMANCE, ACCURACY, AND EFFORT IS WITH LICENSEE. IN NO
19  * EVENT SHALL THE COPYRIGHT OWNER, CONTRIBUTORS OR THE UNIVERSITY CORPORATION FOR ADVANCED INTERNET DEVELOPMENT, INC.
20  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
23  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26 package edu.internet2.middleware.shibboleth.common;
27
28 import java.net.MalformedURLException;
29 import java.net.URI;
30 import java.net.URISyntaxException;
31 import java.net.URL;
32 import java.util.HashMap;
33 import java.util.Map;
34
35 import org.apache.log4j.Logger;
36 import org.w3c.dom.Element;
37 import org.w3c.dom.NodeList;
38
39 import edu.internet2.middleware.shibboleth.idp.IdPConfig;
40 import edu.internet2.middleware.shibboleth.metadata.EntitiesDescriptor;
41 import edu.internet2.middleware.shibboleth.metadata.Metadata;
42 import edu.internet2.middleware.shibboleth.metadata.EntityDescriptor;
43
44 /**
45  * Class for determining the effective relying party from the unique id of the service provider. Checks first for an
46  * exact match on the service provider, then for membership in a federation. Uses the default relying party if neither
47  * is found.
48  * 
49  * @author Walter Hoehn
50  */
51 public class ServiceProviderMapper {
52
53         private static Logger log = Logger.getLogger(ServiceProviderMapper.class.getName());
54         protected Map relyingParties = new HashMap();
55         private Metadata metaData;
56         private IdPConfig configuration;
57         private Credentials credentials;
58         private NameMapper nameMapper;
59
60         public ServiceProviderMapper(Element rawConfig, IdPConfig configuration, Credentials credentials,
61                         NameMapper nameMapper) throws ServiceProviderMapperException {
62
63                 this.configuration = configuration;
64                 this.credentials = credentials;
65                 this.nameMapper = nameMapper;
66
67                 NodeList itemElements = rawConfig.getElementsByTagNameNS(IdPConfig.configNameSpace, "RelyingParty");
68
69                 for (int i = 0; i < itemElements.getLength(); i++) {
70                         addRelyingParty((Element) itemElements.item(i));
71                 }
72
73                 verifyDefaultParty(configuration);
74
75         }
76
77         public void setMetadata(Metadata metadata) {
78
79                 this.metaData = metadata;
80         }
81
82         private IdPConfig getOriginConfig() {
83
84                 return configuration;
85         }
86
87         protected void verifyDefaultParty(IdPConfig configuration) throws ServiceProviderMapperException {
88
89                 // Verify we have a proper default party
90                 String defaultParty = configuration.getDefaultRelyingPartyName();
91                 if (defaultParty == null || defaultParty.equals("")) {
92                         if (relyingParties.size() != 1) {
93                                 log
94                                                 .error("Default Relying Party not specified.  Add a (defaultRelyingParty) attribute to <IdPConfig>.");
95                                 throw new ServiceProviderMapperException("Required configuration not specified.");
96                         } else {
97                                 log.debug("Only one Relying Party loaded.  Using this as the default.");
98                         }
99                 }
100                 log.debug("Default Relying Party set to: (" + defaultParty + ").");
101                 if (!relyingParties.containsKey(defaultParty)) {
102                         log.error("Default Relying Party refers to a Relying Party that has not been loaded.");
103                         throw new ServiceProviderMapperException("Invalid configuration (Default Relying Party).");
104                 }
105         }
106
107         protected RelyingParty getRelyingPartyImpl(String providerIdFromTarget) {
108
109                 // Null request, send the default
110                 if (providerIdFromTarget == null) {
111                         RelyingParty relyingParty = getDefaultRelyingParty();
112                         log.info("Using default Relying Party: (" + relyingParty.getName() + ").");
113                         return new UnknownProviderWrapper(relyingParty, providerIdFromTarget);
114                 }
115
116                 // Look for a configuration for the specific relying party
117                 if (relyingParties.containsKey(providerIdFromTarget)) {
118                         log.info("Found Relying Party for (" + providerIdFromTarget + ").");
119                         return (RelyingParty) relyingParties.get(providerIdFromTarget);
120                 }
121
122                 // Next, check to see if the relying party is in any groups
123                 RelyingParty groupParty = findRelyingPartyByGroup(providerIdFromTarget);
124                 if (groupParty != null) {
125                         log.info("Provider is a member of Relying Party (" + groupParty.getName() + ").");
126                         return new RelyingPartyGroupWrapper(groupParty, providerIdFromTarget);
127                 }
128
129                 // OK, we can't find it... just send the default
130                 RelyingParty relyingParty = getDefaultRelyingParty();
131                 log.info("Could not locate Relying Party configuration for (" + providerIdFromTarget
132                                 + ").  Using default Relying Party: (" + relyingParty.getName() + ").");
133                 return new UnknownProviderWrapper(relyingParty, providerIdFromTarget);
134         }
135
136         private RelyingParty findRelyingPartyByGroup(String providerIdFromTarget) {
137
138                 if (metaData == null) { return null; }
139
140                 EntityDescriptor provider = metaData.lookup(providerIdFromTarget);
141                 if (provider != null) {
142                         EntitiesDescriptor parent = provider.getEntitiesDescriptor();
143                         while (parent != null) {
144                                 if (relyingParties.containsKey(parent.getName())) {
145                                         log.info("Found matching Relying Party for group (" + parent.getName() + ").");
146                                         return (RelyingParty) relyingParties.get(parent.getName());
147                                 } else {
148                                         log.debug("Provider is a member of group (" + parent.getName()
149                                                         + "), but no matching Relying Party was found.");
150                                 }
151                                 parent = parent.getEntitiesDescriptor();
152                         }
153                 }
154                 return null;
155         }
156
157         public RelyingParty getDefaultRelyingParty() {
158
159                 // If there is no explicit default, pick the single configured Relying
160                 // Party
161                 String defaultParty = getOriginConfig().getDefaultRelyingPartyName();
162                 if (defaultParty == null || defaultParty.equals("")) { return (RelyingParty) relyingParties.values().iterator()
163                                 .next(); }
164
165                 // If we do have a default specified, use it...
166                 return (RelyingParty) relyingParties.get(defaultParty);
167         }
168
169         /**
170          * Returns the relying party for a legacy provider(the default)
171          */
172         public RelyingParty getLegacyRelyingParty() {
173
174                 RelyingParty relyingParty = getDefaultRelyingParty();
175                 log.info("Request is from legacy shib target.  Selecting default Relying Party: (" + relyingParty.getName()
176                                 + ").");
177                 return new LegacyWrapper((RelyingParty) relyingParty);
178
179         }
180
181         /**
182          * Returns the appropriate relying party for the supplied service provider id.
183          */
184         public RelyingParty getRelyingParty(String providerIdFromTarget) {
185
186                 if (providerIdFromTarget == null || providerIdFromTarget.equals("")) {
187                         RelyingParty relyingParty = getDefaultRelyingParty();
188                         log.info("Selecting default Relying Party: (" + relyingParty.getName() + ").");
189                         return new NoMetadataWrapper((RelyingParty) relyingParty);
190                 }
191
192                 return (RelyingParty) getRelyingPartyImpl(providerIdFromTarget);
193         }
194
195         private void addRelyingParty(Element e) throws ServiceProviderMapperException {
196
197                 log.debug("Found a Relying Party.");
198                 try {
199                         if (e.getLocalName().equals("RelyingParty")) {
200                                 RelyingParty party = new RelyingPartyImpl(e, configuration, credentials, nameMapper);
201                                 log.debug("Relying Party (" + party.getName() + ") loaded.");
202                                 relyingParties.put(party.getName(), party);
203                         }
204                 } catch (ServiceProviderMapperException exc) {
205                         log.error("Encountered an error while attempting to load Relying Party configuration.  Skipping...");
206                 }
207
208         }
209
210         /**
211          * Base relying party implementation.
212          * 
213          * @author Walter Hoehn
214          */
215         protected class RelyingPartyImpl implements RelyingParty {
216
217                 private RelyingPartyIdentityProvider identityProvider;
218                 private String name;
219                 private String overridenOriginProviderId;
220                 private URL overridenAAUrl;
221                 private URI overridenDefaultAuthMethod;
222                 private String hsNameFormatId;
223                 private IdPConfig configuration;
224                 private boolean overridenPassThruErrors = false;
225                 private boolean passThruIsOverriden = false;
226                 private boolean forceAttributePush = false;
227                 private boolean forceAttributeNoPush = false;
228                 private boolean defaultToPOST = true;
229                 private boolean wantsAssertionsSigned = false;
230                 private int preferredArtifactType = 1;
231
232                 public RelyingPartyImpl(Element partyConfig, IdPConfig globalConfig, Credentials credentials,
233                                 NameMapper nameMapper) throws ServiceProviderMapperException {
234
235                         configuration = globalConfig;
236
237                         // Get party name
238                         name = ((Element) partyConfig).getAttribute("name");
239                         if (name == null || name.equals("")) {
240                                 log.error("Relying Party name not set.  Add a (name) attribute to <RelyingParty>.");
241                                 throw new ServiceProviderMapperException("Required configuration not specified.");
242                         }
243                         log.debug("Loading Relying Party: (" + name + ").");
244
245                         // Process overrides for global configuration data
246                         String attribute = ((Element) partyConfig).getAttribute("providerId");
247                         if (attribute != null && !attribute.equals("")) {
248                                 log.debug("Overriding providerId for Relying Pary (" + name + ") with (" + attribute + ").");
249                                 overridenOriginProviderId = attribute;
250                         }
251
252                         attribute = ((Element) partyConfig).getAttribute("AAUrl");
253                         if (attribute != null && !attribute.equals("")) {
254                                 log.debug("Overriding AAUrl for Relying Pary (" + name + ") with (" + attribute + ").");
255                                 try {
256                                         overridenAAUrl = new URL(attribute);
257                                 } catch (MalformedURLException e) {
258                                         log.error("(AAUrl) attribute to is not a valid URL.");
259                                         throw new ServiceProviderMapperException("Configuration is invalid.");
260                                 }
261                         }
262
263                         attribute = ((Element) partyConfig).getAttribute("defaultAuthMethod");
264                         if (attribute != null && !attribute.equals("")) {
265                                 log.debug("Overriding defaultAuthMethod for Relying Pary (" + name + ") with (" + attribute + ").");
266                                 try {
267                                         overridenDefaultAuthMethod = new URI(attribute);
268                                 } catch (URISyntaxException e1) {
269                                         log.error("(defaultAuthMethod) attribute to is not a valid URI.");
270                                         throw new ServiceProviderMapperException("Configuration is invalid.");
271                                 }
272                         }
273
274                         attribute = ((Element) partyConfig).getAttribute("passThruErrors");
275                         if (attribute != null && !attribute.equals("")) {
276                                 log.debug("Overriding passThruErrors for Relying Pary (" + name + ") with (" + attribute + ").");
277                                 overridenPassThruErrors = Boolean.valueOf(attribute).booleanValue();
278                                 passThruIsOverriden = true;
279                         }
280
281                         // SSO profile defaulting
282                         attribute = ((Element) partyConfig).getAttribute("defaultToPOSTProfile");
283                         if (attribute != null && !attribute.equals("")) {
284                                 defaultToPOST = Boolean.valueOf(attribute).booleanValue();
285                         }
286                         if (defaultToPOST) {
287                                 log.debug("Relying party defaults to POST profile.");
288                         } else {
289                                 log.debug("Relying party defaults to Artifact profile.");
290                         }
291
292                         // Relying Party wants assertions signed?
293                         attribute = ((Element) partyConfig).getAttribute("signAssertions");
294                         if (attribute != null && !attribute.equals("")) {
295                                 wantsAssertionsSigned = Boolean.valueOf(attribute).booleanValue();
296                         }
297                         if (wantsAssertionsSigned) {
298                                 log.debug("Relying party wants SAML Assertions to be signed.");
299                         } else {
300                                 log.debug("Relying party does not want SAML Assertions to be signed.");
301                         }
302
303                         // Determine whether or not we are forcing attribute push on or off
304                         String forcePush = ((Element) partyConfig).getAttribute("forceAttributePush");
305                         String forceNoPush = ((Element) partyConfig).getAttribute("forceAttributeNoPush");
306
307                         if (forcePush != null && Boolean.valueOf(forcePush).booleanValue() && forceNoPush != null
308                                         && Boolean.valueOf(forceNoPush).booleanValue()) {
309                                 log.error("Invalid configuration:  Attribute push is forced to ON and OFF for this relying "
310                                                 + "party.  Turning off forcing in favor of profile defaults.");
311                         } else {
312                                 forceAttributePush = Boolean.valueOf(forcePush).booleanValue();
313                                 forceAttributeNoPush = Boolean.valueOf(forceNoPush).booleanValue();
314                                 log.debug("Attribute push forcing is set to (" + forceAttributePush + ").");
315                                 log.debug("No attribute push forcing is set to (" + forceAttributeNoPush + ").");
316                         }
317
318                         attribute = ((Element) partyConfig).getAttribute("preferredArtifactType");
319                         if (attribute != null && !attribute.equals("")) {
320                                 log.debug("Overriding AAUrl for Relying Pary (" + name + ") with (" + attribute + ").");
321                                 try {
322                                         preferredArtifactType = Integer.parseInt(attribute);
323                                 } catch (NumberFormatException e) {
324                                         log.error("(preferredArtifactType) attribute to is not a valid integer.");
325                                         throw new ServiceProviderMapperException("Configuration is invalid.");
326                                 }
327                                 log.debug("Preferred artifact type: (" + preferredArtifactType + ").");
328                         }
329
330                         // Load and verify the name format that the HS should use in
331                         // assertions for this RelyingParty
332                         NodeList hsNameFormats = ((Element) partyConfig).getElementsByTagNameNS(IdPConfig.configNameSpace,
333                                         "HSNameFormat");
334                         // If no specification. Make sure we have a default mapping
335                         if (hsNameFormats.getLength() < 1) {
336                                 if (nameMapper.getNameIdentifierMappingById(null) == null) {
337                                         log.error("Relying Party HS Name Format not set.  Add a <HSNameFormat> element to <RelyingParty>.");
338                                         throw new ServiceProviderMapperException("Required configuration not specified.");
339                                 }
340
341                         } else {
342                                 // We do have a specification, so make sure it points to a
343                                 // valid Name Mapping
344                                 if (hsNameFormats.getLength() > 1) {
345                                         log.warn("Found multiple HSNameFormat specifications for Relying Party (" + name
346                                                         + ").  Ignoring all but the first.");
347                                 }
348
349                                 hsNameFormatId = ((Element) hsNameFormats.item(0)).getAttribute("nameMapping");
350                                 if (hsNameFormatId == null || hsNameFormatId.equals("")) {
351                                         log.error("HS Name Format mapping not set.  Add a (nameMapping) attribute to <HSNameFormat>.");
352                                         throw new ServiceProviderMapperException("Required configuration not specified.");
353                                 }
354
355                                 if (nameMapper.getNameIdentifierMappingById(hsNameFormatId) == null) {
356                                         log.error("Relying Party HS Name Format refers to a name mapping that is not loaded.");
357                                         throw new ServiceProviderMapperException("Required configuration not specified.");
358                                 }
359                         }
360
361                         // Load the credential for signing
362                         String credentialName = ((Element) partyConfig).getAttribute("signingCredential");
363                         Credential signingCredential = credentials.getCredential(credentialName);
364                         if (signingCredential == null) {
365                                 if (credentialName == null || credentialName.equals("")) {
366                                         log.error("Relying Party credential not set.  Add a (signingCredential) "
367                                                         + "attribute to <RelyingParty>.");
368                                         throw new ServiceProviderMapperException("Required configuration not specified.");
369                                 } else {
370                                         log.error("Relying Party credential invalid.  Fix the (signingCredential) attribute "
371                                                         + "on <RelyingParty>.");
372                                         throw new ServiceProviderMapperException("Required configuration is invalid.");
373                                 }
374
375                         }
376
377                         // Initialize and Identity Provider object for this use by this relying party
378                         identityProvider = new RelyingPartyIdentityProvider(overridenOriginProviderId != null
379                                         ? overridenOriginProviderId
380                                         : configuration.getProviderId(), signingCredential);
381
382                 }
383
384                 public String getProviderId() {
385
386                         return name;
387                 }
388
389                 public String getName() {
390
391                         return name;
392                 }
393
394                 public IdentityProvider getIdentityProvider() {
395
396                         return identityProvider;
397                 }
398
399                 public boolean isLegacyProvider() {
400
401                         return false;
402                 }
403
404                 public String getHSNameFormatId() {
405
406                         return hsNameFormatId;
407                 }
408
409                 public URI getDefaultAuthMethod() {
410
411                         if (overridenDefaultAuthMethod != null) {
412                                 return overridenDefaultAuthMethod;
413                         } else {
414                                 return configuration.getDefaultAuthMethod();
415                         }
416                 }
417
418                 public URL getAAUrl() {
419
420                         if (overridenAAUrl != null) {
421                                 return overridenAAUrl;
422                         } else {
423                                 return configuration.getAAUrl();
424                         }
425                 }
426
427                 public boolean passThruErrors() {
428
429                         if (passThruIsOverriden) {
430                                 return overridenPassThruErrors;
431                         } else {
432                                 return configuration.passThruErrors();
433                         }
434                 }
435
436                 public boolean forceAttributePush() {
437
438                         return forceAttributePush;
439                 }
440
441                 public boolean forceAttributeNoPush() {
442
443                         return forceAttributeNoPush;
444                 }
445
446                 public boolean defaultToPOSTProfile() {
447
448                         return defaultToPOST;
449                 }
450
451                 public boolean wantsAssertionsSigned() {
452
453                         return wantsAssertionsSigned;
454                 }
455
456                 public int getPreferredArtifactType() {
457
458                         return preferredArtifactType;
459                 }
460
461                 /**
462                  * Default identity provider implementation.
463                  * 
464                  * @author Walter Hoehn
465                  */
466                 protected class RelyingPartyIdentityProvider implements IdentityProvider {
467
468                         private String providerId;
469                         private Credential credential;
470
471                         public RelyingPartyIdentityProvider(String providerId, Credential credential) {
472
473                                 this.providerId = providerId;
474                                 this.credential = credential;
475                         }
476
477                         /*
478                          * @see edu.internet2.middleware.shibboleth.common.IdentityProvider#getProviderId()
479                          */
480                         public String getProviderId() {
481
482                                 return providerId;
483                         }
484
485                         /*
486                          * @see edu.internet2.middleware.shibboleth.common.IdentityProvider#getSigningCredential()
487                          */
488                         public Credential getSigningCredential() {
489
490                                 return credential;
491                         }
492                 }
493
494         }
495
496         /**
497          * Relying party implementation wrapper for relying parties that are federations.
498          * 
499          * @author Walter Hoehn
500          */
501         class RelyingPartyGroupWrapper implements RelyingParty {
502
503                 private RelyingParty wrapped;
504                 private String providerId;
505
506                 RelyingPartyGroupWrapper(RelyingParty wrapped, String providerId) {
507
508                         this.wrapped = wrapped;
509                         this.providerId = providerId;
510                 }
511
512                 public String getName() {
513
514                         return wrapped.getName();
515                 }
516
517                 public boolean isLegacyProvider() {
518
519                         return false;
520                 }
521
522                 public IdentityProvider getIdentityProvider() {
523
524                         return wrapped.getIdentityProvider();
525                 }
526
527                 public String getProviderId() {
528
529                         return providerId;
530                 }
531
532                 public String getHSNameFormatId() {
533
534                         return wrapped.getHSNameFormatId();
535                 }
536
537                 public URL getAAUrl() {
538
539                         return wrapped.getAAUrl();
540                 }
541
542                 public URI getDefaultAuthMethod() {
543
544                         return wrapped.getDefaultAuthMethod();
545                 }
546
547                 public boolean passThruErrors() {
548
549                         return wrapped.passThruErrors();
550                 }
551
552                 public boolean forceAttributePush() {
553
554                         return wrapped.forceAttributePush();
555                 }
556
557                 public boolean forceAttributeNoPush() {
558
559                         return wrapped.forceAttributeNoPush();
560                 }
561
562                 public boolean defaultToPOSTProfile() {
563
564                         return wrapped.defaultToPOSTProfile();
565                 }
566
567                 public boolean wantsAssertionsSigned() {
568
569                         return wrapped.wantsAssertionsSigned();
570                 }
571
572                 public int getPreferredArtifactType() {
573
574                         return wrapped.getPreferredArtifactType();
575                 }
576         }
577
578         /**
579          * Relying party implementation wrapper for anonymous service providers.
580          * 
581          * @author Walter Hoehn
582          */
583         protected class UnknownProviderWrapper implements RelyingParty {
584
585                 protected RelyingParty wrapped;
586                 protected String providerId;
587
588                 protected UnknownProviderWrapper(RelyingParty wrapped, String providerId) {
589
590                         this.wrapped = wrapped;
591                         this.providerId = providerId;
592                 }
593
594                 public String getName() {
595
596                         return wrapped.getName();
597                 }
598
599                 public IdentityProvider getIdentityProvider() {
600
601                         return wrapped.getIdentityProvider();
602                 }
603
604                 public String getProviderId() {
605
606                         return providerId;
607                 }
608
609                 public String getHSNameFormatId() {
610
611                         return wrapped.getHSNameFormatId();
612                 }
613
614                 public boolean isLegacyProvider() {
615
616                         return wrapped.isLegacyProvider();
617                 }
618
619                 public URL getAAUrl() {
620
621                         return wrapped.getAAUrl();
622                 }
623
624                 public URI getDefaultAuthMethod() {
625
626                         return wrapped.getDefaultAuthMethod();
627                 }
628
629                 public boolean passThruErrors() {
630
631                         return wrapped.passThruErrors();
632                 }
633
634                 public boolean forceAttributePush() {
635
636                         return false;
637                 }
638
639                 public boolean forceAttributeNoPush() {
640
641                         return false;
642                 }
643
644                 public boolean defaultToPOSTProfile() {
645
646                         return true;
647                 }
648
649                 public boolean wantsAssertionsSigned() {
650
651                         return wrapped.wantsAssertionsSigned();
652                 }
653
654                 public int getPreferredArtifactType() {
655
656                         return wrapped.getPreferredArtifactType();
657                 }
658         }
659
660         /**
661          * Relying party wrapper for Shibboleth &lt;=1.1 service providers.
662          * 
663          * @author Walter Hoehn
664          */
665         class LegacyWrapper extends UnknownProviderWrapper implements RelyingParty {
666
667                 LegacyWrapper(RelyingParty wrapped) {
668
669                         super(wrapped, null);
670                 }
671
672                 public boolean isLegacyProvider() {
673
674                         return true;
675                 }
676
677                 public String getHSNameFormatId() {
678
679                         return ((RelyingParty) wrapped).getHSNameFormatId();
680                 }
681
682                 public URL getAAUrl() {
683
684                         return ((RelyingParty) wrapped).getAAUrl();
685                 }
686
687                 public URI getDefaultAuthMethod() {
688
689                         return ((RelyingParty) wrapped).getDefaultAuthMethod();
690                 }
691         }
692
693         /**
694          * Relying party wrapper for providers for which we have no metadata
695          * 
696          * @author Walter Hoehn
697          */
698         class NoMetadataWrapper extends UnknownProviderWrapper implements RelyingParty {
699
700                 NoMetadataWrapper(RelyingParty wrapped) {
701
702                         super(wrapped, null);
703                 }
704
705                 public String getHSNameFormatId() {
706
707                         return ((RelyingParty) wrapped).getHSNameFormatId();
708                 }
709
710                 public URL getAAUrl() {
711
712                         return ((RelyingParty) wrapped).getAAUrl();
713                 }
714
715                 public URI getDefaultAuthMethod() {
716
717                         return ((RelyingParty) wrapped).getDefaultAuthMethod();
718                 }
719         }
720 }