@Test public void testDigestAuthentication() throws Exception { log.info("testDigestAuthentication - Begin"); config.saslMechanisms = Collections.singleton(DIGEST_MD5); JMXRemotingServer remotingServer = new JMXRemotingServer(config); remotingServer.start(); Map<String, Object> env = new HashMap<String, Object>(1); env.put(JMXConnector.CREDENTIALS, new String[] {"DigestUser", "DigestPassword"}); JMXConnector connector = JMXConnectorFactory.connect(serviceURL, env); assertNotNull(connector.getConnectionId()); connector.close(); // Now Try A Bad Password env.put(JMXConnector.CREDENTIALS, new String[] {"DigestUser", "BadPassword"}); try { JMXConnectorFactory.connect(serviceURL, env); fail("Expected exception not thrown."); } catch (IOException expected) { } remotingServer.stop(); }
/** * Fast check of the accessibility of the virtualization server. * * @see org.alfresco.linkvalidation.LinkValidationServiceImpl * @return Returns true if server is accessible. */ public boolean pingVirtServer() { if (conn_ != null) { try { // Detects if the connection is connected/disconnected/terminated // See javax.management.remote.rmi.RMIConnector.getConnectionId() implementation conn_.getConnectionId(); return true; } catch (Exception ex) { closeJmxRmiConnection(); return false; } } return false; }
@Test public void testAnonymousAuthentication() throws Exception { log.info("testAnonymousAuthentication - Begin"); JMXRemotingServer remotingServer = new JMXRemotingServer(config); remotingServer.start(); Map<String, Object> env = new HashMap<String, Object>(0); JMXConnector connector = JMXConnectorFactory.connect(serviceURL, env); assertNotNull(connector.getConnectionId()); connector.close(); remotingServer.stop(); System.out.println("STOPPED"); }
@Test public void testLocalAuthentication() throws Exception { log.info("testLocalAuthentication - Begin"); config.saslMechanisms = Collections.singleton(JBOSS_LOCAL_USER); JMXRemotingServer remotingServer = new JMXRemotingServer(config); remotingServer.start(); Map<String, Object> env = new HashMap<String, Object>(1); JMXConnector connector = JMXConnectorFactory.connect(serviceURL, env); assertNotNull(connector.getConnectionId()); connector.close(); remotingServer.stop(); }