PasswordAccessFileTest.java revision 2362
2362N/A * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * @summary Tests the use of the "jmx.remote.x.password.file" and 0N/A * "jmx.remote.x.access.file" environment map properties. 0N/A * @author Luis-Miguel Alventosa 0N/A * @run clean PasswordAccessFileTest SimpleStandard SimpleStandardMBean 0N/A * @run build PasswordAccessFileTest SimpleStandard SimpleStandardMBean 0N/A * @run main PasswordAccessFileTest 0N/A //------------------------------------------------------------------ 0N/A //------------------------------------------------------------------ 0N/A // Instantiate the MBean server 0N/A // Create SimpleStandard MBean 0N/A // Server's environment map 0N/A // Provide the password file used by the connector server to 0N/A // perform user authentication. The password file is a properties 0N/A // properties based password authenticator has been implemented 0N/A // using the JMXAuthenticator interface and is passed to the 0N/A // connector through the "jmx.remote.authenticator" property 0N/A // This property is implementation-dependent and might not be 0N/A // supported by all implementations of the JMX Remote API. 0N/A // Provide the access level file used by the connector server to 0N/A // perform user authorization. The access level file is a properties 0N/A // access level is either "readonly" or "readwrite" access to the 0N/A // MBeanServer operations. This properties based access control 0N/A // checker has been implemented using the MBeanServerForwarder 0N/A // interface which wraps the real MBean server inside an access 0N/A // controller MBean server which performs the access control checks 0N/A // before forwarding the requests to the real MBean server. 0N/A // This property is implementation-dependent and might not be 0N/A // supported by all implementations of the JMX Remote API. 0N/A // Create an RMI connector server 0N/A // Start the RMI connector server 0N/A //------------------------------------------------------------------ 0N/A // CLIENT : Invalid authentication credentials 0N/A //------------------------------------------------------------------ 0N/A {
"admin1",
"adminPassword"},
0N/A {
"admin",
"adminPassword1"},
0N/A {
"user1",
"userPassword"},
0N/A {
"user",
"userPassword1"}
0N/A // Try to connect to the server using the invalid credentials. 0N/A // All the connect calls should get SecurityException. 0N/A // Client environment map 0N/A "] with password [" +
0N/A // Create an RMI connector client and 0N/A // connect it to the RMI connector server 0N/A "connect it to the RMI connector server");
0N/A //------------------------------------------------------------------ 0N/A //------------------------------------------------------------------ 0N/A // Admin client environment map 0N/A // Create an RMI connector client and 0N/A // connect it to the RMI connector server 0N/A "connect it to the RMI connector server");
0N/A // Get an MBeanServerConnection 0N/A // Get the proxy for the Simple MBean 0N/A // Get State attribute 0N/A // Set State attribute 0N/A // Get State attribute 0N/A // Invoke "reset" in SimpleStandard MBean 0N/A // Close MBeanServer connection 0N/A //------------------------------------------------------------------ 0N/A //------------------------------------------------------------------ 0N/A // User client environment map 0N/A // Create an RMI connector client and 0N/A // connect it to the RMI connector server 0N/A "connect it to the RMI connector server");
0N/A // Get an MBeanServerConnection 0N/A // Get the proxy for the Simple MBean 0N/A // Get State attribute 0N/A // Set State attribute 0N/A // Get State attribute 0N/A // Invoke "reset" in SimpleStandard MBean 0N/A // Close MBeanServer connection 0N/A //------------------------------------------------------------------ 0N/A //------------------------------------------------------------------ 0N/A // Stop the connector server