Code example for PasswordAuthentication

0
					Log.d("jNag","data_url not set, returning nowt");
					return ""; 
				} 
        	Authenticator.setDefault(new Authenticator(){
            protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication(username,password.toCharArray());
            }}); 
            HttpURLConnection c;    
            StringBuilder total = new StringBuilder();
            try { 
    			//try to connect using saved credentials and URL 
            	if (data_url.toLowerCase().contains("https")){
            		trustAllHosts(); 
            		c = (HttpsURLConnection) new URL(data_url + parameters).openConnection();
            		((HttpsURLConnection) c).setHostnameVerifier(DO_NOT_VERIFY);
            	} else { 
            		c = (HttpURLConnection) new URL(data_url + parameters).openConnection();
            	} 
            	c.setConnectTimeout(timeout);
            	c.setReadTimeout(timeout);
    			InputStream in = new BufferedInputStream(c.getInputStream(),40960);