@Test public void testBase64Encoding() { if (m_runTests == false) return; final Map<String, Object> m = new ConcurrentSkipListMap<String, Object>(); m.put("basic-authentication", "Aladdin:open sesame"); assertEquals("QWxhZGRpbjpvcGVuIHNlc2FtZQ==", HttpMonitor.determineBasicAuthentication(m)); assertFalse( "QWxhZGRpbjpvcZVuIHNlc2FtZQ==".equals(HttpMonitor.determineBasicAuthentication(m))); }
static String determineBasicAuthentication(final Map<String, Object> parameters) { String credentials = ParameterMap.getKeyedString(parameters, PARAMETER_BASIC_AUTHENTICATION, null); if (isNotBlank(credentials)) { credentials = new String(Base64.encodeBase64(credentials.getBytes())); } else { String user = ParameterMap.getKeyedString(parameters, PARAMETER_USER, null); if (isBlank(user)) { credentials = null; } else { String passwd = ParameterMap.getKeyedString(parameters, PARAMETER_PASSWORD, ""); credentials = new String(Base64.encodeBase64((user+":"+passwd).getBytes())); } } return credentials; }
HttpMonitor extends AbstractServiceMonitor { static String determineBasicAuthentication(final Map<String, Object> parameters) { String credentials = ParameterMap.getKeyedString(parameters, PARAMETER_BASIC_AUTHENTICATION, null); if (isNotBlank(credentials)) { credentials = new String(Base64.encodeBase64(credentials.getBytes())); } else { String user = ParameterMap.getKeyedString(parameters, PARAMETER_USER, null); if (isBlank(user)) { credentials = null; } else { String passwd = ParameterMap.getKeyedString(parameters, PARAMETER_PASSWORD, ""); credentials = new String(Base64.encodeBase64((user+":"+passwd).getBytes())); } } return credentials; } }
HttpMonitor extends AbstractServiceMonitor { static String determineBasicAuthentication(final Map<String, Object> parameters) { String credentials = ParameterMap.getKeyedString(parameters, PARAMETER_BASIC_AUTHENTICATION, null); if (isNotBlank(credentials)) { credentials = new String(Base64.encodeBase64(credentials.getBytes())); } else { String user = ParameterMap.getKeyedString(parameters, PARAMETER_USER, null); if (isBlank(user)) { credentials = null; } else { String passwd = ParameterMap.getKeyedString(parameters, PARAMETER_PASSWORD, ""); credentials = new String(Base64.encodeBase64((user+":"+passwd).getBytes())); } } return credentials; }  }
HttpMonitor extends AbstractServiceMonitor { static String determineBasicAuthentication(final Map<String, Object> parameters) { String credentials = ParameterMap.getKeyedString(parameters, PARAMETER_BASIC_AUTHENTICATION, null); if (isNotBlank(credentials)) { credentials = new String(Base64.encodeBase64(credentials.getBytes())); } else { String user = ParameterMap.getKeyedString(parameters, PARAMETER_USER, null); if (isBlank(user)) { credentials = null; } else { String passwd = ParameterMap.getKeyedString(parameters, PARAMETER_PASSWORD, ""); credentials = new String(Base64.encodeBase64((user+":"+passwd).getBytes())); } } return credentials; }  PollStatus poll(final MonitoredService svc, final Map<String, Object> parameters); }
HttpMonitor extends AbstractServiceMonitor { static String determineBasicAuthentication(final Map<String, Object> parameters) { String credentials = ParameterMap.getKeyedString(parameters, PARAMETER_BASIC_AUTHENTICATION, null); if (isNotBlank(credentials)) { credentials = new String(Base64.encodeBase64(credentials.getBytes())); } else { String user = ParameterMap.getKeyedString(parameters, PARAMETER_USER, null); if (isBlank(user)) { credentials = null; } else { String passwd = ParameterMap.getKeyedString(parameters, PARAMETER_PASSWORD, ""); credentials = new String(Base64.encodeBase64((user+":"+passwd).getBytes())); } } return credentials; }  PollStatus poll(final MonitoredService svc, final Map<String, Object> parameters); static final String PARAMETER_VERBOSE; static final String PARAMETER_USER_AGENT; static final String PARAMETER_BASIC_AUTHENTICATION; static final String PARAMETER_USER; static final String PARAMETER_PASSWORD; static final String PARAMETER_RESOLVE_IP; static final String PARAMETER_NODE_LABEL_HOST_NAME; static final String PARAMETER_HOST_NAME; static final String PARAMETER_RESPONSE_TEXT; static final String PARAMETER_RESPONSE; static final String PARAMETER_URL; static final String PARAMETER_PORT; }