Blame SOURCES/TestSecurityProperties.java

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