code: public static void setProxyAuthenticator(final String proxyHost, final String proxyPort, final String proxyUser, final String decodedPwd) {
          if (proxyUser == null || proxyUser.isEmpty() || decodedPwd == null || decodedPwd.isEmpty()) {
              return;
          }
          //Authenticate proxy credentials
          Authenticator.setDefault(new Authenticator() {
              @Override
              public PasswordAuthentication getPasswordAuthentication() {
                  if (getRequestorType() == RequestorType.PROXY) {
                      if (getRequestingHost().equals(proxyHost) && getRequestingPort() == Integer.valueOf(proxyPort)) {
                          return new PasswordAuthentication(proxyUser, decodedPwd.toCharArray());
                      }
                  }
                  return null;
              }
          });
      }
docs: Set Proxy Authenticator Default
  
  @param proxyHost The proxy host
  @param proxyPort The proxy port
  @param proxyUser the proxy username
  @param decodedPwd the proxy password decoded