jdk/test/lib/security/cacerts/VerifyCACerts.java
author ysr
Mon, 24 Nov 2008 09:53:31 -0800
changeset 1607 be7d05bc07b2
parent 2 90ce3da70b43
child 1632 79700ce7c059
permissions -rw-r--r--
6774607: SIGSEGV or (!is_null(v),"oop value can never be zero") assertion when running with CMS and COOPs Summary: Use the more permissive set_klass_or_null() and klass_or_null() interfaces in ParNew's workqueue overflow code that manipulates the klass-word. Reviewed-by: coleenp
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2002-2006 Sun Microsystems, Inc.  All Rights Reserved.
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
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
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 4400624 6321453
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 * @summary Make sure all self-signed root cert signatures are valid
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.io.FileInputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.security.KeyStore;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.security.cert.*;
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
public class VerifyCACerts {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
    private final static String cacertsFileName =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
        System.getProperty("java.home") +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
        System.getProperty("file.separator") + "lib" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
        System.getProperty("file.separator") + "security" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
        System.getProperty("file.separator") + "cacerts";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    public static void main(String[] args) throws Exception {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
        // pull all the trusted self-signed CA certs out of the cacerts file
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
        // and verify their signatures
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
        KeyStore ks = KeyStore.getInstance("JKS");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
        ks.load(new FileInputStream(cacertsFileName), "changeit".toCharArray());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
        Enumeration<String> aliases = ks.aliases();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
        while (aliases.hasMoreElements()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
            String alias = aliases.nextElement();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
            System.out.println("Verifying " + alias);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
            if (!ks.isCertificateEntry(alias))
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
                throw new Exception(alias + " is not a trusted cert entry");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
            Certificate cert = ks.getCertificate(alias);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
            // remember the GTE CyberTrust CA cert for further tests
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
            if (alias.equals("gtecybertrustca")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
                throw new Exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
                    ("gtecybertrustca is expired and should be deleted");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
            cert.verify(cert.getPublicKey());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
}