Blame SOURCES/TestSecurityProperties.java

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