Blame SOURCES/TestSecurityProperties.java

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