jdk/test/java/security/Provider/GetInstance.java
author ohair
Tue, 25 May 2010 15:58:33 -0700
changeset 5506 202f599c92aa
parent 2 90ce3da70b43
child 10057 03ae05289550
permissions -rw-r--r--
6943119: Rebrand source copyright notices Reviewed-by: darcy, weijun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 * @test
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 * @bug 4856968
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 * @summary make sure getInstance() works correctly, including failover
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 *   and delayed provider selection for Signatures
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * @author Andreas Sterbenz
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.security.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.security.cert.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
public class GetInstance {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
    private static void same(Provider p1, Provider p2) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
        if (p1 != p2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
            throw new Exception("Wrong provider");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    public static void main(String[] args) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
        long start = System.currentTimeMillis();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
        Provider foo = new FooProvider();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
        Provider bar = new BarProvider();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
        Provider baz = new BazProvider();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
        Security.addProvider(foo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
        Security.addProvider(bar);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
        Security.addProvider(baz);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
        System.out.println("Testing MessageDigest.getInstance()...");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        MessageDigest m;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        m = MessageDigest.getInstance("foo");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        m = MessageDigest.getInstance("foo", "foo");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        m = MessageDigest.getInstance("foo", foo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        System.out.println("Testing Signature.getInstance() for SPI...");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        Signature sig;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        PrivateKey privateKey = new FooPrivateKey();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        sig = Signature.getInstance("foo");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        same(foo, sig.getProvider());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        sig = Signature.getInstance("foo");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        sig.initSign(privateKey);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        same(foo, sig.getProvider());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        sig = Signature.getInstance("foo", "foo");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        sig.initSign(privateKey);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        same(foo, sig.getProvider());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        sig = Signature.getInstance("foo", foo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        sig.initSign(privateKey);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        same(foo, sig.getProvider());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        System.out.println("Testing Signature.getInstance() for Signature...");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        sig = Signature.getInstance("fuu");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        same(foo, sig.getProvider());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        sig = Signature.getInstance("fuu");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        sig.initSign(privateKey);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        same(foo, sig.getProvider());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        sig = Signature.getInstance("fuu", "foo");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        sig.initSign(privateKey);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        same(foo, sig.getProvider());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        sig = Signature.getInstance("fuu", foo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        sig.initSign(privateKey);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        same(foo, sig.getProvider());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        System.out.println("Testing CertStore.getInstance()...");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        CertStoreParameters params = new CollectionCertStoreParameters(Collections.EMPTY_LIST);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        CertStore cs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        cs = CertStore.getInstance("foo", params);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        cs = CertStore.getInstance("foo", params, "foo");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        cs = CertStore.getInstance("foo", params, foo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        System.out.println("Testing failover...");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        m = MessageDigest.getInstance("bar");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        same(m.getProvider(), baz);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        sig = Signature.getInstance("bar");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        same(sig.getProvider(), baz);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        cs = CertStore.getInstance("bar", params);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        same(cs.getProvider(), baz);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        System.out.println("Testing Signature delayed provider selection...");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        sig = Signature.getInstance("baz");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        sig.initVerify(new FooPublicKey());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        same(sig.getProvider(), baz);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        Provider.Service s = foo.getService("CertStore", "foo");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        s.newInstance(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        s.newInstance(params);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
            s.newInstance(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
            throw new Exception("call should not succeed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        } catch (NoSuchAlgorithmException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
            e.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
            Throwable cause = e.getCause();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
            if (cause instanceof InvalidParameterException == false) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                throw new Exception("incorrect exception");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        long stop = System.currentTimeMillis();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        System.out.println("Done (" + (stop - start) + " ms).");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    public static class FooProvider extends Provider {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        FooProvider() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
            super("foo", 1.0d, "none");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
            put("MessageDigest.foo", "GetInstance$FooDigest");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
            put("CertStore.foo",     "GetInstance$FooStore");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
            put("Signature.foo",     "GetInstance$FooSignatureSpi");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            put("Signature.fuu",     "GetInstance$BazSignature");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
            // throws InvalidKeyException, skipped in delayed provider selection
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
            put("Signature.baz",     "GetInstance$BazSignatureSpi");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    public static class BarProvider extends Provider {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        BarProvider() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
            super("bar", 1.0d, "none");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
            // all entries invalid for failover
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
            put("MessageDigest.bar", "GetInstance$FooKey");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
            put("Signature.bar",     "GetInstance$FooKey");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
            put("Certstore.bar",     "GetInstance$FooKey");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
            // not an SPI, skipped in delayed provider selection
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
            put("Signature.baz",     "GetInstance$BazSignature");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    public static class BazProvider extends Provider {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        BazProvider() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
            super("baz", 1.0d, "none");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
            put("MessageDigest.bar", "GetInstance$FooDigest");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
            put("CertStore.bar",     "GetInstance$FooStore");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
            put("Signature.bar",     "GetInstance$FooSignatureSpi");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
            put("Signature.baz",     "GetInstance$FooSignatureSpi");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    public static class FooDigest extends MessageDigestSpi {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        public byte[] engineDigest() { return new byte[0]; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        public void engineReset() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        public void engineUpdate(byte input) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        public void engineUpdate(byte[] b, int ofs, int len) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    public static class FooStore extends CertStoreSpi {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        public FooStore(CertStoreParameters params) throws InvalidAlgorithmParameterException { super(params); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        public Collection engineGetCertificates(CertSelector sel) { return Collections.EMPTY_LIST; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        public Collection engineGetCRLs(CRLSelector sel) { return Collections.EMPTY_LIST; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    public static class BaseSignatureSpi extends SignatureSpi {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        protected void engineInitVerify(PublicKey publicKey) throws InvalidKeyException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        protected void engineInitSign(PrivateKey privateKey) throws InvalidKeyException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        protected void engineUpdate(byte b) throws SignatureException { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        protected void engineUpdate(byte[] b, int off, int len) throws SignatureException { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        protected byte[] engineSign() throws SignatureException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
            return new byte[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        protected boolean engineVerify(byte[] sigBytes) throws SignatureException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        protected void engineSetParameter(String param, Object value) throws InvalidParameterException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        protected Object engineGetParameter(String param) throws InvalidParameterException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    public static class BaseSignature extends Signature {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        BaseSignature(String s) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            super(s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        protected void engineInitVerify(PublicKey publicKey) throws InvalidKeyException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        protected void engineInitSign(PrivateKey privateKey) throws InvalidKeyException { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        protected void engineUpdate(byte b) throws SignatureException { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        protected void engineUpdate(byte[] b, int off, int len) throws SignatureException { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        protected byte[] engineSign() throws SignatureException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
            return new byte[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        protected boolean engineVerify(byte[] sigBytes) throws SignatureException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        protected void engineSetParameter(String param, Object value) throws InvalidParameterException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        protected Object engineGetParameter(String param) throws InvalidParameterException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    public static abstract class FooKey implements Key {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        public String getFormat() { return null; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        public byte[] getEncoded() { return null; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        public String getAlgorithm() { return "foo"; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    public static class FooPrivateKey extends FooKey implements PrivateKey { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    public static class FooPublicKey extends FooKey implements PublicKey { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    public static class FooSignatureSpi extends BaseSignatureSpi {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        public FooSignatureSpi() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
            super();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
            System.out.println("FooSignatureSpi constructor");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    public static class BazSignatureSpi extends BaseSignatureSpi {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        public BazSignatureSpi() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
            super();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
            System.out.println("BazSignatureSpi constructor");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        protected void engineInitVerify(PublicKey publicKey) throws InvalidKeyException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
            throw new InvalidKeyException("verify not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    public static class BazSignature extends BaseSignature {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        public BazSignature() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
            super("baz");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
            System.out.println("BazSignature constructor");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
}