protected String getTargetHost() { return getRequestingHost(); } }
/** * Read the users .netrc file and find credentials for the specified server. * * @param host name of the remote machine the credentials are to be used with * @param strict require a strict hostname match or also allow default value * @return authentication credentials or null */ public PasswordAuthentication getCredentials(String host, boolean strict) { return readFromCache(host, strict); }
private void runHttpTransfer(HttpTransfer transfer) { if (sslSocketFactory != null) transfer.setSSLSocketFactory(sslSocketFactory); transfer.run(); if (transfer.getSSLSocketFactory() != null) this.sslSocketFactory = transfer.getSSLSocketFactory(); } }
/** * Used for tests to override. * * @param url The URL to download from. * @param outputStream The OutputStream to write to. * @return HttpDownload instance used. * @throws IOException Any errors. */ protected HttpDownload download(final URL url, final OutputStream outputStream) throws IOException { final HttpDownload get = new HttpDownload(url, outputStream); get.run(); return get; }
/** * Submit login data to the service. * @param payload The payload information. * @param out The response stream. * @return Response status code. */ int post(final Map<String, Object> payload, final OutputStream out) { final HttpPost post = new HttpPost(lookupLoginURL(), payload, out); post.run(); return post.getResponseCode(); }
protected HttpDownload getHttpDownload(final URL url, final ByteArrayOutputStream out) { return new HttpDownload(url, out); }
@Override protected PasswordAuthentication getPasswordAuthentication() { synchronized(this) // http library does not have to synchronize usage { log.debug("host: " + getTargetHost()); return netrc.getCredentials(getTargetHost(), true); } }
protected void fireEvent(File file, int state, FileMetadata meta) { if (fireEvents) { TransferEvent e = new TransferEvent(this, eventID, remoteURL, file, state); e.setFileMetadata(meta); fireEvent(e); } }
/** * Set additional request headers. Do not set the same value twice by using this * method and the specific set methods (like setUserAgent, setContentType, etc) in this * class or subclasses. * * @param header * @param value */ public void setRequestProperty(String header, String value) { requestProperties.add(new HttpRequestProperty(header, value)); }
public NetrcAuthenticator(boolean secureMode) { super(); this.netrc = new NetrcFile(secureMode); }
protected void fireEvent(File file, Throwable t) { if (fireEvents) { TransferEvent e = new TransferEvent(this, eventID, remoteURL, file, t); fireEvent(e); } }
public HttpDownload(String userAgent, URL src, InputStreamWrapper dest) { super(true); setUserAgent(userAgent); if (src == null) throw new IllegalArgumentException("source URL cannot be null"); if (dest == null) throw new IllegalArgumentException("destination wrapper cannot be null"); this.remoteURL = src; this.wrapper = dest; }
protected void fireEvent(File file, int state) { fireEvent(file, state, null); }
public void cancel() { if (dl != null) { dl.terminate(); } }
protected void runHttpTransfer(HttpTransfer transfer) { transfer.run(); }
/** * Set additional request headers. * * @param header * @param value */ public void setRequestProperty(String header, String value) { httpRequestProperties.add(new HttpRequestProperty(header,value)); }
NetrcAuthenticator(String netrcFile) { super(); this.netrc = new NetrcFile(netrcFile); }
protected void fireEvent(Throwable t) { fireEvent(localFile, t); }
/** * Set additional request headers. * * @param header * @param value */ public void setRequestProperty(String header, String value) { httpRequestProperties.add(new HttpRequestProperty(header,value)); }
protected void fireEvent(int state) { fireEvent(localFile, state); }