test/sun/management/jmxremote/bootstrap/SSLConfigFilePermissionTest.sh

Print this page




  84 mkdir ${LIBDIR} 2>&1
  85 createJavaFile ${TESTCLASSES} Dummy
  86 createManagementConfigFile ${MGMT} ${SSL}
  87 createSSLConfigFile ${SSL} ${TESTSRC}/ssl/keystore
  88 
  89 # Compile test
  90 
  91 ${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d ${TESTCLASSES} ${TESTCLASSES}/Dummy.java
  92 
  93 JAVA=${TESTJAVA}/bin/java
  94 CLASSPATH=${TESTCLASSES}
  95 export CLASSPATH
  96 
  97 failures=0
  98 
  99 mp=-Dcom.sun.management.config.file=${MGMT}
 100 pp=-Dcom.sun.management.jmxremote.port=4999
 101 
 102 go() {
 103     echo ''
 104     sh -xc "$JAVA ${TESTVMOPTS} $1 $2 $3 $4 $5 $6 $7 $8" 2>&1
 105     if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
 106 }
 107 
 108 # Test 1 - SSL config file is secure - VM should start
 109 chmod 700 ${SSL}
 110 sh -xc "$JAVA ${TESTVMOPTS} $mp $pp Dummy" 2>&1
 111 if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
 112 
 113 # Test 2 - SSL config file is not secure - VM should fail to start
 114 chmod o+rx ${SSL}
 115 sh -xc "$JAVA ${TESTVMOPTS} $mp $pp Dummy" 2>&1
 116 if [ $? = 0 ]; then failures=`expr $failures + 1`; fi
 117 
 118 # Reset the file permissions on the generated SSL config file
 119 chmod 777 ${SSL}
 120 
 121 #
 122 # Results
 123 #
 124 echo ''
 125 if [ $failures -gt 0 ];
 126   then echo "$failures test(s) failed";
 127   else echo "All test(s) passed"; fi
 128 exit $failures


  84 mkdir ${LIBDIR} 2>&1
  85 createJavaFile ${TESTCLASSES} Dummy
  86 createManagementConfigFile ${MGMT} ${SSL}
  87 createSSLConfigFile ${SSL} ${TESTSRC}/ssl/keystore
  88 
  89 # Compile test
  90 
  91 ${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d ${TESTCLASSES} ${TESTCLASSES}/Dummy.java
  92 
  93 JAVA=${TESTJAVA}/bin/java
  94 CLASSPATH=${TESTCLASSES}
  95 export CLASSPATH
  96 
  97 failures=0
  98 
  99 mp=-Dcom.sun.management.config.file=${MGMT}
 100 pp=-Dcom.sun.management.jmxremote.port=4999
 101 
 102 go() {
 103     echo ''
 104     sh -xc "$JAVA ${TESTVMOPTS} ${TESTJAVAOPTS} $1 $2 $3 $4 $5 $6 $7 $8" 2>&1
 105     if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
 106 }
 107 
 108 # Test 1 - SSL config file is secure - VM should start
 109 chmod 700 ${SSL}
 110 sh -xc "$JAVA ${TESTVMOPTS} ${TESTJAVAOPTS} $mp $pp Dummy" 2>&1
 111 if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
 112 
 113 # Test 2 - SSL config file is not secure - VM should fail to start
 114 chmod o+rx ${SSL}
 115 sh -xc "$JAVA ${TESTVMOPTS} ${TESTJAVAOPTS} $mp $pp Dummy" 2>&1
 116 if [ $? = 0 ]; then failures=`expr $failures + 1`; fi
 117 
 118 # Reset the file permissions on the generated SSL config file
 119 chmod 777 ${SSL}
 120 
 121 #
 122 # Results
 123 #
 124 echo ''
 125 if [ $failures -gt 0 ];
 126   then echo "$failures test(s) failed";
 127   else echo "All test(s) passed"; fi
 128 exit $failures