Results 1 to 2 of 2
- 07-11-2014, 10:39 PM #1Member
- Join Date
- Jul 2014
- Rep Power
Https Request Authentication failing even after setting the proxy
i am trying to access an https request on a server and authenticating it after passing on username and passwork. I have even set up the proxy of the employer to get the request back as a zipped folder.
I always get an error on: " InputStream reader = con.getInputStream();"
Can be a proxy setting issue too but I am not sure why it should be.
Is there a way to create a secure channel in java to connect to https or by any way the below code could be modified to connect it to the server?
Code is as below:
import com.sun.org.apache.xerces.internal.impl.dv.util.Ba se64;
public class DownloadFile
static final String kuser = "username"; // your account name
static final String kpass = "password"; // your password for the account
static class MyAuthenticator extends Authenticator
public PasswordAuthentication getPasswordAuthentication()
System.err.println("Feeding username and password for " +getRequestingScheme());
return (new PasswordAuthentication(kuser, kpass.toCharArray()));
public static void main(String args)
* * Get a connection to the URL and start up
* * a buffered reader.
long startTime = System.currentTimeMillis();
System.out.println("Connecting to SWIFTRef Data website...\n");
URL url = new URL("https://www.swiftrefdata.com/afakdsjfkd/Random/Random");
HttpsURLConnection con = (HttpsURLConnection)url.openConnection();
InputStream reader = con.getInputStream();
* * Setup a buffered file writer to write
* * out what we read from the website.
FileOutputStream writer = new FileOutputStream("MySavedFile.zip");
byte buffer = new byte;
int totalBytesRead = 0;
int bytesRead = 0;
System.out.println("Reading ZIP file 150KB blocks at a time.\n");
while ((bytesRead = reader.read(buffer)) > 0)
writer.write(buffer, 0, bytesRead);
buffer = new byte;
totalBytesRead += bytesRead;
long endTime = System.currentTimeMillis();
System.out.println("Done. " + (new Integer(totalBytesRead).toString()) + " bytes read (" + (new Long(endTime - startTime).toString()) + " millseconds).\n");
catch (MalformedURLException e)
catch (IOException e)
- 07-14-2014, 11:56 AM #2Moderator
- Join Date
- Apr 2009
- Rep Power
Re: Https Request Authentication failing even after setting the proxy
When posting code please wrap it in code tags in order to retain the formatting.
If you are getting an error then you'll also probably want to post the full exception and stack trace for it.Please do not ask for code as refusal often offends.
** This space for rent **
- By dror in forum NetworkingReplies: 1Last Post: 07-29-2012, 01:34 PM
- By vinaykutsa in forum NetworkingReplies: 0Last Post: 03-10-2011, 03:48 AM
- By rioz in forum NetworkingReplies: 6Last Post: 02-15-2011, 01:05 AM
- By Jsharma in forum Advanced JavaReplies: 0Last Post: 01-21-2011, 03:33 AM
- By vns955 in forum Web FrameworksReplies: 1Last Post: 11-12-2009, 03:26 AM