Cleaned up imports.
[java-idp.git] / tests / edu / internet2 / middleware / shibboleth / hs / provider / NameMapperTests.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.hs.provider;
27
28 import java.io.File;
29 import java.io.StringReader;
30 import java.net.MalformedURLException;
31
32 import junit.framework.TestCase;
33
34 import org.apache.log4j.BasicConfigurator;
35 import org.apache.log4j.Level;
36 import org.apache.log4j.Logger;
37 import org.opensaml.SAMLNameIdentifier;
38 import org.xml.sax.InputSource;
39
40 import edu.internet2.middleware.shibboleth.common.AuthNPrincipal;
41 import edu.internet2.middleware.shibboleth.common.Credential;
42 import edu.internet2.middleware.shibboleth.common.IdentityProvider;
43 import edu.internet2.middleware.shibboleth.common.NameIdentifierMapping;
44 import edu.internet2.middleware.shibboleth.common.NameIdentifierMappingException;
45 import edu.internet2.middleware.shibboleth.common.NameMapper;
46 import edu.internet2.middleware.shibboleth.common.ServiceProvider;
47 import edu.internet2.middleware.shibboleth.xml.Parser;
48
49
50
51 /**
52  * Validation suite for the <code>NameMapper</code>.
53  * 
54  * @author Walter Hoehn(wassa@columbia.edu)
55  */
56
57 public class NameMapperTests extends TestCase {
58
59         private Parser.DOMParser parser = new Parser.DOMParser(true);
60
61         public NameMapperTests(String name) {
62
63                 super(name);
64                 BasicConfigurator.resetConfiguration();
65                 BasicConfigurator.configure();
66                 Logger.getRootLogger().setLevel(Level.DEBUG);
67         }
68
69         public static void main(String[] args) {
70
71                 junit.textui.TestRunner.run(NameMapperTests.class);
72                 BasicConfigurator.configure();
73                 Logger.getRootLogger().setLevel(Level.DEBUG);
74         }
75
76         protected void setUp() throws Exception {
77
78                 super.setUp();
79
80         }
81
82         public void testCryptoMapping() {
83
84                 try {
85
86                         NameMapper nameMapper = new NameMapper();
87
88                         File file = new File("data/handle.jks");
89
90                         String rawConfig = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
91                                         + "<NameMapping xmlns=\"urn:mace:shibboleth:namemapper:1.0\""
92                                         + "             xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
93                                         + "             xsi:schemaLocation=\"urn:mace:shibboleth:namemapper:1.0 namemapper.xsd\" "
94                                         + "                     id=\"cryptotest\" format=\"urn:mace:shibboleth:1.0:nameIdentifier\" "
95                                         + "                     type=\"CryptoHandleGenerator\" handleTTL=\"1800\">" 
96                                         + "             <KeyStorePath>" + file.toURL().toString() + "</KeyStorePath>" 
97                                         + "             <KeyStorePassword>shibhs</KeyStorePassword>"
98                                         + "             <KeyStoreKeyAlias>handlekey</KeyStoreKeyAlias>"
99                                         + "             <KeyStoreKeyPassword>shibhs</KeyStoreKeyPassword>" 
100                                         + "     </NameMapping>";
101
102                         parser.parse(new InputSource(new StringReader(rawConfig)));
103                         nameMapper.addNameMapping(parser.getDocument().getDocumentElement());
104
105                         SAMLNameIdentifier nameId = nameMapper.getNameIdentifierName("cryptotest", new AuthNPrincipal(
106                                         "testprincipal"), new BasicServiceProvider(), new BasicIdentityProvider("urn-x:testid"));
107
108                         AuthNPrincipal principal = nameMapper.getPrincipal(nameId, new BasicServiceProvider(),
109                                         new BasicIdentityProvider("urn-x:testid"));
110                         assertEquals("Round-trip handle validation failed.", principal.getName(), "testprincipal");
111
112                 } catch (MalformedURLException e) {
113                         fail("Error in test specification: " + e.getMessage());
114                 } catch (NameIdentifierMappingException e) {
115                         fail("Error exercising NameMaper: " + e.getMessage());
116                 } catch (Exception e) {
117                         fail("Error exercising NameMaper: " + e.getMessage());
118                 }
119
120         }
121
122         public void testCryptoMappingWithOverriddenAlgorithms() {
123
124                 try {
125
126                         NameMapper nameMapper = new NameMapper();
127
128                         File file = new File("data/handle.jks");
129
130                         String rawConfig = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
131                                         + "<NameMapping xmlns=\"urn:mace:shibboleth:namemapper:1.0\""
132                                         + "             xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
133                                         + "             xsi:schemaLocation=\"urn:mace:shibboleth:namemapper:1.0 namemapper.xsd\" "
134                                         + "                     id=\"cryptotest\" format=\"urn:mace:shibboleth:1.0:nameIdentifier\" "
135                                         + "                     type=\"CryptoHandleGenerator\" handleTTL=\"1800\">" 
136                                         + "             <KeyStorePath>"+ file.toURL().toString() + "</KeyStorePath>" 
137                                         + "             <KeyStorePassword>shibhs</KeyStorePassword>"
138                                         + "             <KeyStoreKeyAlias>handlekey</KeyStoreKeyAlias>"
139                                         + "             <KeyStoreKeyPassword>shibhs</KeyStoreKeyPassword>"
140                                         + "             <Cipher>DESede/CBC/PKCS5Padding</Cipher>" 
141                                         + "             <MAC>HmacSHA1</MAC>"
142                                         + "             <KeyStoreType>JCEKS</KeyStoreType>" 
143                                         + "     </NameMapping>";
144
145                         parser.parse(new InputSource(new StringReader(rawConfig)));
146                         nameMapper.addNameMapping(parser.getDocument().getDocumentElement());
147
148                         SAMLNameIdentifier nameId = nameMapper.getNameIdentifierName("cryptotest", new AuthNPrincipal(
149                                         "testprincipal"), new BasicServiceProvider(), new BasicIdentityProvider("urn-x:testid"));
150
151                         AuthNPrincipal principal = nameMapper.getPrincipal(nameId, new BasicServiceProvider(),
152                                         new BasicIdentityProvider("urn-x:testid"));
153                         assertEquals("Round-trip handle validation failed.", principal.getName(), "testprincipal");
154
155                 } catch (MalformedURLException e) {
156                         fail("Error in test specification: " + e.getMessage());
157                 } catch (NameIdentifierMappingException e) {
158                         fail("Error exercising NameMaper: " + e.getMessage());
159                 } catch (Exception e) {
160                         fail("Error exercising NameMaper: " + e.getMessage());
161                 }
162
163         }
164         
165         public void testCryptoMappingBadQualifier() {
166
167                 try {
168
169                         NameMapper nameMapper = new NameMapper();
170
171                         File file = new File("data/handle.jks");
172
173                         String rawConfig = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
174                                         + "<NameMapping xmlns=\"urn:mace:shibboleth:namemapper:1.0\""
175                                         + "             xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
176                                         + "             xsi:schemaLocation=\"urn:mace:shibboleth:namemapper:1.0 namemapper.xsd\" "
177                                         + "                     id=\"cryptotest\" format=\"urn:mace:shibboleth:1.0:nameIdentifier\" "
178                                         + "                     type=\"CryptoHandleGenerator\" handleTTL=\"1800\">" 
179                                         + "             <KeyStorePath>" + file.toURL().toString() + "</KeyStorePath>" 
180                                         + "             <KeyStorePassword>shibhs</KeyStorePassword>"
181                                         + "             <KeyStoreKeyAlias>handlekey</KeyStoreKeyAlias>"
182                                         + "             <KeyStoreKeyPassword>shibhs</KeyStoreKeyPassword>" 
183                                         + "     </NameMapping>";
184
185                         parser.parse(new InputSource(new StringReader(rawConfig)));
186                         nameMapper.addNameMapping(parser.getDocument().getDocumentElement());
187
188                         SAMLNameIdentifier nameId = nameMapper.getNameIdentifierName("cryptotest", new AuthNPrincipal(
189                                         "testprincipal"), new BasicServiceProvider(), new BasicIdentityProvider("urn-x:good"));
190
191                         AuthNPrincipal principal = nameMapper.getPrincipal(nameId, new BasicServiceProvider(),
192                                         new BasicIdentityProvider("urn-x:bad"));
193                 
194                         fail("Expected failure for bad name qualifier.");
195                         
196                 } catch (NameIdentifierMappingException e) {
197                         //This exception should be generated by this test
198                         
199                 } catch (MalformedURLException e) {
200                         fail("Error in test specification: " + e.getMessage());
201                 
202                 } catch (Exception e) {
203                         fail("Error exercising NameMaper: " + e.getMessage());
204                 }
205
206         }
207
208         public void testDefaultConfig() {
209
210                 try {
211
212                         NameMapper nameMapper = new NameMapper();
213
214                         SAMLNameIdentifier nameId = nameMapper.getNameIdentifierName(null, new AuthNPrincipal("testprincipal"),
215                                         new BasicServiceProvider(), new BasicIdentityProvider("urn-x:testid"));
216
217                         AuthNPrincipal principal = nameMapper.getPrincipal(nameId, new BasicServiceProvider(),
218                                         new BasicIdentityProvider("urn-x:testid"));
219
220                         assertEquals("Round-trip handle validation failed.", principal.getName(), "testprincipal");
221
222                 } catch (NameIdentifierMappingException e) {
223                         fail("Error exercising NameMaper: " + e.getMessage());
224                 } catch (Exception e) {
225                         fail("Error exercising NameMaper: " + e.getMessage());
226                 }
227         }
228
229         public void testDefaultingId() {
230
231                 try {
232
233                         NameMapper nameMapper = new NameMapper();
234
235                         File file = new File("data/handle.jks");
236
237                         String rawConfig = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
238                                         + "<NameMapping xmlns=\"urn:mace:shibboleth:namemapper:1.0\""
239                                         + "             xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
240                                         + "             xsi:schemaLocation=\"urn:mace:shibboleth:namemapper:1.0 namemapper.xsd\" "
241                                         + "                     format=\"urn:mace:shibboleth:1.0:nameIdentifier\""
242                                         + "             type=\"CryptoHandleGenerator\" handleTTL=\"1800\">" 
243                                         + "             <KeyStorePath>" + file.toURL().toString() + "</KeyStorePath>" 
244                                         + "             <KeyStorePassword>shibhs</KeyStorePassword>"
245                                         + "             <KeyStoreKeyAlias>handlekey</KeyStoreKeyAlias>"
246                                         + "             <KeyStoreKeyPassword>shibhs</KeyStoreKeyPassword>" 
247                                         + "     </NameMapping>";
248
249                         parser.parse(new InputSource(new StringReader(rawConfig)));
250                         nameMapper.addNameMapping(parser.getDocument().getDocumentElement());
251
252                         SAMLNameIdentifier nameId = nameMapper.getNameIdentifierName(null, new AuthNPrincipal("testprincipal"),
253                                         new BasicServiceProvider(), new BasicIdentityProvider("urn-x:testid"));
254
255                         AuthNPrincipal principal = nameMapper.getPrincipal(nameId, new BasicServiceProvider(),
256                                         new BasicIdentityProvider("urn-x:testid"));
257
258                         assertEquals("Round-trip handle validation failed.", principal.getName(), "testprincipal");
259
260                         NameIdentifierMapping nameMapping = nameMapper.getNameIdentifierMappingById(null);
261                         if (!(nameMapping instanceof CryptoShibHandle)) {
262                                 fail("HSNameMapper defaulted to incorrect name mapping.");
263                         }
264
265                 } catch (NameIdentifierMappingException e) {
266                         fail("Error exercising NameMaper: " + e.getMessage());
267                 } catch (Exception e) {
268                         fail("Error exercising NameMaper: " + e.getMessage());
269                 }
270         }
271
272         public void testDefaultingAmbiguousId() {
273
274                 try {
275
276                         NameMapper nameMapper = new NameMapper();
277
278                         File file = new File("data/handle.jks");
279
280                         String rawConfig = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
281                                         + "<NameMapping xmlns=\"urn:mace:shibboleth:namemapper:1.0\""
282                                         + "             xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
283                                         + "             xsi:schemaLocation=\"urn:mace:shibboleth:namemapper:1.0 namemapper.xsd\" "
284                                         + "                     format=\"urn:mace:shibboleth:1.0:nameIdentifier\""
285                                         + "             type=\"CryptoHandleGenerator\" handleTTL=\"1800\">" 
286                                         + "             <KeyStorePath>" + file.toURL().toString() + "</KeyStorePath>" 
287                                         + "             <KeyStorePassword>shibhs</KeyStorePassword>"
288                                         + "             <KeyStoreKeyAlias>handlekey</KeyStoreKeyAlias>"
289                                         + "             <KeyStoreKeyPassword>shibhs</KeyStoreKeyPassword>" 
290                                         + "     </NameMapping>";
291
292                         parser.parse(new InputSource(new StringReader(rawConfig)));
293                         nameMapper.addNameMapping(parser.getDocument().getDocumentElement());
294
295                         String rawConfig2 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
296                                         + "<NameMapping xmlns=\"urn:mace:shibboleth:namemapper:1.0\""
297                                         + "             xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
298                                         + "             xsi:schemaLocation=\"urn:mace:shibboleth:namemapper:1.0 namemapper.xsd\" "
299                                         + "                     format=\"urn-x:testNameIdentifier\"" 
300                                         + "             type=\"CryptoHandleGenerator\" handleTTL=\"1800\">"
301                                         + "             <KeyStorePath>" + file.toURL().toString() + "</KeyStorePath>"
302                                         + "             <KeyStorePassword>shibhs</KeyStorePassword>"
303                                         + "             <KeyStoreKeyAlias>handlekey</KeyStoreKeyAlias>"
304                                         + "             <KeyStoreKeyPassword>shibhs</KeyStoreKeyPassword>" 
305                                         + "     </NameMapping>";
306
307                         parser.parse(new InputSource(new StringReader(rawConfig2)));
308
309                         nameMapper.addNameMapping(parser.getDocument().getDocumentElement());
310
311                         nameMapper.getNameIdentifierName(null, new AuthNPrincipal("testprincipal"), new BasicServiceProvider(),
312                                         new BasicIdentityProvider("urn-x:testid"));
313
314                         fail("HSNameMapper defaulted to incorrect name mapping.");
315
316                         //This is only a failure if we don't get this exception
317                 } catch (NameIdentifierMappingException e) {
318
319                 } catch (Exception e) {
320
321                         fail("Error exercising NameMaper: " + e.getMessage());
322                 }
323         }
324
325         public void testMemoryMapping() {
326
327                 try {
328
329                         NameMapper nameMapper = new NameMapper();
330
331                         String rawConfig = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
332                                         + "<NameMapping xmlns=\"urn:mace:shibboleth:namemapper:1.0\""
333                                         + "             xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
334                                         + "             xsi:schemaLocation=\"urn:mace:shibboleth:namemapper:1.0 namemapper.xsd\" "
335                                         + "                     id=\"memorytest\" " 
336                                         + "             format=\"urn:mace:shibboleth:1.0:nameIdentifier\""
337                                         + "             type=\"SharedMemoryShibHandle\" handleTTL=\"1800\"/>";
338
339                         parser.parse(new InputSource(new StringReader(rawConfig)));
340                         nameMapper.addNameMapping(parser.getDocument().getDocumentElement());
341
342                         SAMLNameIdentifier nameId = nameMapper.getNameIdentifierName("memorytest", new AuthNPrincipal(
343                                         "testprincipal"), new BasicServiceProvider(), new BasicIdentityProvider("urn-x:testid"));
344
345                         AuthNPrincipal principal = nameMapper.getPrincipal(nameId, new BasicServiceProvider(),
346                                         new BasicIdentityProvider("urn-x:testid"));
347
348                         assertEquals("Round-trip handle validation failed.", principal.getName(), "testprincipal");
349
350                 } catch (MalformedURLException e) {
351                         fail("Error in test specification: " + e.getMessage());
352                 } catch (NameIdentifierMappingException e) {
353                         fail("Error exercising NameMaper: " + e.getMessage());
354                 } catch (Exception e) {
355                         fail("Error exercising NameMaper: " + e.getMessage());
356                 }
357         }
358         
359         public void testMemoryMappingBadQualifier() {
360
361                 try {
362
363                         NameMapper nameMapper = new NameMapper();
364
365                         String rawConfig = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
366                                         + "<NameMapping xmlns=\"urn:mace:shibboleth:namemapper:1.0\""
367                                         + "             xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
368                                         + "             xsi:schemaLocation=\"urn:mace:shibboleth:namemapper:1.0 namemapper.xsd\" "
369                                         + "                     id=\"memorytest\" " 
370                                         + "             format=\"urn:mace:shibboleth:1.0:nameIdentifier\""
371                                         + "             type=\"SharedMemoryShibHandle\" handleTTL=\"1800\"/>";
372
373                         parser.parse(new InputSource(new StringReader(rawConfig)));
374                         nameMapper.addNameMapping(parser.getDocument().getDocumentElement());
375
376                         SAMLNameIdentifier nameId = nameMapper.getNameIdentifierName("memory", new AuthNPrincipal(
377                                         "testprincipal"), new BasicServiceProvider(), new BasicIdentityProvider("urn-x:good"));
378
379                         AuthNPrincipal principal = nameMapper.getPrincipal(nameId, new BasicServiceProvider(),
380                                         new BasicIdentityProvider("urn-x:bad"));
381                 
382                         fail("Expected failure for bad name qualifier.");
383                         
384                 } catch (NameIdentifierMappingException e) {
385                         //This exception should be generated by this test
386                         
387                 } catch (MalformedURLException e) {
388                         fail("Error in test specification: " + e.getMessage());
389                 
390                 } catch (Exception e) {
391                         fail("Error exercising NameMaper: " + e.getMessage());
392                 }
393         }
394
395         public void testPrincipalMapping() {
396
397                 try {
398
399                         NameMapper nameMapper = new NameMapper();
400
401                         String format = "urn-x:test:NameIdFormat1";
402                         String rawConfig = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
403                                         + "<NameMapping xmlns=\"urn:mace:shibboleth:namemapper:1.0\""
404                                         + "             xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
405                                         + "             xsi:schemaLocation=\"urn:mace:shibboleth:namemapper:1.0 namemapper.xsd\" " 
406                                         + "                     format=\"" + format + "\"" + "          type=\"Principal\"/>";
407
408                         parser.parse(new InputSource(new StringReader(rawConfig)));
409                         nameMapper.addNameMapping(parser.getDocument().getDocumentElement());
410
411                         SAMLNameIdentifier nameId = new SAMLNameIdentifier("testprincipal", "urn-x:testid", format);
412                         AuthNPrincipal principal = nameMapper.getPrincipal(nameId, new BasicServiceProvider(),
413                                         new BasicIdentityProvider("urn-x:testid"));
414
415                         assertEquals("Round-trip handle validation failed.", principal.getName(), "testprincipal");
416
417                 } catch (MalformedURLException e) {
418                         fail("Error in test specification: " + e.getMessage());
419                 } catch (NameIdentifierMappingException e) {
420                         fail("Error exercising NameMaper: " + e.getMessage());
421                 } catch (Exception e) {
422                         fail("Error exercising NameMaper: " + e.getMessage());
423                 }
424
425         }
426         
427         public void testPrincipalMappingBadQualifier() {
428
429                 try {
430
431                         NameMapper nameMapper = new NameMapper();
432
433                         String format = "urn-x:test:NameIdFormat1";
434                         String rawConfig = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
435                                         + "<NameMapping xmlns=\"urn:mace:shibboleth:namemapper:1.0\""
436                                         + "             xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
437                                         + "             xsi:schemaLocation=\"urn:mace:shibboleth:namemapper:1.0 namemapper.xsd\" " 
438                                         + "                     format=\"" + format + "\"" + "          type=\"Principal\"/>";
439                         parser.parse(new InputSource(new StringReader(rawConfig)));
440                         nameMapper.addNameMapping(parser.getDocument().getDocumentElement());
441
442                         SAMLNameIdentifier nameId = new SAMLNameIdentifier("testprincipal", "urn-x:good", format);
443
444                         AuthNPrincipal principal = nameMapper.getPrincipal(nameId, new BasicServiceProvider(),
445                                         new BasicIdentityProvider("urn-x:bad"));
446                 
447                         fail("Expected failure for bad name qualifier.");
448                         
449                 } catch (NameIdentifierMappingException e) {
450                         //This exception should be generated by this test
451                         
452                 } catch (MalformedURLException e) {
453                         fail("Error in test specification: " + e.getMessage());
454                 
455                 } catch (Exception e) {
456                         fail("Error exercising NameMaper: " + e.getMessage());
457                 }
458
459         }
460 }
461
462 class BasicIdentityProvider implements IdentityProvider {
463
464         String id;
465
466         public BasicIdentityProvider(String id) {
467
468                 this.id = id;
469         }
470
471         public String getProviderId() {
472
473                 return id;
474         }
475
476         public Credential getResponseSigningCredential() {
477
478                 return null;
479         }
480
481         public Credential getAssertionSigningCredential() {
482
483                 return null;
484         }
485
486 }
487
488 class BasicServiceProvider implements ServiceProvider {
489
490         public String getProviderId() {
491
492                 return null;
493         }
494
495 }