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