jdk/test/java/security/Provider/GetInstance.java
author katleman
Thu, 05 Jan 2012 08:42:37 -0800
changeset 11376 075fe3928b7f
parent 10057 03ae05289550
child 40416 5d91b2fd668c
permissions -rw-r--r--
Added tag jdk8-b20 for changeset 90e14ec89395
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
10057
03ae05289550 7054918: jdk_security1 test target cleanup
weijun
parents: 5506
diff changeset
     2
 * Copyright (c) 2003, 2011, 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
10057
03ae05289550 7054918: jdk_security1 test target cleanup
weijun
parents: 5506
diff changeset
    26
 * @bug 4856968 7054918
03ae05289550 7054918: jdk_security1 test target cleanup
weijun
parents: 5506
diff changeset
    27
 * @library ../testlibrary
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 * @summary make sure getInstance() works correctly, including failover
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 *   and delayed provider selection for Signatures
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * @author Andreas Sterbenz
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.security.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.security.cert.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
public class GetInstance {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    private static void same(Provider p1, Provider p2) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
        if (p1 != p2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
            throw new Exception("Wrong provider");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    public static void main(String[] args) throws Exception {
10057
03ae05289550 7054918: jdk_security1 test target cleanup
weijun
parents: 5506
diff changeset
    47
        ProvidersSnapshot snapshot = ProvidersSnapshot.create();
03ae05289550 7054918: jdk_security1 test target cleanup
weijun
parents: 5506
diff changeset
    48
        try {
03ae05289550 7054918: jdk_security1 test target cleanup
weijun
parents: 5506
diff changeset
    49
            main0(args);
03ae05289550 7054918: jdk_security1 test target cleanup
weijun
parents: 5506
diff changeset
    50
        } finally {
03ae05289550 7054918: jdk_security1 test target cleanup
weijun
parents: 5506
diff changeset
    51
            snapshot.restore();
03ae05289550 7054918: jdk_security1 test target cleanup
weijun
parents: 5506
diff changeset
    52
        }
03ae05289550 7054918: jdk_security1 test target cleanup
weijun
parents: 5506
diff changeset
    53
    }
03ae05289550 7054918: jdk_security1 test target cleanup
weijun
parents: 5506
diff changeset
    54
03ae05289550 7054918: jdk_security1 test target cleanup
weijun
parents: 5506
diff changeset
    55
    public static void main0(String[] args) throws Exception {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
        long start = System.currentTimeMillis();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        Provider foo = new FooProvider();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        Provider bar = new BarProvider();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
        Provider baz = new BazProvider();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        Security.addProvider(foo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        Security.addProvider(bar);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        Security.addProvider(baz);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        System.out.println("Testing MessageDigest.getInstance()...");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        MessageDigest m;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        m = MessageDigest.getInstance("foo");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        m = MessageDigest.getInstance("foo", "foo");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        m = MessageDigest.getInstance("foo", foo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        System.out.println("Testing Signature.getInstance() for SPI...");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        Signature sig;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        PrivateKey privateKey = new FooPrivateKey();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        sig = Signature.getInstance("foo");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        same(foo, sig.getProvider());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        sig = Signature.getInstance("foo");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        sig.initSign(privateKey);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        same(foo, sig.getProvider());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        sig = Signature.getInstance("foo", "foo");
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("foo", 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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        System.out.println("Testing Signature.getInstance() for Signature...");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        sig = Signature.getInstance("fuu");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        same(foo, sig.getProvider());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        sig = Signature.getInstance("fuu");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        sig.initSign(privateKey);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        same(foo, sig.getProvider());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        sig = Signature.getInstance("fuu", "foo");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        sig.initSign(privateKey);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        same(foo, sig.getProvider());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        sig = Signature.getInstance("fuu", foo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        sig.initSign(privateKey);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        same(foo, sig.getProvider());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        System.out.println("Testing CertStore.getInstance()...");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        CertStoreParameters params = new CollectionCertStoreParameters(Collections.EMPTY_LIST);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        CertStore cs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        cs = CertStore.getInstance("foo", params);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        cs = CertStore.getInstance("foo", params, "foo");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        cs = CertStore.getInstance("foo", params, foo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        System.out.println("Testing failover...");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        m = MessageDigest.getInstance("bar");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        same(m.getProvider(), baz);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        sig = Signature.getInstance("bar");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        same(sig.getProvider(), baz);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        cs = CertStore.getInstance("bar", params);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        same(cs.getProvider(), baz);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        System.out.println("Testing Signature delayed provider selection...");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        sig = Signature.getInstance("baz");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        sig.initVerify(new FooPublicKey());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        same(sig.getProvider(), baz);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        Provider.Service s = foo.getService("CertStore", "foo");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        s.newInstance(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        s.newInstance(params);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
            s.newInstance(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
            throw new Exception("call should not succeed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        } catch (NoSuchAlgorithmException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
            e.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
            Throwable cause = e.getCause();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            if (cause instanceof InvalidParameterException == false) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                throw new Exception("incorrect exception");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        long stop = System.currentTimeMillis();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        System.out.println("Done (" + (stop - start) + " ms).");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    public static class FooProvider extends Provider {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        FooProvider() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
            super("foo", 1.0d, "none");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
            put("MessageDigest.foo", "GetInstance$FooDigest");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            put("CertStore.foo",     "GetInstance$FooStore");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
            put("Signature.foo",     "GetInstance$FooSignatureSpi");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
            put("Signature.fuu",     "GetInstance$BazSignature");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
            // throws InvalidKeyException, skipped in delayed provider selection
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
            put("Signature.baz",     "GetInstance$BazSignatureSpi");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    public static class BarProvider extends Provider {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        BarProvider() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
            super("bar", 1.0d, "none");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
            // all entries invalid for failover
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
            put("MessageDigest.bar", "GetInstance$FooKey");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
            put("Signature.bar",     "GetInstance$FooKey");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
            put("Certstore.bar",     "GetInstance$FooKey");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
            // not an SPI, skipped in delayed provider selection
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
            put("Signature.baz",     "GetInstance$BazSignature");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    public static class BazProvider extends Provider {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        BazProvider() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
            super("baz", 1.0d, "none");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
            put("MessageDigest.bar", "GetInstance$FooDigest");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
            put("CertStore.bar",     "GetInstance$FooStore");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
            put("Signature.bar",     "GetInstance$FooSignatureSpi");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
            put("Signature.baz",     "GetInstance$FooSignatureSpi");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    public static class FooDigest extends MessageDigestSpi {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        public byte[] engineDigest() { return new byte[0]; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        public void engineReset() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        public void engineUpdate(byte input) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        public void engineUpdate(byte[] b, int ofs, int len) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    public static class FooStore extends CertStoreSpi {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        public FooStore(CertStoreParameters params) throws InvalidAlgorithmParameterException { super(params); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        public Collection engineGetCertificates(CertSelector sel) { return Collections.EMPTY_LIST; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        public Collection engineGetCRLs(CRLSelector sel) { return Collections.EMPTY_LIST; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    public static class BaseSignatureSpi extends SignatureSpi {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        protected void engineInitVerify(PublicKey publicKey) throws InvalidKeyException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        protected void engineInitSign(PrivateKey privateKey) throws InvalidKeyException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        protected void engineUpdate(byte b) throws SignatureException { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        protected void engineUpdate(byte[] b, int off, int len) throws SignatureException { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        protected byte[] engineSign() throws SignatureException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            return new byte[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        protected boolean engineVerify(byte[] sigBytes) throws SignatureException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        protected void engineSetParameter(String param, Object value) throws InvalidParameterException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        protected Object engineGetParameter(String param) throws InvalidParameterException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    public static class BaseSignature extends Signature {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        BaseSignature(String s) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
            super(s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        protected void engineInitVerify(PublicKey publicKey) throws InvalidKeyException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        protected void engineInitSign(PrivateKey privateKey) throws InvalidKeyException { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        protected void engineUpdate(byte b) throws SignatureException { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        protected void engineUpdate(byte[] b, int off, int len) throws SignatureException { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        protected byte[] engineSign() throws SignatureException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
            return new byte[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        protected boolean engineVerify(byte[] sigBytes) throws SignatureException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        protected void engineSetParameter(String param, Object value) throws InvalidParameterException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        protected Object engineGetParameter(String param) throws InvalidParameterException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    public static abstract class FooKey implements Key {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        public String getFormat() { return null; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        public byte[] getEncoded() { return null; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        public String getAlgorithm() { return "foo"; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    public static class FooPrivateKey extends FooKey implements PrivateKey { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    public static class FooPublicKey extends FooKey implements PublicKey { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    public static class FooSignatureSpi extends BaseSignatureSpi {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        public FooSignatureSpi() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
            super();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
            System.out.println("FooSignatureSpi constructor");
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 BazSignatureSpi extends BaseSignatureSpi {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        public BazSignatureSpi() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
            super();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
            System.out.println("BazSignatureSpi constructor");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        protected void engineInitVerify(PublicKey publicKey) throws InvalidKeyException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
            throw new InvalidKeyException("verify not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    public static class BazSignature extends BaseSignature {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        public BazSignature() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
            super("baz");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
            System.out.println("BazSignature constructor");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
}