/** * Generates a URL string that will return a Torrent file for an object in S3, * which file can be downloaded and run in a BitTorrent client. * * @param bucket the name of the bucket containing the object. * @param key the name of the object. * @return a URL to a Torrent file representing the object. */ public String create(final String bucket, final String key) { String s3Endpoint = endpoint.getHostname(); String serviceEndpointVirtualPath = ""; String bucketNameInPath = ServiceUtils.isBucketNameValidDNSName(bucket) ? "" : RestUtils.encodeUrlString(bucket) + "/"; String urlPath = RestUtils.encodeUrlPath(serviceEndpointVirtualPath, "/") + "/" + bucketNameInPath + RestUtils.encodeUrlPath(key, "/"); return "http://" + ServiceUtils.generateS3HostnameForBucket( bucket, false, s3Endpoint) + urlPath + "?torrent"; } }
protected HttpClient initHttpConnection() { return RestUtils.initHttpConnection( this, this.jets3tProperties, this.invokingApplicationDescription, this.credentialsProvider); }
/** * Initialises this service's HTTP proxy by auto-detecting the proxy settings. */ public static void initHttpProxy(HttpClient httpClient, Jets3tProperties jets3tProperties) { initHttpProxy(httpClient, jets3tProperties, true, null, -1, null, null, null); }
uriPath = (objectKey != null ? RestUtils.encodeUrlPath(objectKey, "/") : ""); } else { uriPath = bucketName + (objectKey != null ? "/" + RestUtils.encodeUrlPath(objectKey, "/") : ""); RestUtils.encodeUrlString((String) headersMap.get(Constants.AMZ_SECURITY_TOKEN)) + "&"; uriPath += "&Expires=" + secondsSinceEpoch; String canonicalString = RestUtils.makeServiceCanonicalString(method, serviceEndpointVirtualPath + "/" + virtualBucketPath + uriPath, renameMetadataKeys(headersMap), String.valueOf(secondsSinceEpoch), String encodedCanonical = RestUtils.encodeUrlString(signedCanonical); uriPath += "&Signature=" + encodedCanonical;
String pathRemainder = iconResourcePath.substring(firstSlashIndex); URL baseUrl = this.getClass().getResource(firstPathComponent); iconUrl = new URL(baseUrl.toString() + RestUtils.encodeUrlPath(pathRemainder, "/"));
+ RestUtils.encodeUrlString(key); if(value != null && value.length() > 0) { urlPath += "=" + RestUtils.encodeUrlString(value); if(log.isDebugEnabled()) { log.debug("Added request parameter: " + key + "=" + value);
exception.setResponseHeaders(RestUtils.convertHeadersToMap(response.getAllHeaders())); this.timeOffset = RestUtils.calculateTimeAdjustmentOffset(response); if(log.isWarnEnabled()) { log.warn("Adjusted time offset in response to RequestTimeTooSkewed error" response.getFirstHeader(Constants.AMZ_REQUEST_ID_1).getValue(), response.getFirstHeader(Constants.AMZ_REQUEST_ID_2).getValue()); serviceException.setResponseHeaders(RestUtils.convertHeadersToMap( response.getAllHeaders()));
private HttpClient initHttpConnection() { // Set client parameters. HttpParams params = RestUtils.createDefaultHttpParams(); HttpProtocolParams.setUserAgent( params, ServiceUtils.getUserAgentDescription(APPLICATION_DESCRIPTION)); // Set connection parameters. HttpConnectionParams.setConnectionTimeout( params, HTTP_CONNECTION_TIMEOUT); HttpConnectionParams.setSoTimeout(params, SOCKET_CONNECTION_TIMEOUT); HttpConnectionParams.setStaleCheckingEnabled(params, false); DefaultHttpClient httpClient = new DefaultHttpClient(params); // Replace default error retry handler. httpClient.setHttpRequestRetryHandler(new RestUtils.JetS3tRetryHandler( MAX_CONNECTION_RETRIES, null)); return httpClient; }
roleName = RestUtils.httpGetUrlAsString(baseCredentialsUrl + "/").trim();
e.setResponseHeaders(RestUtils.convertHeadersToMap( httpResponse.getAllHeaders())); throw e;
this.timeOffset = RestUtils.calculateTimeAdjustmentOffset(response); if(log.isWarnEnabled()) { log.warn("Adjusted time offset in response to RequestTimeTooSkewed error. "
String canonicalString = RestUtils.makeServiceCanonicalString( httpMethod.getMethod(), fullUrl,
uriPath = (objectKey != null ? RestUtils.encodeUrlPath(objectKey, "/") : ""); } else { uriPath = bucketName + (objectKey != null ? "/" + RestUtils.encodeUrlPath(objectKey, "/") : ""); RestUtils.encodeUrlString((String) headersMap.get(Constants.AMZ_SECURITY_TOKEN)) + "&"; uriPath += "&Expires=" + secondsSinceEpoch; String canonicalString = RestUtils.makeServiceCanonicalString(method, serviceEndpointVirtualPath + "/" + virtualBucketPath + uriPath, renameMetadataKeys(headersMap), String.valueOf(secondsSinceEpoch), String encodedCanonical = RestUtils.encodeUrlString(signedCanonical); uriPath += "&Signature=" + encodedCanonical;
String pathRemainder = iconResourcePath.substring(firstSlashIndex); URL baseUrl = this.getClass().getResource(firstPathComponent); iconUrl = new URL(baseUrl.toString() + RestUtils.encodeUrlPath(pathRemainder, "/"));
+ RestUtils.encodeUrlString(key); if(value != null && value.length() > 0) { urlPath += "=" + RestUtils.encodeUrlString(value); if(log.isDebugEnabled()) { log.debug("Added request parameter: " + key + "=" + value);
exception.setResponseHeaders(RestUtils.convertHeadersToMap(response.getAllHeaders())); this.timeOffset = RestUtils.calculateTimeAdjustmentOffset(response); if(log.isWarnEnabled()) { log.warn("Adjusted time offset in response to RequestTimeTooSkewed error" response.getFirstHeader(Constants.AMZ_REQUEST_ID_1).getValue(), response.getFirstHeader(Constants.AMZ_REQUEST_ID_2).getValue()); serviceException.setResponseHeaders(RestUtils.convertHeadersToMap( response.getAllHeaders()));
private HttpClient initHttpConnection() { // Set client parameters. HttpParams params = RestUtils.createDefaultHttpParams(); HttpProtocolParams.setUserAgent( params, ServiceUtils.getUserAgentDescription(APPLICATION_DESCRIPTION)); // Set connection parameters. HttpConnectionParams.setConnectionTimeout( params, HTTP_CONNECTION_TIMEOUT); HttpConnectionParams.setSoTimeout(params, SOCKET_CONNECTION_TIMEOUT); HttpConnectionParams.setStaleCheckingEnabled(params, false); DefaultHttpClient httpClient = new DefaultHttpClient(params); // Replace default error retry handler. httpClient.setHttpRequestRetryHandler(new RestUtils.JetS3tRetryHandler( MAX_CONNECTION_RETRIES, null)); return httpClient; }
roleName = RestUtils.httpGetUrlAsString(baseCredentialsUrl + "/").trim();
e.setResponseHeaders(RestUtils.convertHeadersToMap( httpResponse.getAllHeaders())); throw e;
this.timeOffset = RestUtils.calculateTimeAdjustmentOffset(response); if(log.isWarnEnabled()) { log.warn("Adjusted time offset in response to RequestTimeTooSkewed error. "