#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
# @test
# @bug 6557093
# @summary Check SSL config file permission for out-of-the-box management
#
# @run shell SSLConfigFilePermissionTest.sh
{
cat << EOF > $1/$2.java
class $2 {
public static void main(String[] args) {
System.out.println("Inside main method...");
}
}
EOF
}
cat << EOF > $1
# management.properties
com.sun.management.jmxremote.authenticate=false
com.sun.management.jmxremote.ssl.config.file=$2
EOF
}
if [ -f "$1" ] ; then
fi
cat << EOF > $1
javax.net.ssl.keyStore=$2
javax.net.ssl.keyStorePassword=password
EOF
}
# Check we are run from jtreg
if [ -z "${TESTCLASSES}" ]; then
echo "Test is designed to be run from jtreg only"
exit 0
fi
# Test not suitable for Windows as chmod may not be able to
# security the password file.
echo "Test not designed to run on this operating system, skipping..."
exit 0
fi
# Create management and SSL configuration files
# Compile test
export CLASSPATH
failures=0
echo ''
}
# Test 1 - SSL config file is secure - VM should start
# Test 2 - SSL config file is not secure - VM should fail to start
# Reset the file permissions on the generated SSL config file
#
# Results
#
echo ''
then echo "$failures test(s) failed";
else echo "All test(s) passed"; fi
exit $failures