jdk/test/java/security/cert/CertPathValidator/indirectCRL/CircularCRLTwoLevel.java
author xuelei
Mon, 13 Jan 2014 21:12:58 -0800
changeset 22268 d72c97c708ae
parent 5506 202f599c92aa
permissions -rw-r--r--
8030829: Add MD5 to jdk.certpath.disabledAlgorithms security property Reviewed-by: mullan, weijun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2927
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
     1
/*
22268
d72c97c708ae 8030829: Add MD5 to jdk.certpath.disabledAlgorithms security property
xuelei
parents: 5506
diff changeset
     2
 * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
2927
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
     4
 *
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
     7
 * published by the Free Software Foundation.
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
     8
 *
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    13
 * accompanied this code).
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    14
 *
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2927
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2927
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2927
diff changeset
    21
 * questions.
2927
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    22
 */
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    23
22268
d72c97c708ae 8030829: Add MD5 to jdk.certpath.disabledAlgorithms security property
xuelei
parents: 5506
diff changeset
    24
//
d72c97c708ae 8030829: Add MD5 to jdk.certpath.disabledAlgorithms security property
xuelei
parents: 5506
diff changeset
    25
// Security properties, once set, cannot revert to unset.  To avoid
d72c97c708ae 8030829: Add MD5 to jdk.certpath.disabledAlgorithms security property
xuelei
parents: 5506
diff changeset
    26
// conflicts with tests running in the same VM isolate this test by
d72c97c708ae 8030829: Add MD5 to jdk.certpath.disabledAlgorithms security property
xuelei
parents: 5506
diff changeset
    27
// running it in otherVM mode.
d72c97c708ae 8030829: Add MD5 to jdk.certpath.disabledAlgorithms security property
xuelei
parents: 5506
diff changeset
    28
//
d72c97c708ae 8030829: Add MD5 to jdk.certpath.disabledAlgorithms security property
xuelei
parents: 5506
diff changeset
    29
