author | prr |
Fri, 25 May 2018 12:12:24 -0700 | |
changeset 50347 | b2f046ae8eb6 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
42691 | 1 |
/* |
2 |
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
*/ |
|
23 |
||
24 |
/* |
|
25 |
* @test |
|
26 |
* @bug 8165751 |
|
27 |
* @summary Verify that that a subclass of Signature that does not contain a |
|
42780
7781326fff20
8170876: NPE in JCE engine classes with java.security.debug=provider
mullan
parents:
42691
diff
changeset
|
28 |
* provider can be used to verify. |
42691 | 29 |
* @run main/othervm -Djava.security.debug=provider NoProvider |
30 |
*/ |
|
31 |
||
32 |
import java.security.*; |
|
33 |
||
34 |
public class NoProvider { |
|
35 |
||
36 |
private static class NoProviderPublicKey implements PublicKey { |
|
37 |
||
38 |
public String getAlgorithm() { |
|
39 |
return "NoProvider"; |
|
40 |
} |
|
41 |
public String getFormat() { |
|
42 |
return "none"; |
|
43 |
} |
|
44 |
public byte[] getEncoded() { |
|
45 |
return new byte[1]; |
|
46 |
} |
|
47 |
} |
|
48 |
||
49 |
private static class NoProviderSignature extends Signature { |
|
50 |
||
51 |
public NoProviderSignature() { |
|
52 |
super("NoProvider"); |
|
53 |
} |
|
54 |
||
55 |
protected void engineInitVerify(PublicKey publicKey) |
|
56 |
throws InvalidKeyException { |
|
57 |
// do nothing |
|
58 |
} |
|
59 |
||
60 |
protected void engineInitSign(PrivateKey privateKey) |
|
61 |
throws InvalidKeyException { |
|
62 |
// do nothing |
|
63 |
} |
|
64 |
||
65 |
protected void engineUpdate(byte b) throws SignatureException { |
|
66 |
// do nothing |
|
67 |
} |
|
68 |
||
69 |
protected void engineUpdate(byte[] b, int off, int len) |
|
70 |
throws SignatureException { |
|
71 |
// do nothing |
|
72 |
} |
|
73 |
||
74 |
protected byte[] engineSign() throws SignatureException { |
|
75 |
return new byte[1]; |
|
76 |
} |
|
77 |
||
78 |
protected boolean engineVerify(byte[] sigBytes) |
|
79 |
throws SignatureException { |
|
80 |
return false; |
|
81 |
} |
|
82 |
||
83 |
@Deprecated |
|
84 |
protected void engineSetParameter(String param, Object value) |
|
85 |
throws InvalidParameterException { |
|
86 |
// do nothing |
|
87 |
} |
|
88 |
||
89 |
@Deprecated |
|
90 |
protected Object engineGetParameter(String param) |
|
91 |
throws InvalidParameterException { |
|
92 |
return null; |
|
93 |
} |
|
94 |
} |
|
95 |
||
96 |
public static void main(String[] args) throws Exception { |
|
97 |
new NoProviderSignature().initVerify(new NoProviderPublicKey()); |
|
98 |
} |
|
99 |
} |