8253866: Security Libs Terminology Refresh

Reviewed-by: erikj, weijun, mullan
This commit is contained in:
Jamil Nimeh 2021-01-14 16:36:51 +00:00
parent c2a3c7ef7d
commit 8554fe6ebc
15 changed files with 71 additions and 69 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -34,8 +34,8 @@ import javax.security.auth.login.LoginException;
/*
* @test
* @bug 4515853 8075297 8194486
* @summary Checks that Kerberos client tries slave KDC
* if master KDC is not responding
* @summary Checks that Kerberos client tries replica KDC
* if primary KDC is not responding
* @library /test/lib
* @run main jdk.test.lib.FileInstaller TestHosts TestHosts
* @run main/othervm -Djdk.net.hosts.file=TestHosts BogusKDC
@ -80,8 +80,8 @@ public class BogusKDC {
CallbackHandler handler = new Helper.UserPasswordHandler(
USER, USER_PASSWORD);
// create a krb5 config with non-existing host for master KDC,
// and wrong port for slave KDC
// create a krb5 config with non-existing host for primary KDC,
// and wrong port for replica KDC
try (PrintWriter w = new PrintWriter(new FileWriter(KRB5_CONF))) {
w.write(String.format(KRB5_CONF_TEMPLATE,
KDC.NOT_EXISTING_HOST, WRONG_KDC_PORT));
@ -96,8 +96,8 @@ public class BogusKDC {
System.out.println("Expected login failure: " + le);
}
// create a krb5 config with non-existing host for master KDC,
// but correct port for slave KDC
// create a krb5 config with non-existing host for primary KDC,
// but correct port for replica KDC
try (PrintWriter w = new PrintWriter(new FileWriter(KRB5_CONF))) {
w.write(String.format(KRB5_CONF_TEMPLATE,
KDC.NOT_EXISTING_HOST, kdc.getPort()));

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -35,7 +35,7 @@ import java.security.KeyStore;
import java.security.cert.*;
import java.util.*;
public class CheckBlacklistedCerts {
public class CheckBlockedCerts {
public static void main(String[] args) throws Exception {
String home = System.getProperty("java.home");
@ -57,29 +57,30 @@ public class CheckBlacklistedCerts {
}
// All certs in the pem files
Set<Certificate> blacklisted = new HashSet<>();
Set<Certificate> blocked = new HashSet<>();
// Assumes the full src is available
File blacklist = new File(System.getProperty("test.src"),
"../../../../../make/data/blacklistedcertsconverter/blacklisted.certs.pem");
File blockedCertsFile = new File(System.getProperty("test.src"),
"../../../../../make/data/blockedcertsconverter/blocked.certs.pem");
CertificateFactory cf = CertificateFactory.getInstance("X.509");
try (FileInputStream fis = new FileInputStream(blacklist)) {
try (FileInputStream fis = new FileInputStream(blockedCertsFile)) {
Collection<? extends Certificate> certs
= cf.generateCertificates(fis);
System.out.println(certs.size());
for (Certificate c: certs) {
blacklisted.add(c);
blocked.add(c);
X509Certificate cert = ((X509Certificate)c);
if (!UntrustedCertificates.isUntrusted(cert)) {
System.out.println(cert.getSubjectDN() + " is trusted");
System.out.println(cert.getSubjectX500Principal() +
" is trusted");
failed = true;
}
}
}
// Check the blacklisted.certs file itself
file = new File(home, "lib/security/blacklisted.certs");
// Check the blocked.certs file itself
file = new File(home, "lib/security/blocked.certs");
System.out.print("Check for " + file + ": ");
try (BufferedReader reader = new BufferedReader(
new InputStreamReader(new FileInputStream(file)))) {
@ -100,11 +101,11 @@ public class CheckBlacklistedCerts {
failed = true;
}
// There are two unique fingerprints for each RSA certificate
if (ccount != blacklisted.size() * 2
&& !blacklisted.isEmpty()) {
System.out.println("Wrong blacklisted.certs size: "
if (ccount != blocked.size() * 2
&& !blocked.isEmpty()) {
System.out.println("Wrong blocked.certs size: "
+ ccount + " fingerprints, "
+ blacklisted.size() + " certs");
+ blocked.size() + " certs");
failed = true;
}
}