1 // $Id: getInstance14.java,v 1.2 2003/04/07 15:42:11 crawley Exp $ |
|
2 // |
|
3 // Copyright (C) 2003, Free Software Foundation, Inc. |
|
4 // |
|
5 // This file is part of Mauve. |
|
6 // |
|
7 // Mauve is free software; you can redistribute it and/or modify |
|
8 // it under the terms of the GNU General Public License as published by |
|
9 // the Free Software Foundation; either version 2, or (at your option) |
|
10 // any later version. |
|
11 // |
|
12 // Mauve is distributed in the hope that it will be useful, |
|
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 // GNU General Public License for more details. |
|
16 // |
|
17 // You should have received a copy of the GNU General Public License |
|
18 // along with Mauve; see the file COPYING. If not, write to |
|
19 // the Free Software Foundation, 59 Temple Place - Suite 330, |
|
20 // Boston, MA 02111-1307, USA. |
|
21 // |
|
22 // Tags: JDK1.4 |
|
23 // Uses: MauveAlgorithm |
|
24 |
|
25 package gnu.testlet.java.security.KeyFactory; |
|
26 import gnu.testlet.Testlet; |
|
27 import gnu.testlet.TestHarness; |
|
28 import java.security.KeyFactory; |
|
29 import java.security.NoSuchAlgorithmException; |
|
30 import java.security.Provider; |
|
31 import java.security.Security; |
|
32 |
|
33 public class getInstance14 extends Provider implements Testlet |
|
34 { |
|
35 public getInstance14() |
|
36 { |
|
37 super("KeyFactory", 1.0, ""); |
|
38 |
|
39 put("KeyFactory.foo", |
|
40 "gnu.testlet.java.security.KeyFactory.MauveAlgorithm"); |
|
41 put("Alg.Alias.KeyFactory.bar", "foo"); |
|
42 } |
|
43 |
|
44 public void test (TestHarness harness) |
|
45 { |
|
46 harness.checkPoint ("KeyFactory"); |
|
47 |
|
48 KeyFactory spi; |
|
49 Provider provider = this; |
|
50 Security.addProvider(provider); |
|
51 String signature; |
|
52 |
|
53 spi = null; |
|
54 signature = "getInstance(\"foo\", provider)"; |
|
55 try |
|
56 { |
|
57 spi = KeyFactory.getInstance("foo", provider); |
|
58 harness.check(spi != null, signature); |
|
59 } |
|
60 catch (NoSuchAlgorithmException x) |
|
61 { |
|
62 harness.fail(signature); |
|
63 harness.debug(x); |
|
64 } |
|
65 |
|
66 spi = null; |
|
67 signature = "getInstance(\"FOO\", provider)"; |
|
68 try |
|
69 { |
|
70 spi = KeyFactory.getInstance("FOO", provider); |
|
71 harness.check(spi != null, signature); |
|
72 } |
|
73 catch (NoSuchAlgorithmException x) |
|
74 { |
|
75 harness.fail(signature); |
|
76 harness.debug(x); |
|
77 } |
|
78 |
|
79 spi = null; |
|
80 signature = "getInstance(\"bar\", provider)"; |
|
81 try |
|
82 { |
|
83 spi = KeyFactory.getInstance("bar", provider); |
|
84 harness.check(spi != null, signature); |
|
85 } |
|
86 catch (NoSuchAlgorithmException x) |
|
87 { |
|
88 harness.fail(signature); |
|
89 harness.debug(x); |
|
90 } |
|
91 |
|
92 spi = null; |
|
93 signature = "getInstance(\"BAR\", provider)"; |
|
94 try |
|
95 { |
|
96 spi = KeyFactory.getInstance("BAR", provider); |
|
97 harness.check(spi != null, signature); |
|
98 } |
|
99 catch (NoSuchAlgorithmException x) |
|
100 { |
|
101 harness.fail(signature); |
|
102 harness.debug(x); |
|
103 } |
|
104 } |
|
105 } |
|