Blame SOURCES/TestSecurityProperties.java

cadfac
import java.io.File;
cadfac
import java.io.FileInputStream;
cadfac
import java.security.Security;
cadfac
import java.util.Properties;
cadfac
cadfac
public class TestSecurityProperties {
cadfac
    // JDK 11
cadfac
    private static final String JDK_PROPS_FILE_JDK_11 = System.getProperty("java.home") + "/conf/security/java.security";
cadfac
    // JDK 8
cadfac
    private static final String JDK_PROPS_FILE_JDK_8 = System.getProperty("java.home") + "/lib/security/java.security";
cadfac
cadfac
    public static void main(String[] args) {
cadfac
        Properties jdkProps = new Properties();
cadfac
        loadProperties(jdkProps);
cadfac
        for (Object key: jdkProps.keySet()) {
cadfac
            String sKey = (String)key;
cadfac
            String securityVal = Security.getProperty(sKey);
cadfac
            String jdkSecVal = jdkProps.getProperty(sKey);
cadfac
            if (!securityVal.equals(jdkSecVal)) {
cadfac
                String msg = "Expected value '" + jdkSecVal + "' for key '" + 
cadfac
                             sKey + "'" + " but got value '" + securityVal + "'";
cadfac
                throw new RuntimeException("Test failed! " + msg);
cadfac
            } else {
cadfac
                System.out.println("DEBUG: " + sKey + " = " + jdkSecVal + " as expected.");
cadfac
            }
cadfac
        }
cadfac
        System.out.println("TestSecurityProperties PASSED!");
cadfac
    }
cadfac
    
cadfac
    private static void loadProperties(Properties props) {
cadfac
        String javaVersion = System.getProperty("java.version");
cadfac
        System.out.println("Debug: Java version is " + javaVersion);
cadfac
        String propsFile = JDK_PROPS_FILE_JDK_11;
cadfac
        if (javaVersion.startsWith("1.8.0")) {
cadfac
            propsFile = JDK_PROPS_FILE_JDK_8;
cadfac
        }
cadfac
        try (FileInputStream fin = new FileInputStream(new File(propsFile))) {
cadfac
            props.load(fin);
cadfac
        } catch (Exception e) {
cadfac
            throw new RuntimeException("Test failed!", e);
cadfac
        }
cadfac
    }
cadfac
}