WebAppUtils { static String getPassword(Configuration conf, String alias) { String password = null; try { char[] passchars = conf.getPassword(alias); if (passchars != null) { password = new String(passchars); } } catch (IOException ioe) { password = null; } return password; }  static void setRMWebAppPort(Configuration conf, int port); static void setRMWebAppHostnameAndPort(Configuration conf,
      String hostname, int port); static void setNMWebAppHostNameAndPort(Configuration conf,
      String hostName, int port); static R execOnActiveRM(Configuration conf,
      ThrowingBiFunction<String, T, R> func, T arg); static String getRMWebAppURLWithoutScheme(Configuration conf,
      boolean isHAEnabled, int haIdIndex); static String getRMWebAppURLWithScheme(Configuration conf,
      int haIdIndex); static String getRMWebAppURLWithScheme(Configuration conf); static String getRMWebAppURLWithoutScheme(Configuration conf); static String getRouterWebAppURLWithScheme(Configuration conf); static String getRouterWebAppURLWithoutScheme(Configuration conf); static List<String> getProxyHostsAndPortsForAmFilter(
      Configuration conf); static String getProxyHostAndPort(Configuration conf); static String getResolvedRemoteRMWebAppURLWithScheme(
      Configuration conf); static String getResolvedRMWebAppURLWithScheme(Configuration conf); static String getResolvedRemoteRMWebAppURLWithoutScheme(
      Configuration conf); static String getResolvedRMWebAppURLWithoutScheme(Configuration conf); static String getResolvedRMWebAppURLWithoutScheme(Configuration conf,
      Policy httpPolicy); static String getResolvedRemoteRMWebAppURLWithoutScheme(Configuration conf,
      Policy httpPolicy); static String getResolvedRemoteRMWebAppURLWithoutScheme(
      Configuration conf, Policy httpPolicy, String rmId); static String getResolvedAddress(InetSocketAddress address); static String getWebAppBindURL(
      Configuration conf,
      String hostProperty,
      String webAppURLWithoutScheme); static String getNMWebAppURLWithoutScheme(Configuration conf); static String getAHSWebAppURLWithoutScheme(Configuration conf); static String getTimelineReaderWebAppURLWithoutScheme(
      Configuration conf); static String getTimelineCollectorWebAppURLWithoutScheme(
      Configuration conf); static String getURLWithScheme(String schemePrefix, String url); static String getRunningLogURL(
      String nodeHttpAddress, String containerId, String user); static String getAggregatedLogURL(String serverHttpAddress,
      String allocatedNode, String containerId, String entity, String user); static String getHttpSchemePrefix(Configuration conf); static HttpServer2.Builder loadSslConfiguration(
      HttpServer2.Builder builder); static HttpServer2.Builder loadSslConfiguration(
      HttpServer2.Builder builder, Configuration conf); static ApplicationId parseApplicationId(RecordFactory recordFactory,
      String appId); static String getSupportedLogContentType(String format); static String getDefaultLogContentType(); static List<String> listSupportedLogContentType(); static List<NameValuePair> getURLEncodedQueryParam(
      HttpServletRequest request); static String removeQueryParams(HttpServletRequest httpRequest,
      String parameterName); static String getHtmlEscapedURIWithQueryString(
      HttpServletRequest request); static String appendQueryParams(HttpServletRequest request,
      String targetUri); static final String WEB_APP_TRUSTSTORE_PASSWORD_KEY; static final String WEB_APP_KEYSTORE_PASSWORD_KEY; static final String WEB_APP_KEY_PASSWORD_KEY; static final String HTTPS_PREFIX; static final String HTTP_PREFIX; }
@Test public void testGetPassword() throws Exception { Configuration conf = provisionCredentialsForSSL(); Assert.assertEquals("keypass", WebAppUtils.getPassword(conf, WebAppUtils.WEB_APP_KEY_PASSWORD_KEY)); Assert.assertEquals("storepass", WebAppUtils.getPassword(conf, WebAppUtils.WEB_APP_KEYSTORE_PASSWORD_KEY)); Assert.assertEquals("trustpass", WebAppUtils.getPassword(conf, WebAppUtils.WEB_APP_TRUSTSTORE_PASSWORD_KEY)); Assert.assertEquals(null, WebAppUtils.getPassword(conf,"invalid-alias")); }