2927
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    30
/**
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    31
 * @test
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    32
 *
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    33
 * @bug 6720721
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    34
 * @summary CRL check with circular depency support needed
22268
d72c97c708ae 8030829: Add MD5 to jdk.certpath.disabledAlgorithms security property
xuelei
parents: 5506
diff changeset
    35
 * @run main/othervm CircularCRLTwoLevel
2927
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    36
 * @author Xuelei Fan
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    37
 */
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    38
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    39
import java.io.*;
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    40
import java.net.SocketException;
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    41
import java.util.*;
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    42
import java.security.Security;
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    43
import java.security.cert.*;
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    44
import java.security.cert.CertPathValidatorException.BasicReason;
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    45
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    46
public class CircularCRLTwoLevel {
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    47
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    48
    static String selfSignedCertStr =
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    49
        "-----BEGIN CERTIFICATE-----\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    50
        "MIICPjCCAaegAwIBAgIBADANBgkqhkiG9w0BAQQFADAfMQswCQYDVQQGEwJVUzEQ\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    51
        "MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA0MjcwMjI0MzJaFw0zMDA0MDcwMjI0MzJa\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    52
        "MB8xCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMIGfMA0GCSqGSIb3DQEB\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    53
        "AQUAA4GNADCBiQKBgQC4OTag24sTxL2tXTNuvpmUEtdxrYAZoFsslFQ60T+WD9wQ\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    54
        "Jeiw87FSPsR2vxRuv0j8DNm2a4h7LNNIFcLurfNldbz5pvgZ7VqdbbUMPE9qP85n\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    55
        "jgDl4woyRTSUeRI4A7O0CO6NpES21dtbdhroWQrEkHxpnrDPxsxrz5gf2m3gqwID\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    56
        "AQABo4GJMIGGMB0GA1UdDgQWBBSCJd0hpl5PdAD9IZS+Hzng4lXLGzBHBgNVHSME\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    57
        "QDA+gBSCJd0hpl5PdAD9IZS+Hzng4lXLG6EjpCEwHzELMAkGA1UEBhMCVVMxEDAO\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    58
        "BgNVBAoTB0V4YW1wbGWCAQAwDwYDVR0TAQH/BAUwAwEB/zALBgNVHQ8EBAMCAgQw\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    59
        "DQYJKoZIhvcNAQEEBQADgYEAluy6HIjWcq009lTLmhp+Np6dxU78pInBK8RZkza0\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    60
        "484qGaxFGD3UGyZkI5uWmsH2XuMbuox5khfIq6781gmkPBHXBIEtJN8eLusOHEye\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    61
        "iE8h7WI+N3qa6Pj56WionMrioqC/3X+b06o147bbhx8U0vkYv/HyPaITOFfMXTdz\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    62
        "Vjw=\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    63
        "-----END CERTIFICATE-----";
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    64
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    65
    static String subCaCertStr =
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    66
        "-----BEGIN CERTIFICATE-----\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    67
        "MIICUDCCAbmgAwIBAgIBAzANBgkqhkiG9w0BAQQFADAfMQswCQYDVQQGEwJVUzEQ\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    68
        "MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA0MjcwMjI0MzRaFw0yOTAxMTIwMjI0MzRa\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    69
        "MDExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMRAwDgYDVQQLEwdDbGFz\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    70
        "cy0xMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCiAJnAQW2ad3ZMKUhSJVZj\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    71
        "8pBqxTcHSTwAVguQkDglsN/OIwUpvR5Jgp3lpRWUEt6idEp0FZzORpvtjt3pr5MG\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    72
        "Eg2CDptekC5BSPS+fIAIKlncB3HwOiFFhH6b3wTydDCdEd2fvsi4QMOSVrIYMeA8\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    73
        "P/mCz6kRhfUQPE0CMmOUewIDAQABo4GJMIGGMB0GA1UdDgQWBBT0/nNP8WpyxmYr\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    74
        "IBp4tN8y08jw2jBHBgNVHSMEQDA+gBSCJd0hpl5PdAD9IZS+Hzng4lXLG6EjpCEw\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    75
        "HzELMAkGA1UEBhMCVVMxEDAOBgNVBAoTB0V4YW1wbGWCAQAwDwYDVR0TAQH/BAUw\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    76
        "AwEB/zALBgNVHQ8EBAMCAgQwDQYJKoZIhvcNAQEEBQADgYEAS9PzI6B39R/U9fRj\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    77
        "UExzN1FXNP5awnAPtiv34kSCL6n6MryqkfG+8aaAOdZsSjmTylNFaF7cW/Xp1VBF\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    78
        "hq0bg/SbEAbK7+UwL8GSC3crhULHLbh+1iFdVTEwxCw5YmB8ji3BaZ/WKW/PkjCZ\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    79
        "7cXP6VDeZMG6oRQ4hbOcixoFPXo=\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    80
        "-----END CERTIFICATE-----";
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    81
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    82
    static String targetCertStr =
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    83
        "-----BEGIN CERTIFICATE-----\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    84
        "MIICNzCCAaCgAwIBAgIBAjANBgkqhkiG9w0BAQQFADAxMQswCQYDVQQGEwJVUzEQ\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    85
        "MA4GA1UEChMHRXhhbXBsZTEQMA4GA1UECxMHQ2xhc3MtMTAeFw0wOTA0MjcwMjI0\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    86
        "MzZaFw0yOTAxMTIwMjI0MzZaMEExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFt\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    87
        "cGxlMRAwDgYDVQQLEwdDbGFzcy0xMQ4wDAYDVQQDEwVBbGljZTCBnzANBgkqhkiG\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    88
        "9w0BAQEFAAOBjQAwgYkCgYEAvYSaU3oiE4Pxp/aUIXwMqOwSiWkZ+O3aTu13hRtK\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    89
        "ZyR+Wtj63IuvaigAC4uC+zBypF93ThjwCzVR2qKDQaQzV8CLleO96gStt7Y+i3G2\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    90
        "V3IUGgrVCqeK7N6nNYu0wW84sibcPqG/TIy0UoaQMqgB21xtRF+1DUVlFh4Z89X/\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    91
        "pskCAwEAAaNPME0wCwYDVR0PBAQDAgPoMB0GA1UdDgQWBBSynMEdcal/e9TmvlNE\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    92
        "4suXGA4+hjAfBgNVHSMEGDAWgBT0/nNP8WpyxmYrIBp4tN8y08jw2jANBgkqhkiG\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    93
        "9w0BAQQFAAOBgQB/jru7E/+piSmUwByw5qbZsoQZVcgR97pd2TErNJpJMAX2oIHR\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    94
        "wJH6w4NuYs27+fEAX7wK4whc6EUH/w1SI6o28F2rG6HqYQPPZ2E2WqwbBQL9nYE3\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    95
        "Vfzu/G9axTUQXFbf90h80UErA+mZVxqc2xtymLuH0YEaMZImtRZ2MXHfXg==\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    96
        "-----END CERTIFICATE-----";
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    97
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    98
    static String topCrlIssuerCertStr =
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
    99
        "-----BEGIN CERTIFICATE-----\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   100
        "MIICKzCCAZSgAwIBAgIBAjANBgkqhkiG9w0BAQQFADAfMQswCQYDVQQGEwJVUzEQ\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   101
        "MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA0MjcwMjI0MzNaFw0yOTAxMTIwMjI0MzNa\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   102
        "MB8xCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMIGfMA0GCSqGSIb3DQEB\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   103
        "AQUAA4GNADCBiQKBgQDMJeBMBybHykI/YpwUJ4O9euqDSLb1kpWpceBS8TVqvgBC\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   104
        "SgUJWtFZL0i6bdvF6mMdlbuBkGzhXqHiVAi96/zRLbUC9F8SMEJ6MuD+YhQ0ZFTQ\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   105
        "atKy8zf8O9XzztelLJ26Gqb7QPV133WY3haAqHtCXOhEKkCN16NOYNC37DTaJwID\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   106
        "AQABo3cwdTAdBgNVHQ4EFgQULXSWzXzUOIpOJpzbSCpW42IJUugwRwYDVR0jBEAw\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   107
        "PoAUgiXdIaZeT3QA/SGUvh854OJVyxuhI6QhMB8xCzAJBgNVBAYTAlVTMRAwDgYD\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   108
        "VQQKEwdFeGFtcGxlggEAMAsGA1UdDwQEAwIBAjANBgkqhkiG9w0BAQQFAAOBgQAY\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   109
        "eMnf5AHSNlyUlzXk8o2S0h4gCuvKX6C3kFfKuZcWvFAbx4yQOWLS2s15/nzR4+AP\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   110
        "FGX3lgJjROyAh7fGedTQK+NFWwkM2ag1g3hXktnlnT1qHohi0w31nVBJxXEDO/Ck\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   111
        "uJTpJGt8XxxbFaw5v7cHy7XuTAeU/sekvjEiNHW00Q==\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   112
        "-----END CERTIFICATE-----";
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   113
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   114
    static String subCrlIssuerCertStr =
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   115
        "-----BEGIN CERTIFICATE-----\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   116
        "MIICPTCCAaagAwIBAgIBBDANBgkqhkiG9w0BAQQFADAfMQswCQYDVQQGEwJVUzEQ\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   117
        "MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA0MjcwMjI0MzRaFw0yOTAxMTIwMjI0MzRa\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   118
        "MDExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMRAwDgYDVQQLEwdDbGFz\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   119
        "cy0xMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDWUtDQx2MB/7arDiquMJyd\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   120
        "LWwSg6p8sg5z6wKrC1v47MT4DBhFX+0RUgTMUdQgYpgxGpczn+6y4zfV76064S0N\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   121
        "4L/IQ+SunTW1w4yRGjB+xkyyJmWAqijG1nr+Dgkv5nxPI+9Er5lHcoVWVMEcvvRm\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   122
        "6jIBQdldVlSgv+VgUnFm5wIDAQABo3cwdTAdBgNVHQ4EFgQUkV3Qqtk7gIot9n60\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   123
        "jX6dloxrfMEwRwYDVR0jBEAwPoAUgiXdIaZeT3QA/SGUvh854OJVyxuhI6QhMB8x\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   124
        "CzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlggEAMAsGA1UdDwQEAwIBAjAN\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   125
        "BgkqhkiG9w0BAQQFAAOBgQADu4GM8EdmIKhC7FRvk5jF90zfvZ38wbXBzCjKI4jX\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   126
        "QJrhne1bfyeNNm5c1w+VKidT+XzBzBGH7ZqYzoZmzRIfcbLKX2brEBKiukeeAyL3\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   127
        "bctQtbp19tX+uu2dQberD188AAysKTkHcJUV+rRsTwVJ9vcYKxoRxKk8DhH7ZS3M\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   128
        "rg==\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   129
        "-----END CERTIFICATE-----";
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   130
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   131
    static String topCrlStr =
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   132
        "-----BEGIN X509 CRL-----\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   133
        "MIIBGzCBhQIBATANBgkqhkiG9w0BAQQFADAfMQswCQYDVQQGEwJVUzEQMA4GA1UE\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   134
        "ChMHRXhhbXBsZRcNMDkwNDI3MDIzODA0WhcNMjgwNjI2MDIzODA0WjAiMCACAQUX\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   135
        "DTA5MDQyNzAyMzgwMFowDDAKBgNVHRUEAwoBBKAOMAwwCgYDVR0UBAMCAQIwDQYJ\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   136
        "KoZIhvcNAQEEBQADgYEAoarfzXEtw3ZDi4f9U8eSvRIipHSyxOrJC7HR/hM5VhmY\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   137
        "CErChny6x9lBVg9s57tfD/P9PSzBLusCcHwHMAbMOEcTltVVKUWZnnbumpywlYyg\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   138
        "oKLrE9+yCOkYUOpiRlz43/3vkEL5hjIKMcDSZnPKBZi1h16Yj2hPe9GMibNip54=\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   139
        "-----END X509 CRL-----";
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   140
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   141
    static String subCrlStr =
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   142
        "-----BEGIN X509 CRL-----\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   143
        "MIIBLTCBlwIBATANBgkqhkiG9w0BAQQFADAxMQswCQYDVQQGEwJVUzEQMA4GA1UE\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   144
        "ChMHRXhhbXBsZTEQMA4GA1UECxMHQ2xhc3MtMRcNMDkwNDI3MDIzODA0WhcNMjgw\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   145
        "NjI2MDIzODA0WjAiMCACAQQXDTA5MDQyNzAyMzgwMVowDDAKBgNVHRUEAwoBBKAO\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   146
        "MAwwCgYDVR0UBAMCAQIwDQYJKoZIhvcNAQEEBQADgYEAeS+POqYEIHIIJcsLxuUr\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   147
        "aJFzQ/ujH0QmnyMNEL3Uavyq4VQuAahF+w6aTPb5UBzms0uX8NAvD2vNoUJvmJOX\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   148
        "nGKuq4Q1DFj82E7/9d25nXdWGOmFvFCRVO+St2Xe5n8CJuZNBiz388FDSIOiFSCa\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   149
        "ARGr6Qu68MYGtLMC6ZqP3u0=\n" +
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   150
        "-----END X509 CRL-----";
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   151
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   152
    private static CertPath generateCertificatePath()
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   153
            throws CertificateException {
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   154
        // generate certificate from cert strings
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   155
        CertificateFactory cf = CertificateFactory.getInstance("X.509");
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   156
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   157
        ByteArrayInputStream is;
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   158
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   159
        is = new ByteArrayInputStream(targetCertStr.getBytes());
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   160
        Certificate targetCert = cf.generateCertificate(is);
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   161
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   162
        is = new ByteArrayInputStream(subCaCertStr.getBytes());
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   163
        Certificate subCaCert = cf.generateCertificate(is);
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   164
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   165
        is = new ByteArrayInputStream(selfSignedCertStr.getBytes());
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   166
        Certificate selfSignedCert = cf.generateCertificate(is);
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   167
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   168
        // generate certification path
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   169
        List<Certificate> list = Arrays.asList(new Certificate[] {
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   170
                        targetCert, subCaCert, selfSignedCert});
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   171
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   172
        return cf.generateCertPath(list);
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   173
    }
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   174
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   175
    private static Set<TrustAnchor> generateTrustAnchors()
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   176
            throws CertificateException {
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   177
        // generate certificate from cert string
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   178
        CertificateFactory cf = CertificateFactory.getInstance("X.509");
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   179
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   180
        ByteArrayInputStream is =
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   181
                    new ByteArrayInputStream(selfSignedCertStr.getBytes());
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   182
        Certificate selfSignedCert = cf.generateCertificate(is);
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   183
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   184
        // generate a trust anchor
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   185
        TrustAnchor anchor =
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   186
            new TrustAnchor((X509Certificate)selfSignedCert, null);
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   187
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   188
        return Collections.singleton(anchor);
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   189
    }
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   190
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   191
    private static CertStore generateCertificateStore() throws Exception {
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   192
        Collection entries = new HashSet();
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   193
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   194
        // generate CRL from CRL string
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   195
        CertificateFactory cf = CertificateFactory.getInstance("X.509");
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   196
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   197
        ByteArrayInputStream is =
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   198
                    new ByteArrayInputStream(topCrlStr.getBytes());
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   199
        Collection mixes = cf.generateCRLs(is);
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   200
        entries.addAll(mixes);
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   201
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   202
        is = new ByteArrayInputStream(subCrlStr.getBytes());
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   203
        mixes = cf.generateCRLs(is);
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   204
        entries.addAll(mixes);
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   205
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   206
        // intermediate certs
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   207
        is = new ByteArrayInputStream(topCrlIssuerCertStr.getBytes());
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   208
        mixes = cf.generateCertificates(is);
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   209
        entries.addAll(mixes);
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   210
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   211
        is = new ByteArrayInputStream(subCrlIssuerCertStr.getBytes());
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   212
        mixes = cf.generateCertificates(is);
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   213
        entries.addAll(mixes);
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   214
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   215
        return CertStore.getInstance("Collection",
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   216
                            new CollectionCertStoreParameters(entries));
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   217
    }
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   218
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   219
    public static void main(String args[]) throws Exception {
22268
d72c97c708ae 8030829: Add MD5 to jdk.certpath.disabledAlgorithms security property
xuelei
parents: 5506
diff changeset
   220
        // MD5 is used in this test case, don't disable MD5 algorithm.
d72c97c708ae 8030829: Add MD5 to jdk.certpath.disabledAlgorithms security property
xuelei
parents: 5506
diff changeset
   221
        Security.setProperty(
d72c97c708ae 8030829: Add MD5 to jdk.certpath.disabledAlgorithms security property
xuelei
parents: 5506
diff changeset
   222
                "jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024");
d72c97c708ae 8030829: Add MD5 to jdk.certpath.disabledAlgorithms security property
xuelei
parents: 5506
diff changeset
   223
2927
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   224
        CertPath path = generateCertificatePath();
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   225
        Set<TrustAnchor> anchors = generateTrustAnchors();
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   226
        CertStore crls = generateCertificateStore();
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   227
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   228
        PKIXParameters params = new PKIXParameters(anchors);
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   229
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   230
        // add the CRL store
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   231
        params.addCertStore(crls);
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   232
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   233
        // Activate certificate revocation checking
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   234
        params.setRevocationEnabled(true);
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   235
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   236
        // set the validation time
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   237
        params.setDate(new Date(109, 5, 1));   // 2009-05-01
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   238
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   239
        // disable OCSP checker
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   240
        Security.setProperty("ocsp.enable", "false");
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   241
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   242
        // enable CRL checker
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   243
        System.setProperty("com.sun.security.enableCRLDP", "true");
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   244
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   245
        CertPathValidator validator = CertPathValidator.getInstance("PKIX");
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   246
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   247
        try {
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   248
            validator.validate(path, params);
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   249
        } catch (CertPathValidatorException cpve) {
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   250
            if (cpve.getReason() != BasicReason.REVOKED) {
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   251
                throw new Exception(
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   252
                    "unexpect exception, should be a REVOKED CPVE", cpve);
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   253
            }
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   254
        }
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   255
    }
7780913dc7d6 6720721: CRL check with circular depency support needed
xuelei
parents:
diff changeset
   256
}