Blame SOURCES/TestSecurityProperties.java

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