/*
* 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 4924664
* @summary Tests the use of the "jmx.remote.x.password.file" and
* "jmx.remote.x.access.file" environment map properties.
* @author Luis-Miguel Alventosa
* @run clean PasswordAccessFileTest SimpleStandard SimpleStandardMBean
* @run build PasswordAccessFileTest SimpleStandard SimpleStandardMBean
* @run main PasswordAccessFileTest
*/
public class PasswordAccessFileTest {
try {
//------------------------------------------------------------------
// SERVER
//------------------------------------------------------------------
// Instantiate the MBean server
//
// Create SimpleStandard MBean
//
// Server's environment map
//
// Provide the password file used by the connector server to
// perform user authentication. The password file is a properties
// properties based password authenticator has been implemented
// using the JMXAuthenticator interface and is passed to the
// connector through the "jmx.remote.authenticator" property
// in the map.
//
// This property is implementation-dependent and might not be
// supported by all implementations of the JMX Remote API.
//
// Provide the access level file used by the connector server to
// perform user authorization. The access level file is a properties
// access level is either "readonly" or "readwrite" access to the
// MBeanServer operations. This properties based access control
// checker has been implemented using the MBeanServerForwarder
// interface which wraps the real MBean server inside an access
// controller MBean server which performs the access control checks
// before forwarding the requests to the real MBean server.
//
// This property is implementation-dependent and might not be
// supported by all implementations of the JMX Remote API.
//
// Create an RMI connector server
//
// Start the RMI connector server
//
//------------------------------------------------------------------
// CLIENT : Invalid authentication credentials
//------------------------------------------------------------------
final String invalidCreds[][] = {
{"admin1", "adminPassword"},
{"admin", "adminPassword1"},
{"user1", "userPassword"},
{"user", "userPassword1"}
};
// Try to connect to the server using the invalid credentials.
// All the connect calls should get SecurityException.
//
// Client environment map
//
" for user [" +
invalidCreds[i][0] +
"] with password [" +
// Create an RMI connector client and
// connect it to the RMI connector server
//
"connect it to the RMI connector server");
try {
} catch (SecurityException e) {
} catch (Exception e) {
e.printStackTrace();
}
}
//------------------------------------------------------------------
// CLIENT (admin)
//------------------------------------------------------------------
// Admin client environment map
//
// Create an RMI connector client and
// connect it to the RMI connector server
//
"connect it to the RMI connector server");
// Get an MBeanServerConnection
//
// Get the proxy for the Simple MBean
//
SimpleStandardMBean.class,
false);
// Get State attribute
//
// Set State attribute
//
// Get State attribute
//
// Invoke "reset" in SimpleStandard MBean
//
adminProxy.reset();
// Close MBeanServer connection
//
//------------------------------------------------------------------
// CLIENT (user)
//------------------------------------------------------------------
// User client environment map
//
// Create an RMI connector client and
// connect it to the RMI connector server
//
"connect it to the RMI connector server");
// Get an MBeanServerConnection
//
// Get the proxy for the Simple MBean
//
SimpleStandardMBean.class,
false);
// Get State attribute
//
// Set State attribute
//
try {
} catch (SecurityException e) {
} catch (Exception e) {
e.printStackTrace();
}
// Get State attribute
//
// Invoke "reset" in SimpleStandard MBean
//
try {
} catch (SecurityException e) {
} catch (Exception e) {
e.printStackTrace();
}
// Close MBeanServer connection
//
//------------------------------------------------------------------
// SERVER
//------------------------------------------------------------------
// Stop the connector server
//
} catch (Exception e) {
e.printStackTrace();
}
}
}