/** * It is convenient to be able to directly set the Credentials * (not the provider) when those credentials are fixed. * Scope defaults to ANY * * @param creds * @throws HTTPException */ static public void setGlobalCredentials(Credentials creds) throws HTTPException { setGlobalCredentials(creds, null); }
/** * Sets the HTTP authentication. * * @param url the url * @param username the username * @param password the password */ public static void setHTTPAuthentication(String url, String username, String password) { URL urlobj=null; try { urlobj = new URL(url); AuthScope authscope = new AuthScope(urlobj.getHost(), urlobj.getPort()); UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(username, password); ucar.httpservices.HTTPSession.setGlobalCredentials(credentials,authscope); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (HTTPException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
HTTPSession.setGlobalCredentials(creds); try (HTTPSession session = HTTPFactory.newSession(data.url)) { result = invoke(session, data.url);