Blame SOURCES/TestSecurityProperties.java

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