Skip to content

Commit

Permalink
v3.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
SendSafely-GitHub committed Jan 18, 2019
1 parent 20ac376 commit 474c5a1
Show file tree
Hide file tree
Showing 12 changed files with 637 additions and 17 deletions.
16 changes: 11 additions & 5 deletions SendSafelyAPI/src/com/sendsafely/SendSafely.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ public class SendSafely {

protected double version = 0.3;

private boolean ec2Proxy = false;

/**
* @description Constructor to create a new SendSafely object.
* @param host The hostname you use to access SendSafely. Should be https://companyname.sendsafely.com or https://www.sendsafely.com
Expand Down Expand Up @@ -216,6 +218,10 @@ public SendSafely(String host) {
this(host, (ConnectionManager)null, (CredentialsManager)null);
}

public void setEc2Proxy (boolean isProxy) {
this.ec2Proxy = isProxy;
}

/**
* @description Add Contact Group as a recipient on a package.
* @param packageId The unique package id of the package for the add the Contact Group operation.
Expand Down Expand Up @@ -435,7 +441,7 @@ public void deletePackage(String packageId) throws DeletePackageException
*/
public java.io.File downloadFile(String packageId, String fileId, String keyCode) throws DownloadFileException, PasswordRequiredException
{
return downloadFile(packageId, fileId, keyCode, null, (String)null);
return downloadFile(packageId, fileId, keyCode, new DefaultProgress());
}

/**
Expand All @@ -452,7 +458,7 @@ public java.io.File downloadFile(String packageId, String fileId, String keyCode
public java.io.File downloadFile(String packageId, String fileId, String keyCode, ProgressInterface progress) throws DownloadFileException, PasswordRequiredException
{
DownloadAndDecryptFileHandler handler = new DownloadAndDecryptFileHandler(uploadManager);
return handler.makeRequest(packageId, null, fileId, keyCode, progress, null);
return handler.makeRequestS3(packageId, null, fileId, keyCode, progress, null, ec2Proxy);
}

/**
Expand Down Expand Up @@ -485,7 +491,6 @@ public java.io.File downloadFile(String packageId, String fileId, String keyCode
return handler.makeRequest(packageId, null, fileId, keyCode, progress, password);
}


/**
* @description Downloads a file from the server and decrypts it.
* @param packageId The unique package id of the package for the file download operation.
Expand All @@ -499,7 +504,8 @@ public java.io.File downloadFile(String packageId, String fileId, String keyCode
*/
public java.io.File downloadFile(String packageId, String fileId, String keyCode, String password) throws DownloadFileException, PasswordRequiredException
{
return downloadFile(packageId, fileId, keyCode, null, password);
DownloadAndDecryptFileHandler handler = new DownloadAndDecryptFileHandler(uploadManager);
return handler.makeRequest(packageId, null, fileId, keyCode, null, password);
}

/**
Expand Down Expand Up @@ -531,7 +537,7 @@ public java.io.File downloadFileFromDirectory(String packageId, String directory
*/
public java.io.File downloadFileFromDirectory(String packageId, String directoryId, String fileId, String keyCode, ProgressInterface progress) throws DownloadFileException, PasswordRequiredException {
DownloadAndDecryptFileHandler handler = new DownloadAndDecryptFileHandler(uploadManager);
return handler.makeRequest(packageId, directoryId, fileId, keyCode, progress);
return handler.makeRequestS3(packageId, directoryId, fileId, keyCode, progress, (String)null, ec2Proxy);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.sendsafely.dto.request;

import com.sendsafely.enums.GetParam;
import com.sendsafely.enums.HTTPMethod;
import com.sendsafely.json.JsonManager;

public class GetDownloadUrlsFromDirectoryRequest extends BaseRequest {

private HTTPMethod method = HTTPMethod.POST;
private String path = "/package/" + GetParam.PACKAGE_ID + "/directory/" + GetParam.DIRECTORY_ID + "/file/" + GetParam.FILE_ID + "/download-urls/";

public GetDownloadUrlsFromDirectoryRequest(JsonManager jsonManager){
initialize(jsonManager, method, path);
}

public void setPackageId(String packageId) {
super.setGetParam(GetParam.PACKAGE_ID, packageId);
}

public void setFileId(String fileId) {
super.setGetParam(GetParam.FILE_ID, fileId);
}

public void setDirectoryId(String directoryId){
super.setGetParam(GetParam.DIRECTORY_ID, directoryId);
}

public void setStartSegment(int start) {
super.setPostParam("startSegment", start);
}

public void setEndSegment(int end) {
super.setPostParam("endSegment", end);
}
public void setPackageCode(String packageCode){
super.setPostParam("packageCode", packageCode);
}
public void setChecksum(String checksum){
super.setPostParam("checksum", checksum);
}
public void setForceProxy(boolean forceProxy){
super.setPostParam("forceProxy", forceProxy);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.sendsafely.dto.request;

import com.sendsafely.enums.GetParam;
import com.sendsafely.enums.HTTPMethod;
import com.sendsafely.json.JsonManager;

public class GetDownloadUrlsRequest extends BaseRequest {

private HTTPMethod method = HTTPMethod.POST;
private String path = "/package/" + GetParam.PACKAGE_ID + "/file/" + GetParam.FILE_ID + "/download-urls/";

public GetDownloadUrlsRequest(JsonManager jsonManager){
initialize(jsonManager, method, path);
}

public void setPackageId(String packageId) {
super.setGetParam(GetParam.PACKAGE_ID, packageId);
}

public void setFileId(String fileId) {
super.setGetParam(GetParam.FILE_ID, fileId);
}

public void setStartSegment(int start) {
super.setPostParam("startSegment", start);
}

public void setEndSegment(int end) {
super.setPostParam("endSegment", end);
}

public void setChecksum(String checksum){
super.setPostParam("checksum", checksum);
}
public void setForceProxy(boolean forceProxy){
super.setPostParam("forceProxy", forceProxy);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.sendsafely.dto.response;

import java.util.List;
import java.util.Map;

public class GetDownloadUrlsResponse extends BaseResponse {

private List<Map<String, String>> downloadUrls;

public List<Map<String, String>> getDownloadUrls() {
return downloadUrls;
}

public void setDownloadUrls(List<Map<String, String>> downloadUrls) {
this.downloadUrls = downloadUrls;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.sendsafely.exceptions;

public class GetDownloadUrlsException extends Exception {

/**
*
*/
private static final long serialVersionUID = 1L;

String error;

public GetDownloadUrlsException(Exception e) {
super(e);
error = e.getMessage();
}

public GetDownloadUrlsException(String err){
super(err);
error = err;
}

}
Loading

0 comments on commit 474c5a1

Please sign in to comment.