diff --git a/src/main/java/Services/AcceptReject/SWAcceptRejectService.java b/src/main/java/Services/AcceptReject/SWAcceptRejectService.java index f645bbd..6fab4a0 100644 --- a/src/main/java/Services/AcceptReject/SWAcceptRejectService.java +++ b/src/main/java/Services/AcceptReject/SWAcceptRejectService.java @@ -13,6 +13,14 @@ import Utils.Responses.IResponse; public class SWAcceptRejectService extends SWService{ + public SWAcceptRejectService(String user, String password, String URI, String proxyHost, int proxyPort) throws AuthException { + super(user, password, URI, proxyHost, proxyPort); + } + + public SWAcceptRejectService(String token, String URI, String proxyHost, int proxyPort) { + super(token, URI, proxyHost, proxyPort); + } + public SWAcceptRejectService(String user, String password, String URI) throws AuthException { super(user, password, URI); } @@ -22,25 +30,25 @@ public SWAcceptRejectService(String token, String URI) { } public IResponse AceptarRechazarCancelacionCSD(Map uuids,String password_csd, String rfc, String b64Cer, String b64Key) throws AuthException, GeneralException, IOException { - AceptarRechazarOptionsRequest settings = new AceptarRechazarOptionsRequest(getToken(),getURI(), uuids, password_csd, rfc, b64Cer, b64Key); + AceptarRechazarOptionsRequest settings = new AceptarRechazarOptionsRequest(getToken(),getURI(), uuids, password_csd, rfc, b64Cer, b64Key, getProxyHost(), getProxyPort()); AceptarRechazarCancelationRequest req = new AceptarRechazarCancelationRequest(); return req.sendRequest(settings); } public IResponse AceptarRechazarCancelacionPFX(Map uuids,String password_csd, String rfc, String b64pfx) throws AuthException, GeneralException, IOException, SOAPException { - AceptarRechazarOptionsRequest settings = new AceptarRechazarOptionsRequest(getToken(),getURI(), uuids, password_csd, rfc, b64pfx); + AceptarRechazarOptionsRequest settings = new AceptarRechazarOptionsRequest(getToken(),getURI(), uuids, password_csd, rfc, b64pfx, getProxyHost(), getProxyPort()); AceptarRechazarCancelationRequest req = new AceptarRechazarCancelationRequest(); return req.sendRequestPFX(settings); } public IResponse AceptarRechazarCancelacionXML(String xml) throws AuthException, GeneralException, IOException { - AceptarRechazarOptionsRequest settings = new AceptarRechazarOptionsRequest(getToken(),getURI(),xml); + AceptarRechazarOptionsRequest settings = new AceptarRechazarOptionsRequest(getToken(),getURI(), xml, getProxyHost(), getProxyPort()); AceptarRechazarCancelationRequest req = new AceptarRechazarCancelationRequest(); return req.sendRequestXML(settings); } public IResponse AceptarRechazarCancelacionUUID(String uuid, String rfc, String action) throws AuthException, GeneralException, IOException, SOAPException { - AceptarRechazarOptionsRequest settings = new AceptarRechazarOptionsRequest(getToken(),getURI(), uuid, rfc, action); + AceptarRechazarOptionsRequest settings = new AceptarRechazarOptionsRequest(getToken(),getURI(), uuid, rfc, action, getProxyHost(), getProxyPort()); AceptarRechazarCancelationRequest req = new AceptarRechazarCancelationRequest(); return req.sendRequestUUID(settings); } diff --git a/src/main/java/Services/Authentication/SWAuthenticationService.java b/src/main/java/Services/Authentication/SWAuthenticationService.java index ebaf374..d69e67b 100644 --- a/src/main/java/Services/Authentication/SWAuthenticationService.java +++ b/src/main/java/Services/Authentication/SWAuthenticationService.java @@ -10,12 +10,15 @@ import Utils.Responses.IResponse; public class SWAuthenticationService extends SWService { + public SWAuthenticationService(String user, String password, String URI, String proxyHost, int proxyPort) throws AuthException { + super(user, password, URI, proxyHost, proxyPort); + } public SWAuthenticationService(String user, String password, String URI) throws AuthException { super(user, password, URI); } public IResponse Token() throws GeneralException, AuthException, IOException { - AuthOptionsRequest settings = new AuthOptionsRequest(getURI(),getUser(),getPassword()); + AuthOptionsRequest settings = new AuthOptionsRequest(getURI(), getUser(), getPassword(), getProxyHost(), getProxyPort()); AuthRequest req = new AuthRequest(); return req.sendRequest(settings); } diff --git a/src/main/java/Services/BalanceAccount/SWBalanceAccountService.java b/src/main/java/Services/BalanceAccount/SWBalanceAccountService.java index 55306f4..979cc08 100644 --- a/src/main/java/Services/BalanceAccount/SWBalanceAccountService.java +++ b/src/main/java/Services/BalanceAccount/SWBalanceAccountService.java @@ -20,8 +20,16 @@ public SWBalanceAccountService(String token, String URI) { super(token, URI); } + public SWBalanceAccountService(String user, String password, String URI, String proxyHost, int proxyPort) throws AuthException { + super(user, password, URI, proxyHost, proxyPort); + } + + public SWBalanceAccountService(String token, String URI, String proxyHost, int proxyPort) { + super(token, URI, proxyHost, proxyPort); + } + public IResponse GetBalanceAccount() throws AuthException, GeneralException, IOException { - BalanceAcctOptionsRequest settings = new BalanceAcctOptionsRequest(getToken(),getURI()); + BalanceAcctOptionsRequest settings = new BalanceAcctOptionsRequest(getToken(), getURI(), getProxyHost(), getProxyPort()); BalanceAcctRequest req = new BalanceAcctRequest(); return req.sendRequest(settings); } diff --git a/src/main/java/Services/Cancelation/SWCancelationService.java b/src/main/java/Services/Cancelation/SWCancelationService.java index 9cfb671..c56f7ae 100644 --- a/src/main/java/Services/Cancelation/SWCancelationService.java +++ b/src/main/java/Services/Cancelation/SWCancelationService.java @@ -21,26 +21,34 @@ public SWCancelationService(String token, String URI) { super(token, URI); } + public SWCancelationService(String user, String password, String URI, String proxyHost, int proxyPort) throws AuthException { + super(user, password, URI, proxyHost, proxyPort); + } + + public SWCancelationService(String token, String URI, String proxyHost, int proxyPort) { + super(token, URI, proxyHost, proxyPort); + } + public IResponse Cancelation(String uuid, String password_csd, String rfc, String b64Cer, String b64Key) throws AuthException, GeneralException, IOException { - CancelationOptionsRequest settings = new CancelationOptionsRequest(getToken(),getURI(),uuid, password_csd, rfc, b64Cer, b64Key); + CancelationOptionsRequest settings = new CancelationOptionsRequest(getToken(), getURI(), uuid, password_csd, rfc, b64Cer, b64Key, getProxyHost(), getProxyPort()); CancelationRequest req = new CancelationRequest(); return req.sendRequest(settings); } public IResponse Cancelation(String xml) throws AuthException, GeneralException, IOException { - CancelationOptionsRequest settings = new CancelationOptionsRequest(getToken(),getURI(),xml); + CancelationOptionsRequest settings = new CancelationOptionsRequest(getToken(), getURI(), xml, getProxyHost(), getProxyPort()); CancelationRequest req = new CancelationRequest(); return req.sendRequest(settings, true); } public IResponse Cancelation(String uuid, String password_csd, String rfc, String b64Pfx) throws AuthException, GeneralException, IOException { - CancelationOptionsRequest settings = new CancelationOptionsRequest(getToken(),getURI(),uuid, password_csd, rfc, b64Pfx); + CancelationOptionsRequest settings = new CancelationOptionsRequest(getToken(), getURI(), uuid, password_csd, rfc, b64Pfx, getProxyHost(), getProxyPort()); CancelationRequest req = new CancelationRequest(); return req.sendRequestPfx(settings); } public IResponse Cancelation(String uuid, String rfc) throws AuthException, GeneralException, IOException { - CancelationOptionsRequest settings = new CancelationOptionsRequest(getToken(),getURI(),uuid, rfc); + CancelationOptionsRequest settings = new CancelationOptionsRequest(getToken(), getURI(), uuid, rfc, getProxyHost(), getProxyPort()); CancelationRequest req = new CancelationRequest(); return req.sendRequestUuid(settings); } diff --git a/src/main/java/Services/Csd/SWCsdService.java b/src/main/java/Services/Csd/SWCsdService.java index 66befb1..bfbd973 100644 --- a/src/main/java/Services/Csd/SWCsdService.java +++ b/src/main/java/Services/Csd/SWCsdService.java @@ -18,11 +18,11 @@ public SWCsdService(String user, String password, String URI) throws AuthExcepti public SWCsdService(String token, String URI) { super(token, URI); } - public SWCsdService(String user, String password, String URI, String proxyHost, String proxyPort) throws AuthException { + public SWCsdService(String user, String password, String URI, String proxyHost, int proxyPort) throws AuthException { super(user, password, URI, proxyHost, proxyPort); } - public SWCsdService(String token, String URI, String proxyHost, String proxyPort) { + public SWCsdService(String token, String URI, String proxyHost, int proxyPort) { super(token, URI, proxyHost, proxyPort); } diff --git a/src/main/java/Services/Issue/SWIssueService.java b/src/main/java/Services/Issue/SWIssueService.java index 7ed3fec..6ab7a79 100644 --- a/src/main/java/Services/Issue/SWIssueService.java +++ b/src/main/java/Services/Issue/SWIssueService.java @@ -19,27 +19,35 @@ public SWIssueService(String user, String password, String URI) throws AuthExcep public SWIssueService(String token, String URI) { super(token, URI); } + + public SWIssueService(String user, String password, String URI, String proxyHost, int proxyPort) throws AuthException { + super(user, password, URI, proxyHost, proxyPort); + } + + public SWIssueService(String token, String URI, String proxyHost, int proxyPort) { + super(token, URI, proxyHost, proxyPort); + } public IResponse IssueJson(String json, String version) throws AuthException, GeneralException, IOException { - IssueOptionsRequest settings = new IssueOptionsRequest(getToken(), getURI(), json, version); + IssueOptionsRequest settings = new IssueOptionsRequest(getToken(), getURI(), json, version, getProxyHost(), getProxyPort()); IssueRequest req = new IssueRequest(); return req.sendRequest(settings); } public IResponse IssueJson(byte[] jsonFile, String version) throws AuthException, GeneralException, IOException { String jsonProcess = new String(jsonFile, Charset.forName("UTF-8")); - IssueOptionsRequest settings = new IssueOptionsRequest(getToken(), getURI(), jsonProcess, version); + IssueOptionsRequest settings = new IssueOptionsRequest(getToken(), getURI(), jsonProcess, version, getProxyHost(), getProxyPort()); IssueRequest req = new IssueRequest(); return req.sendRequest(settings); } public IResponse IssueXml(String xml, String version) throws AuthException, GeneralException, IOException { - IssueOptionsRequest settings = new IssueOptionsRequest(getToken(), getURI(), xml, version, true); + IssueOptionsRequest settings = new IssueOptionsRequest(getToken(), getURI(), xml, version, true, getProxyHost(), getProxyPort()); IssueRequest req = new IssueRequest(); return req.sendRequestXml(settings); } public IResponse IssueXml(byte[] xmlfile, String version) throws AuthException, GeneralException, IOException { String xmlProcess = new String(xmlfile, Charset.forName("UTF-8")); - IssueOptionsRequest settings = new IssueOptionsRequest(getToken(), getURI(), xmlProcess, version, true); + IssueOptionsRequest settings = new IssueOptionsRequest(getToken(), getURI(), xmlProcess, version, true, getProxyHost(), getProxyPort()); IssueRequest req = new IssueRequest(); return req.sendRequestXml(settings); } diff --git a/src/main/java/Services/Pdf/SWPdfService.java b/src/main/java/Services/Pdf/SWPdfService.java index 8011215..25a03fe 100644 --- a/src/main/java/Services/Pdf/SWPdfService.java +++ b/src/main/java/Services/Pdf/SWPdfService.java @@ -20,20 +20,28 @@ public SWPdfService(String token, String URI) { super(token, URI); } + public SWPdfService(String user, String password, String URI, String proxyHost, int proxyPort) throws AuthException { + super(user, password, URI, proxyHost, proxyPort); + } + + public SWPdfService(String token, String URI, String proxyHost, int proxyPort) { + super(token, URI, proxyHost, proxyPort); + } + public IResponse GeneratePdf(String xml) throws AuthException, GeneralException, IOException { - PdfOptionsRequest settings = new PdfOptionsRequest(getToken(),getURI(), xml); + PdfOptionsRequest settings = new PdfOptionsRequest(getToken(),getURI(), xml, getProxyHost(), getProxyPort()); PdfRequest req = new PdfRequest(); return req.sendRequest(settings); } public IResponse GeneratePdf(String xml, String extras) throws AuthException, GeneralException, IOException { - PdfOptionsRequest settings = new PdfOptionsRequest(getToken(),getURI(), xml, extras); + PdfOptionsRequest settings = new PdfOptionsRequest(getToken(),getURI(), xml, extras, getProxyHost(), getProxyPort()); PdfRequest req = new PdfRequest(); return req.sendRequest(settings); } public IResponse GeneratePdf(String xml, String extras, String templateId) throws AuthException, GeneralException, IOException { - PdfOptionsRequest settings = new PdfOptionsRequest(getToken(),getURI(), xml, extras, templateId); + PdfOptionsRequest settings = new PdfOptionsRequest(getToken(),getURI(), xml, extras, templateId, getProxyHost(), getProxyPort()); PdfRequest req = new PdfRequest(); return req.sendRequest(settings); } diff --git a/src/main/java/Services/Pendings/SWPendingsService.java b/src/main/java/Services/Pendings/SWPendingsService.java index ff39393..b7ca3ab 100644 --- a/src/main/java/Services/Pendings/SWPendingsService.java +++ b/src/main/java/Services/Pendings/SWPendingsService.java @@ -20,8 +20,16 @@ public SWPendingsService(String token, String URI) { super(token, URI); } + public SWPendingsService(String user, String password, String URI, String proxyHost, int proxyPort) throws AuthException { + super(user, password, URI, proxyHost, proxyPort); + } + + public SWPendingsService(String token, String URI, String proxyHost, int proxyPort) { + super(token, URI, proxyHost, proxyPort); + } + public IResponse PendientesPorCancelar(String rfc) throws AuthException, GeneralException, IOException, SOAPException { - PendientesCancelarOptionsRequest settings = new PendientesCancelarOptionsRequest(getToken(),getURI(), rfc); + PendientesCancelarOptionsRequest settings = new PendientesCancelarOptionsRequest(getToken(),getURI(), rfc, getProxyHost(), getProxyPort()); PendientesCancelarRequest req = new PendientesCancelarRequest(); return req.sendRequest(settings); } diff --git a/src/main/java/Services/Relations/SWRelationsService.java b/src/main/java/Services/Relations/SWRelationsService.java index 8a2b4df..a168134 100644 --- a/src/main/java/Services/Relations/SWRelationsService.java +++ b/src/main/java/Services/Relations/SWRelationsService.java @@ -20,26 +20,34 @@ public SWRelationsService(String token, String URI) { super(token, URI); } + public SWRelationsService(String user, String password, String URI, String proxyHost, int proxyPort) throws AuthException { + super(user, password, URI, proxyHost, proxyPort); + } + + public SWRelationsService(String token, String URI, String proxyHost, int proxyPort) { + super(token, URI, proxyHost, proxyPort); + } + public IResponse CfdiRelacionadosCSD(String uuid,String password_csd, String rfc, String b64Cer, String b64Key) throws AuthException, GeneralException, IOException { - CfdiRelacionadosOptionsRequest settings = new CfdiRelacionadosOptionsRequest(getToken(),getURI(), uuid, password_csd, rfc, b64Cer, b64Key); + CfdiRelacionadosOptionsRequest settings = new CfdiRelacionadosOptionsRequest(getToken(),getURI(), uuid, password_csd, rfc, b64Cer, b64Key, getProxyHost(), getProxyPort()); CfdiRelacionadosRequest req = new CfdiRelacionadosRequest(); return req.sendRequest(settings); } public IResponse CfdiRelacionadosPFX(String uuid,String password_csd, String rfc, String b64pfx) throws AuthException, GeneralException, IOException, SOAPException { - CfdiRelacionadosOptionsRequest settings = new CfdiRelacionadosOptionsRequest(getToken(),getURI(), uuid, password_csd, rfc, b64pfx); + CfdiRelacionadosOptionsRequest settings = new CfdiRelacionadosOptionsRequest(getToken(),getURI(), uuid, password_csd, rfc, b64pfx, getProxyHost(), getProxyPort()); CfdiRelacionadosRequest req = new CfdiRelacionadosRequest(); return req.sendRequestPFX(settings); } public IResponse CfdiRelacionadosXML(String xml) throws AuthException, GeneralException, IOException, SOAPException { - CfdiRelacionadosOptionsRequest settings = new CfdiRelacionadosOptionsRequest(getToken(),getURI(), xml); + CfdiRelacionadosOptionsRequest settings = new CfdiRelacionadosOptionsRequest(getToken(),getURI(), xml, getProxyHost(), getProxyPort()); CfdiRelacionadosRequest req = new CfdiRelacionadosRequest(); return req.sendRequestXML(settings); } public IResponse CfdiRelacionadosUUID(String uuid, String rfc) throws AuthException, GeneralException, IOException, SOAPException { - CfdiRelacionadosOptionsRequest settings = new CfdiRelacionadosOptionsRequest(getToken(),getURI(), uuid, rfc); + CfdiRelacionadosOptionsRequest settings = new CfdiRelacionadosOptionsRequest(getToken(),getURI(), uuid, rfc, getProxyHost(), getProxyPort()); CfdiRelacionadosRequest req = new CfdiRelacionadosRequest(); return req.sendRequestUUID(settings); } diff --git a/src/main/java/Services/SWService.java b/src/main/java/Services/SWService.java index e3c857d..798c17c 100644 --- a/src/main/java/Services/SWService.java +++ b/src/main/java/Services/SWService.java @@ -15,7 +15,7 @@ public abstract class SWService { private String User = null; private String Password = null; private String ProxyHost = null; - private String ProxyPort = null; + private int ProxyPort = 0; private Date time = null; public String getToken() throws AuthException, GeneralException, IOException { @@ -41,7 +41,7 @@ public String getProxyHost() { return ProxyHost; } - public String getProxyPort() { + public int getProxyPort() { return ProxyPort; } @@ -60,7 +60,7 @@ protected SWService(String user, String password, String URI) throws AuthExcepti } } - protected SWService(String user, String password, String URI, String ProxyHost, String ProxyPort) throws AuthException { + protected SWService(String user, String password, String URI, String ProxyHost, int ProxyPort) throws AuthException { User = user; Password = password; this.ProxyHost = ProxyHost; @@ -83,7 +83,7 @@ protected SWService(String token, String URI) { this.time = new Date((long)999999999*100000); } - protected SWService(String token, String URI, String ProxyHost, String ProxyPort) { + protected SWService(String token, String URI, String ProxyHost, int ProxyPort) { Token = token; this.URI = URI; this.ProxyHost = ProxyHost; @@ -111,7 +111,7 @@ public void generateToken() throws AuthException, GeneralException, IOException if (User == null || Password == null) { throw new AuthException(400, "no existen elementos de autenticación"); } - AuthOptionsRequest settings = new AuthOptionsRequest(URI, getUser(), getPassword()); + AuthOptionsRequest settings = new AuthOptionsRequest(URI, getUser(), getPassword(), getProxyHost(), getProxyPort()); AuthRequest req = new AuthRequest(); SuccessAuthResponse res = (SuccessAuthResponse) req.sendRequest(settings); if (res.HttpStatusCode == 200) { diff --git a/src/main/java/Services/Stamp/SWStampService.java b/src/main/java/Services/Stamp/SWStampService.java index 9601cc8..5c4c9a6 100644 --- a/src/main/java/Services/Stamp/SWStampService.java +++ b/src/main/java/Services/Stamp/SWStampService.java @@ -21,11 +21,11 @@ public SWStampService(String token, String URI) { super(token, URI); } - public SWStampService(String user, String password, String URI, String proxyHost, String proxyPort) throws AuthException { + public SWStampService(String user, String password, String URI, String proxyHost, int proxyPort) throws AuthException { super(user, password, URI, proxyHost, proxyPort); } - public SWStampService(String token, String URI, String proxyHost, String proxyPort) { + public SWStampService(String token, String URI, String proxyHost, int proxyPort) { super(token, URI, proxyHost, proxyPort); } diff --git a/src/main/java/Services/StatusCfdi/StatusCfdiService.java b/src/main/java/Services/StatusCfdi/StatusCfdiService.java index 07644ad..88db5ff 100644 --- a/src/main/java/Services/StatusCfdi/StatusCfdiService.java +++ b/src/main/java/Services/StatusCfdi/StatusCfdiService.java @@ -19,7 +19,7 @@ public StatusCfdiService(String URL, String Action) { } public IResponse StatusCfdi(String rfcEmisor, String rfcReceptor, String total, String uuid) throws AuthException, GeneralException, IOException, SOAPException { - StatusCancelationOptionsRequest settings = new StatusCancelationOptionsRequest(URL, Action, rfcEmisor, rfcReceptor, total, uuid); + StatusCancelationOptionsRequest settings = new StatusCancelationOptionsRequest(URL, Action, rfcEmisor, rfcReceptor, total, uuid, null, 0); StatusCancelationRequest req = new StatusCancelationRequest(); return req.sendRequest(settings); } diff --git a/src/main/java/Services/Validate/SWValidateService.java b/src/main/java/Services/Validate/SWValidateService.java index 0a92be3..062f025 100644 --- a/src/main/java/Services/Validate/SWValidateService.java +++ b/src/main/java/Services/Validate/SWValidateService.java @@ -22,21 +22,29 @@ public SWValidateService(String user, String password, String URI) throws AuthEx public SWValidateService(String token, String URI) { super(token, URI); } + + public SWValidateService(String user, String password, String URI, String proxyHost, int proxyPort) throws AuthException { + super(user, password, URI, proxyHost, proxyPort); + } + + public SWValidateService(String token, String URI, String proxyHost, int proxyPort) { + super(token, URI, proxyHost, proxyPort); + } public IResponse ValidateXml(String xml) throws AuthException, GeneralException, IOException { - ValidateXmlOptionsRequest settings = new ValidateXmlOptionsRequest(getToken(), getURI(), xml); + ValidateXmlOptionsRequest settings = new ValidateXmlOptionsRequest(getToken(), getURI(), xml, getProxyHost(), getProxyPort()); ValidateXmlRequest req = new ValidateXmlRequest(); return req.sendRequest(settings); } public IResponse ValidateLrfc(String Lrfc) throws AuthException, GeneralException, IOException { - ValidateLrfcOptionsRequest settings = new ValidateLrfcOptionsRequest(getToken(), getURI(), Lrfc); + ValidateLrfcOptionsRequest settings = new ValidateLrfcOptionsRequest(getToken(), getURI(), Lrfc, getProxyHost(), getProxyPort()); ValidateLrfcRequest req = new ValidateLrfcRequest(); return req.sendRequest(settings); } public IResponse ValidateLco(String Lco) throws AuthException, GeneralException, IOException { - ValidateLcoOptionsRequest settings = new ValidateLcoOptionsRequest(getToken(), getURI(), Lco); + ValidateLcoOptionsRequest settings = new ValidateLcoOptionsRequest(getToken(), getURI(), Lco, getProxyHost(), getProxyPort()); ValidateLcoRequest req = new ValidateLcoRequest(); return req.sendRequest(settings); } diff --git a/src/main/java/Utils/Helpers/RequestHelper.java b/src/main/java/Utils/Helpers/RequestHelper.java index 7e5a867..61a6106 100644 --- a/src/main/java/Utils/Helpers/RequestHelper.java +++ b/src/main/java/Utils/Helpers/RequestHelper.java @@ -29,10 +29,10 @@ public static JSONArray buildJSONFromMap(Map map) throws General return mJSONArray; } - public static void setProxy(Builder build, String host, String port) throws GeneralException { + public static void setProxy(Builder build, String host, int port) throws GeneralException { if(host != null){ try { - HttpHost proxy = new HttpHost(host, Integer.parseInt(port)); + HttpHost proxy = new HttpHost(host, port); build.setProxy(proxy); } catch (Exception e) { throw new GeneralException(400, e.getMessage()); diff --git a/src/main/java/Utils/Requests/AcceptReject/AceptarRechazarCancelationRequest.java b/src/main/java/Utils/Requests/AcceptReject/AceptarRechazarCancelationRequest.java index c6fd4a2..407f245 100644 --- a/src/main/java/Utils/Requests/AcceptReject/AceptarRechazarCancelationRequest.java +++ b/src/main/java/Utils/Requests/AcceptReject/AceptarRechazarCancelationRequest.java @@ -48,7 +48,9 @@ public IResponse sendRequest(IRequest request) throws GeneralException, AuthExce try { CloseableHttpClient client = HttpClients.createDefault(); HttpPost httppost = new HttpPost(request.URI); - RequestHelper.setTimeOut(httppost, requestJSON.toString().length()); + RequestHelper.setTimeOut(request.options, requestJSON.toString().length()); + RequestHelper.setProxy(request.options, request.proxyHost, request.proxyPort); + httppost.setConfig(request.options.build()); httppost.setHeader(new BasicHeader("Authorization", "bearer " + request.Token)); httppost.addHeader(new BasicHeader("Content-Type", "application/json")); MultipartEntityBuilder builder = MultipartEntityBuilder.create(); @@ -106,7 +108,9 @@ public IResponse sendRequestPFX(IRequest request) throws GeneralException, AuthE try { CloseableHttpClient client = HttpClients.createDefault(); HttpPost httppost = new HttpPost(request.URI); - RequestHelper.setTimeOut(httppost, requestJSON.toString().length()); + RequestHelper.setTimeOut(request.options, requestJSON.toString().length()); + RequestHelper.setProxy(request.options, request.proxyHost, request.proxyPort); + httppost.setConfig(request.options.build()); httppost.setHeader(new BasicHeader("Authorization", "bearer " + request.Token)); httppost.addHeader(new BasicHeader("Content-Type", "application/json")); MultipartEntityBuilder builder = MultipartEntityBuilder.create(); @@ -160,7 +164,9 @@ public IResponse sendRequestXML(IRequest request) throws GeneralException, AuthE + xmlStr + "\r\n--" + boundary + "--"; CloseableHttpClient client = HttpClients.createDefault(); HttpPost httppost = new HttpPost(request.URI); - RequestHelper.setTimeOut(httppost, raw.length()); + RequestHelper.setTimeOut(request.options, raw.length()); + RequestHelper.setProxy(request.options, request.proxyHost, request.proxyPort); + httppost.setConfig(request.options.build()); httppost.setHeader(new BasicHeader("Authorization", "bearer " + request.Token)); httppost.addHeader(new BasicHeader("content-type", "multipart/form-data; boundary=" + boundary)); MultipartEntityBuilder builder = MultipartEntityBuilder.create(); @@ -209,7 +215,9 @@ public IResponse sendRequestUUID(IRequest request) throws ClientProtocolExceptio try { CloseableHttpClient client = HttpClients.createDefault(); HttpPost httppost = new HttpPost(request.URI); - RequestHelper.setTimeOut(httppost, 7000); + RequestHelper.setTimeOut(request.options, 7000); + RequestHelper.setProxy(request.options, request.proxyHost, request.proxyPort); + httppost.setConfig(request.options.build()); httppost.setHeader(new BasicHeader("Authorization", "bearer " + request.Token)); CloseableHttpResponse responseB = client.execute(httppost); diff --git a/src/main/java/Utils/Requests/AcceptReject/AceptarRechazarOptionsRequest.java b/src/main/java/Utils/Requests/AcceptReject/AceptarRechazarOptionsRequest.java index 20d282d..282d874 100644 --- a/src/main/java/Utils/Requests/AcceptReject/AceptarRechazarOptionsRequest.java +++ b/src/main/java/Utils/Requests/AcceptReject/AceptarRechazarOptionsRequest.java @@ -17,8 +17,8 @@ public class AceptarRechazarOptionsRequest extends IRequest{ private String xml; - public AceptarRechazarOptionsRequest(String token, String URI, Map uuids, String password_csd, String rfc, String b64Cer, String b64Key) { - super(token, URI+ Constants.ACEPTAR_RECHAZAR_CANCELACION_CSD_PATH); + public AceptarRechazarOptionsRequest(String token, String URI, Map uuids, String password_csd, String rfc, String b64Cer, String b64Key, String proxyHost, int proxyPort) { + super(token, URI+ Constants.ACEPTAR_RECHAZAR_CANCELACION_CSD_PATH, proxyHost, proxyPort); this.uuids = uuids; this.password_csd = password_csd; this.rfc = rfc; @@ -26,20 +26,20 @@ public AceptarRechazarOptionsRequest(String token, String URI, Map uuids, String password_csd, String rfc, String b64Pfx) { - super(token, URI+ Constants.ACEPTAR_RECHAZAR_CANCELACION_PFX_PATH); + public AceptarRechazarOptionsRequest(String token, String URI, Map uuids, String password_csd, String rfc, String b64Pfx, String proxyHost, int proxyPort) { + super(token, URI+ Constants.ACEPTAR_RECHAZAR_CANCELACION_PFX_PATH, proxyHost, proxyPort); this.uuids = uuids; this.password_csd = password_csd; this.rfc = rfc; this.b64Pfx = b64Pfx; } - public AceptarRechazarOptionsRequest(String token, String URI, String xml) { - super(token, URI+ Constants.ACEPTAR_RECHAZAR_CANCELACION_XML_PATH); + public AceptarRechazarOptionsRequest(String token, String URI, String xml, String proxyHost, int proxyPort) { + super(token, URI+ Constants.ACEPTAR_RECHAZAR_CANCELACION_XML_PATH, proxyHost, proxyPort); this.xml = xml; } - public AceptarRechazarOptionsRequest(String token, String URI, String uuid, String rfc, String action) { - super(token, URI+ Constants.ACEPTAR_RECHAZAR_CANCELACION_UUID_PATH+rfc+"/"+uuid+"/"+action); + public AceptarRechazarOptionsRequest(String token, String URI, String uuid, String rfc, String action, String proxyHost, int proxyPort) { + super(token, URI+ Constants.ACEPTAR_RECHAZAR_CANCELACION_UUID_PATH+rfc+"/"+uuid+"/"+action, proxyHost, proxyPort); this.uuid = uuid; this.rfc = rfc; } diff --git a/src/main/java/Utils/Requests/Authentication/AuthOptionsRequest.java b/src/main/java/Utils/Requests/Authentication/AuthOptionsRequest.java index bd77283..4602bd5 100644 --- a/src/main/java/Utils/Requests/Authentication/AuthOptionsRequest.java +++ b/src/main/java/Utils/Requests/Authentication/AuthOptionsRequest.java @@ -15,8 +15,8 @@ public void setPortHost(String portHost) { PortHost = portHost; } - public AuthOptionsRequest(String URI, String user, String password) { - super(URI+ Constants.AUTH_PATH, user, password); + public AuthOptionsRequest(String URI, String user, String password, String proxyHost, int proxyPort) { + super(URI+ Constants.AUTH_PATH, user, password, proxyHost, proxyPort); } public String getProxyHost() { @@ -26,11 +26,4 @@ public String getProxyHost() { public String getPortHost() { return PortHost; } - - public AuthOptionsRequest(String URI, String user, String password, String hostProxy, String portProxy) { - - super(URI+ Constants.AUTH_PATH, user, password); - this.setPortHost(portProxy); - this.setProxyHost(hostProxy); - } } diff --git a/src/main/java/Utils/Requests/Authentication/AuthRequest.java b/src/main/java/Utils/Requests/Authentication/AuthRequest.java index f30f8cc..7aa3f74 100644 --- a/src/main/java/Utils/Requests/Authentication/AuthRequest.java +++ b/src/main/java/Utils/Requests/Authentication/AuthRequest.java @@ -2,6 +2,7 @@ import Exceptions.AuthException; import Exceptions.GeneralException; +import Utils.Helpers.RequestHelper; import Utils.Requests.IRequest; import Utils.Requests.IRequestor; import Utils.Responses.IResponse; @@ -31,7 +32,9 @@ public IResponse sendRequest(IRequest request) throws GeneralException, AuthExce HttpPost httppost = new HttpPost(request.URI); httppost.setHeader("user", request.User); httppost.addHeader("password", request.Password); - + RequestHelper.setTimeOut(request.options, 3000); + RequestHelper.setProxy(request.options, request.proxyHost, request.proxyPort); + httppost.setConfig(request.options.build()); CloseableHttpResponse responseB = client.execute(httppost); HttpEntity entity = responseB.getEntity(); String responseString = EntityUtils.toString(entity, "UTF-8"); diff --git a/src/main/java/Utils/Requests/BalanceAccount/BalanceAcctOptionsRequest.java b/src/main/java/Utils/Requests/BalanceAccount/BalanceAcctOptionsRequest.java index 540a7a8..16213a6 100644 --- a/src/main/java/Utils/Requests/BalanceAccount/BalanceAcctOptionsRequest.java +++ b/src/main/java/Utils/Requests/BalanceAccount/BalanceAcctOptionsRequest.java @@ -5,8 +5,8 @@ public class BalanceAcctOptionsRequest extends IRequest { - public BalanceAcctOptionsRequest(String token, String URI) { - super(token, URI+ Constants.BALANCE_ACCOUNT_PATH); + public BalanceAcctOptionsRequest(String token, String URI, String proxyHost, int proxyPort) { + super(token, URI+ Constants.BALANCE_ACCOUNT_PATH, proxyHost, proxyPort); } } diff --git a/src/main/java/Utils/Requests/BalanceAccount/BalanceAcctRequest.java b/src/main/java/Utils/Requests/BalanceAccount/BalanceAcctRequest.java index ae2a722..ceafd05 100644 --- a/src/main/java/Utils/Requests/BalanceAccount/BalanceAcctRequest.java +++ b/src/main/java/Utils/Requests/BalanceAccount/BalanceAcctRequest.java @@ -2,6 +2,7 @@ import Exceptions.AuthException; import Exceptions.GeneralException; +import Utils.Helpers.RequestHelper; import Utils.Requests.IRequest; import Utils.Requests.IRequestor; import Utils.Responses.IResponse; @@ -24,6 +25,9 @@ public IResponse sendRequest(IRequest request) throws GeneralException, AuthExce CloseableHttpClient client = HttpClients.createDefault(); HttpGet httpget = new HttpGet(request.URI); httpget.setHeader("Authorization", "bearer " + request.Token); + RequestHelper.setTimeOut(request.options, 3500); + RequestHelper.setProxy(request.options, request.proxyHost, request.proxyPort); + httpget.setConfig(request.options.build()); CloseableHttpResponse responseB = client.execute(httpget); HttpEntity entity = responseB.getEntity(); String responseString = EntityUtils.toString(entity, "UTF-8"); diff --git a/src/main/java/Utils/Requests/Cancelation/CancelationOptionsRequest.java b/src/main/java/Utils/Requests/Cancelation/CancelationOptionsRequest.java index e05b35b..7289f30 100644 --- a/src/main/java/Utils/Requests/Cancelation/CancelationOptionsRequest.java +++ b/src/main/java/Utils/Requests/Cancelation/CancelationOptionsRequest.java @@ -10,67 +10,36 @@ public class CancelationOptionsRequest extends IRequest{ private String b64Cer; private String b64key; private String b64Pfx; - private String xml; - private String ProxyHost; - private String PortHost; - public CancelationOptionsRequest(String token, String URI, String uuid, String password_csd, String rfc, String b64Cer, String b64Key) { - super(token, URI+ Constants.CANCELATION_CSD_PATH); + public CancelationOptionsRequest(String token, String URI, String uuid, String password_csd, String rfc, String b64Cer, String b64Key, String proxyHost, int proxyPort) { + super(token, URI+ Constants.CANCELATION_CSD_PATH, proxyHost, proxyPort); this.uuid = uuid; this.password_csd = password_csd; this.rfc = rfc; this.b64Cer = b64Cer; this.b64key = b64Key; } - - public CancelationOptionsRequest(String token, String URI, String uuid, String password_csd, String rfc, String b64Cer, String b64Key, String proxyHost, String portHst) { - super(token, URI+ Constants.CANCELATION_CSD_PATH); - this.uuid = uuid; - this.password_csd = password_csd; - this.rfc = rfc; - this.b64Cer = b64Cer; - this.b64key = b64Key; - ProxyHost = proxyHost; - PortHost = portHst; - } - public CancelationOptionsRequest(String token, String URI, String uuid, String password_csd, String rfc, String b64Pfx) { - super(token, URI+ Constants.CANCELATION_PFX_PATH); + public CancelationOptionsRequest(String token, String URI, String uuid, String password_csd, String rfc, String b64Pfx, String proxyHost, int proxyPort) { + super(token, URI+ Constants.CANCELATION_PFX_PATH, proxyHost, proxyPort); this.uuid = uuid; this.password_csd = password_csd; this.rfc = rfc; this.b64Pfx = b64Pfx; } - public CancelationOptionsRequest(String token, String URI, String xml) { - super(token, URI+ Constants.CANCELATION_XML_PATH); + public CancelationOptionsRequest(String token, String URI, String xml, String proxyHost, int proxyPort) { + super(token, URI+ Constants.CANCELATION_XML_PATH, proxyHost, proxyPort); this.xml = xml; } - public CancelationOptionsRequest(String token, String URI, String uuid, String rfc) { - super(token, URI+ Constants.CANCELATION_UUID_PATH+rfc+"/"+uuid); + public CancelationOptionsRequest(String token, String URI, String uuid, String rfc, String proxyHost, int proxyPort) { + super(token, URI + Constants.CANCELATION_UUID_PATH + rfc + "/" + uuid, proxyHost, proxyPort); this.uuid = uuid; this.rfc = rfc; } - public String getProxyHost() { - return ProxyHost; - } - - public String getPortHost() { - return PortHost; - } - - public CancelationOptionsRequest(String token, String URI, String xml, String proxyHost, String portHst) { - super(token, URI+ Constants.CANCELATION_XML_PATH); - this.xml = xml; - ProxyHost = proxyHost; - PortHost = portHst; - - - } - public String getUuid() { return uuid; } diff --git a/src/main/java/Utils/Requests/Cancelation/CancelationRequest.java b/src/main/java/Utils/Requests/Cancelation/CancelationRequest.java index c7d5935..ed3e4c4 100644 --- a/src/main/java/Utils/Requests/Cancelation/CancelationRequest.java +++ b/src/main/java/Utils/Requests/Cancelation/CancelationRequest.java @@ -48,7 +48,9 @@ public IResponse sendRequest(IRequest request) throws GeneralException, AuthExce + ((CancelationOptionsRequest) request).getB64key() + "\"\r\n}"); httppost.setEntity(builder.build()); httppost.setEntity(sEntity); - RequestHelper.setTimeOut(httppost, (int) sEntity.getContentLength()); + RequestHelper.setTimeOut(request.options, (int) sEntity.getContentLength()); + RequestHelper.setProxy(request.options, request.proxyHost, request.proxyPort); + httppost.setConfig(request.options.build()); CloseableHttpResponse responseB = client.execute(httppost); HttpEntity entity = responseB.getEntity(); String responseString = EntityUtils.toString(entity, "UTF-8"); @@ -91,7 +93,9 @@ public IResponse sendRequest(IRequest request, boolean isXml) throws GeneralExce + xmlStr + "\r\n--" + boundary + "--"; CloseableHttpClient client = HttpClients.createDefault(); HttpPost httppost = new HttpPost(request.URI); - RequestHelper.setTimeOut(httppost, raw.length()); + RequestHelper.setTimeOut(request.options, raw.length()); + RequestHelper.setProxy(request.options, request.proxyHost, request.proxyPort); + httppost.setConfig(request.options.build()); httppost.setHeader(new BasicHeader("Authorization", "bearer " + request.Token)); httppost.addHeader(new BasicHeader("content-type", "multipart/form-data; boundary=" + boundary)); MultipartEntityBuilder builder = MultipartEntityBuilder.create(); @@ -152,7 +156,9 @@ public IResponse sendRequestPfx(IRequest request) throws ClientProtocolException + ((CancelationOptionsRequest) request).getB64Pfx() + "\"\r\n}"); httppost.setEntity(builder.build()); httppost.setEntity(sEntity); - RequestHelper.setTimeOut(httppost, (int) sEntity.getContentLength()); + RequestHelper.setTimeOut(request.options, (int) sEntity.getContentLength()); + RequestHelper.setProxy(request.options, request.proxyHost, request.proxyPort); + httppost.setConfig(request.options.build()); CloseableHttpResponse responseB = client.execute(httppost); HttpEntity entity = responseB.getEntity(); String responseString = EntityUtils.toString(entity, "UTF-8"); @@ -189,10 +195,10 @@ public IResponse sendRequestUuid(IRequest request) throws ClientProtocolExceptio try { CloseableHttpClient client = HttpClients.createDefault(); HttpPost httppost = new HttpPost(request.URI); - RequestHelper.setTimeOut(httppost, 3000); - + RequestHelper.setTimeOut(request.options, 4000); + RequestHelper.setProxy(request.options, request.proxyHost, request.proxyPort); + httppost.setConfig(request.options.build()); httppost.setHeader(new BasicHeader("Authorization", "bearer " + request.Token)); - CloseableHttpResponse responseB = client.execute(httppost); HttpEntity entity = responseB.getEntity(); diff --git a/src/main/java/Utils/Requests/Csd/CsdOptionsRequest.java b/src/main/java/Utils/Requests/Csd/CsdOptionsRequest.java index a7260d1..7f1e9d8 100644 --- a/src/main/java/Utils/Requests/Csd/CsdOptionsRequest.java +++ b/src/main/java/Utils/Requests/Csd/CsdOptionsRequest.java @@ -9,18 +9,14 @@ public class CsdOptionsRequest extends IRequest { private String passwordCsd; private String certificateType; private boolean isActive; - private String proxyHost; - private String proxyPort; - public CsdOptionsRequest(String token, String URI, String b64Cer, String b64Key, String passwordCsd, String certificateType, boolean isActive, String proxyHost, String proxyPort) { - super(token, URI+ Constants.SAVE_CSD); + public CsdOptionsRequest(String token, String URI, String b64Cer, String b64Key, String passwordCsd, String certificateType, boolean isActive, String proxyHost, int proxyPort) { + super(token, URI+ Constants.SAVE_CSD, proxyHost, proxyPort); this.b64Cer = b64Cer; this.b64Key = b64Key; this.passwordCsd = passwordCsd; this.certificateType = certificateType; this.isActive = isActive; - this.proxyHost = proxyHost; - this.proxyPort = proxyPort; } public String getB64Cer() { @@ -42,12 +38,4 @@ public String getCertificateType() { public boolean getIsActive() { return isActive; } - - public String getProxyHost() { - return proxyHost; - } - - public String getProxyPort() { - return proxyPort; - } } diff --git a/src/main/java/Utils/Requests/Csd/CsdRequest.java b/src/main/java/Utils/Requests/Csd/CsdRequest.java index d403ddc..249f1dd 100644 --- a/src/main/java/Utils/Requests/Csd/CsdRequest.java +++ b/src/main/java/Utils/Requests/Csd/CsdRequest.java @@ -37,7 +37,7 @@ public IResponse sendRequest(IRequest request) throws GeneralException, AuthExce CloseableHttpClient client = HttpClients.createDefault(); HttpPost httppost = new HttpPost(request.URI); RequestHelper.setTimeOut(request.options, requestJSON.toString().length()); - RequestHelper.setProxy(request.options, ((CsdOptionsRequest) request).getProxyHost(), ((CsdOptionsRequest) request).getProxyPort()); + RequestHelper.setProxy(request.options, request.proxyHost, request.proxyPort); httppost.setConfig(request.options.build()); httppost.setHeader(new BasicHeader("Authorization", "bearer " + request.Token)); httppost.addHeader(new BasicHeader("Content-Type", "application/json")); diff --git a/src/main/java/Utils/Requests/IRequest.java b/src/main/java/Utils/Requests/IRequest.java index b79a8a9..b4115d1 100644 --- a/src/main/java/Utils/Requests/IRequest.java +++ b/src/main/java/Utils/Requests/IRequest.java @@ -9,47 +9,52 @@ public abstract class IRequest { public String Password; public String version; public String xml; + public boolean isb64; public Builder options = RequestConfig.custom(); + public String proxyHost; + public int proxyPort; - public IRequest(String URI, String user, String password, String version, boolean isb64) { + public IRequest(String URI, String user, String password, String version, boolean isb64, String proxyHost, int proxyPort) { this.URI = URI; User = user; Password = password; this.version = version; this.isb64 = isb64; + this.proxyHost = proxyHost; + this.proxyPort = proxyPort; } - public IRequest(String token, String URI, String version, boolean isb64) { + public IRequest(String token, String URI, String version, boolean isb64, String proxyHost, int proxyPort) { Token = token; this.URI = URI; this.version = version; this.isb64 = isb64; + this.proxyHost = proxyHost; + this.proxyPort = proxyPort; } - - public boolean isb64; - - public IRequest(String token, String URI, boolean isb64) { - Token = token; - this.URI = URI; - this.isb64 = isb64; - } - - public IRequest(String URI, String user, String password) { + + public IRequest(String URI, String user, String password, String proxyHost, int proxyPort) { this.URI = URI; User = user; Password = password; + this.proxyHost = proxyHost; + this.proxyPort = proxyPort; } - public IRequest(String token, String URI, String xml, String version) { + public IRequest(String token, String URI, String xml, String version, String proxyHost, int proxyPort) { Token = token; this.URI = URI; this.version = version; this.xml = xml; + this.proxyHost = proxyHost; + this.proxyPort = proxyPort; } - public IRequest(String token, String URI) { + public IRequest(String token, String URI, String proxyHost, int proxyPort) { Token = token; this.URI = URI; + this.proxyHost = proxyHost; + this.proxyPort = proxyPort; } } diff --git a/src/main/java/Utils/Requests/Issue/IssueOptionsRequest.java b/src/main/java/Utils/Requests/Issue/IssueOptionsRequest.java index a0cc5e0..81eb25a 100644 --- a/src/main/java/Utils/Requests/Issue/IssueOptionsRequest.java +++ b/src/main/java/Utils/Requests/Issue/IssueOptionsRequest.java @@ -11,13 +11,13 @@ public String getXml() { return xml; } - public IssueOptionsRequest(String token, String URI, String xml, String version) { - super(token, URI+ Constants.ISSUE_JSON_PATH+version, xml, version); + public IssueOptionsRequest(String token, String URI, String xml, String version, String proxyHost, int proxyPort) { + super(token, URI + Constants.ISSUE_JSON_PATH + version, xml, version, proxyHost, proxyPort); this.xml = xml; this.version = version; } - public IssueOptionsRequest(String token, String URI, String xml, String version, boolean isXml) { - super(token, URI+ Constants.ISSUE_XML_PATH+version, xml, version); + public IssueOptionsRequest(String token, String URI, String xml, String version, boolean isXml, String proxyHost, int proxyPort) { + super(token, URI + Constants.ISSUE_XML_PATH + version, xml, version, proxyHost, proxyPort); this.xml = xml; this.version = version; } diff --git a/src/main/java/Utils/Requests/Issue/IssueRequest.java b/src/main/java/Utils/Requests/Issue/IssueRequest.java index ab3c1a7..8be0bd0 100644 --- a/src/main/java/Utils/Requests/Issue/IssueRequest.java +++ b/src/main/java/Utils/Requests/Issue/IssueRequest.java @@ -35,7 +35,9 @@ public IResponse sendRequest(IRequest request) throws GeneralException, AuthExce CloseableHttpClient client = HttpClients.createDefault(); HttpPost httppost = new HttpPost(request.URI); - RequestHelper.setTimeOut(httppost, xmlStr.length()); + RequestHelper.setTimeOut(request.options, xmlStr.length()); + RequestHelper.setProxy(request.options, request.proxyHost, request.proxyPort); + httppost.setConfig(request.options.build()); httppost.setHeader("Authorization", "bearer " + request.Token); httppost.addHeader("Content-Type", "application/jsontoxml"); StringEntity stringEntity = new StringEntity(xmlStr,ContentType.create("application/json", Consts.UTF_8)); @@ -71,7 +73,9 @@ public IResponse sendRequestXml(IRequest request) throws GeneralException, AuthE CloseableHttpClient client = HttpClients.createDefault(); HttpPost httppost = new HttpPost(request.URI); - RequestHelper.setTimeOut(httppost, raw.length()); + RequestHelper.setTimeOut(request.options, raw.length()); + RequestHelper.setProxy(request.options, request.proxyHost, request.proxyPort); + httppost.setConfig(request.options.build()); httppost.setHeader("Authorization", "bearer " + request.Token); httppost.addHeader("Content-Type", "multipart/form-data; boundary=" + boundary); httppost.addHeader("Content-Disposition", "form-data; name=xml; filename=xml"); diff --git a/src/main/java/Utils/Requests/Pdf/PdfOptionsRequest.java b/src/main/java/Utils/Requests/Pdf/PdfOptionsRequest.java index 615b3da..7707d0e 100644 --- a/src/main/java/Utils/Requests/Pdf/PdfOptionsRequest.java +++ b/src/main/java/Utils/Requests/Pdf/PdfOptionsRequest.java @@ -8,17 +8,17 @@ public class PdfOptionsRequest extends IRequest { private String templateId; private String extras; - public PdfOptionsRequest(String token, String URI, String xml) { - super(token, URI+ Constants.GENERATE_PDF_PATH); + public PdfOptionsRequest(String token, String URI, String xml, String proxyHost, int proxyPort) { + super(token, URI + Constants.GENERATE_PDF_PATH, proxyHost, proxyPort); this.xml = xml; } - public PdfOptionsRequest(String token, String URI, String xml, String extras) { - super(token, URI+ Constants.GENERATE_PDF_PATH); + public PdfOptionsRequest(String token, String URI, String xml, String extras, String proxyHost, int proxyPort) { + super(token, URI + Constants.GENERATE_PDF_PATH, proxyHost, proxyPort); this.xml = xml; this.extras = extras; } - public PdfOptionsRequest(String token, String URI, String xml, String extras, String templateId) { - super(token, URI+ Constants.GENERATE_PDF_PATH); + public PdfOptionsRequest(String token, String URI, String xml, String extras, String templateId, String proxyHost, int proxyPort) { + super(token, URI + Constants.GENERATE_PDF_PATH, proxyHost, proxyPort); this.xml = xml; this.extras = extras; this.templateId = templateId; diff --git a/src/main/java/Utils/Requests/Pdf/PdfRequest.java b/src/main/java/Utils/Requests/Pdf/PdfRequest.java index 166c57c..2bd7b7b 100644 --- a/src/main/java/Utils/Requests/Pdf/PdfRequest.java +++ b/src/main/java/Utils/Requests/Pdf/PdfRequest.java @@ -5,7 +5,6 @@ import java.util.UUID; import org.apache.http.HttpEntity; -import org.apache.http.client.config.RequestConfig; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.ContentType; @@ -19,6 +18,7 @@ import Exceptions.AuthException; import Exceptions.GeneralException; +import Utils.Helpers.RequestHelper; import Utils.Requests.IRequest; import Utils.Requests.IRequestor; import Utils.Requests.Pdf.PdfOptionsRequest; @@ -34,13 +34,9 @@ public IResponse sendRequest(IRequest request) throws GeneralException, AuthExce String raw = "--"+boundary+"\r\nContent-Disposition: form-data; name=file; filename=file\r\nContent-Type: application/xml\r\n\r\n"+xmlStr+"\r\n--"+boundary+"--"; CloseableHttpClient client = HttpClients.createDefault(); HttpPost http = new HttpPost(request.URI); - int timeOut = raw.length() * 5; - RequestConfig requestConfig = RequestConfig.custom() - .setSocketTimeout(timeOut) - .setConnectTimeout(timeOut) - .setConnectionRequestTimeout(timeOut) - .build(); - http.setConfig(requestConfig); + RequestHelper.setTimeOut(request.options, xmlStr.length()); + RequestHelper.setProxy(request.options, request.proxyHost, request.proxyPort); + http.setConfig(request.options.build()); http.setHeader("Authorization", "Bearer " + request.Token); http.addHeader("Content-Type", "multipart/form-data; boundary="+boundary); if(((PdfOptionsRequest) request).getTemplateId() != null && !((PdfOptionsRequest) request).getTemplateId().isEmpty()) { diff --git a/src/main/java/Utils/Requests/Pendings/PendientesCancelarOptionsRequest.java b/src/main/java/Utils/Requests/Pendings/PendientesCancelarOptionsRequest.java index 1fe7ddd..2055d2c 100644 --- a/src/main/java/Utils/Requests/Pendings/PendientesCancelarOptionsRequest.java +++ b/src/main/java/Utils/Requests/Pendings/PendientesCancelarOptionsRequest.java @@ -4,7 +4,7 @@ import Utils.Requests.IRequest; public class PendientesCancelarOptionsRequest extends IRequest { - public PendientesCancelarOptionsRequest(String token, String URI, String rfc) { - super(token, URI+ Constants.PENDIENTES_CANCELAR_PATH+rfc); + public PendientesCancelarOptionsRequest(String token, String URI, String rfc, String proxyHost, int proxyPort) { + super(token, URI + Constants.PENDIENTES_CANCELAR_PATH + rfc, proxyHost, proxyPort); } } diff --git a/src/main/java/Utils/Requests/Pendings/PendientesCancelarRequest.java b/src/main/java/Utils/Requests/Pendings/PendientesCancelarRequest.java index 43d4887..2c50025 100644 --- a/src/main/java/Utils/Requests/Pendings/PendientesCancelarRequest.java +++ b/src/main/java/Utils/Requests/Pendings/PendientesCancelarRequest.java @@ -28,7 +28,9 @@ public IResponse sendRequest(IRequest request) try { CloseableHttpClient client = HttpClients.createDefault(); HttpGet httpget = new HttpGet(request.URI); - RequestHelper.setTimeOut(httpget, 7000); + RequestHelper.setTimeOut(request.options, 7000); + RequestHelper.setProxy(request.options, request.proxyHost, request.proxyPort); + httpget.setConfig(request.options.build()); httpget.setHeader("Authorization", "bearer " + request.Token); CloseableHttpResponse responseB = client.execute(httpget); HttpEntity entity = responseB.getEntity(); diff --git a/src/main/java/Utils/Requests/Relations/CfdiRelacionadosOptionsRequest.java b/src/main/java/Utils/Requests/Relations/CfdiRelacionadosOptionsRequest.java index 5eab8b2..9a99c18 100644 --- a/src/main/java/Utils/Requests/Relations/CfdiRelacionadosOptionsRequest.java +++ b/src/main/java/Utils/Requests/Relations/CfdiRelacionadosOptionsRequest.java @@ -12,8 +12,8 @@ public class CfdiRelacionadosOptionsRequest extends IRequest{ private String b64Pfx; private String xml; - public CfdiRelacionadosOptionsRequest(String token, String URI, String uuid, String password_csd, String rfc, String b64Cer, String b64Key) { - super(token, URI+ Constants.RELACIONADOS_CSD_PATH); + public CfdiRelacionadosOptionsRequest(String token, String URI, String uuid, String password_csd, String rfc, String b64Cer, String b64Key, String proxyHost, int proxyPort) { + super(token, URI + Constants.RELACIONADOS_CSD_PATH, proxyHost, proxyPort); this.uuid = uuid; this.password_csd = password_csd; this.rfc = rfc; @@ -21,22 +21,22 @@ public CfdiRelacionadosOptionsRequest(String token, String URI, String uuid, Str this.b64key = b64Key; } - public CfdiRelacionadosOptionsRequest(String token, String URI, String uuid, String password_csd, String rfc, String b64Pfx) { - super(token, URI+ Constants.RELACIONADOS_PFX_PATH); + public CfdiRelacionadosOptionsRequest(String token, String URI, String uuid, String password_csd, String rfc, String b64Pfx, String proxyHost, int proxyPort) { + super(token, URI + Constants.RELACIONADOS_PFX_PATH, proxyHost, proxyPort); this.uuid = uuid; this.password_csd = password_csd; this.rfc = rfc; this.b64Pfx = b64Pfx; } - public CfdiRelacionadosOptionsRequest(String token, String URI, String uuid, String rfc) { - super(token, URI+ Constants.RELACIONADOS_UUID_PATH+rfc+"/"+uuid); + public CfdiRelacionadosOptionsRequest(String token, String URI, String uuid, String rfc, String proxyHost, int proxyPort) { + super(token, URI + Constants.RELACIONADOS_UUID_PATH + rfc + "/" + uuid, proxyHost, proxyPort); this.uuid = uuid; this.rfc = rfc; } - public CfdiRelacionadosOptionsRequest(String token, String URI, String xml) { - super(token, URI+ Constants.RELACIONADOS_XML_PATH); + public CfdiRelacionadosOptionsRequest(String token, String URI, String xml, String proxyHost, int proxyPort) { + super(token, URI + Constants.RELACIONADOS_XML_PATH, proxyHost, proxyPort); this.xml = xml; } diff --git a/src/main/java/Utils/Requests/Relations/CfdiRelacionadosRequest.java b/src/main/java/Utils/Requests/Relations/CfdiRelacionadosRequest.java index 60485a2..65cab24 100644 --- a/src/main/java/Utils/Requests/Relations/CfdiRelacionadosRequest.java +++ b/src/main/java/Utils/Requests/Relations/CfdiRelacionadosRequest.java @@ -43,7 +43,9 @@ public IResponse sendRequest(IRequest request) throws GeneralException, AuthExce requestJSON.put("b64Key", ((CfdiRelacionadosOptionsRequest) request).getB64key()); CloseableHttpClient client = HttpClients.createDefault(); HttpPost httppost = new HttpPost(request.URI); - RequestHelper.setTimeOut(httppost, requestJSON.toString().length()); + RequestHelper.setTimeOut(request.options, requestJSON.toString().length()); + RequestHelper.setProxy(request.options, request.proxyHost, request.proxyPort); + httppost.setConfig(request.options.build()); httppost.setHeader(new BasicHeader("Authorization", "bearer " + request.Token)); httppost.addHeader(new BasicHeader("Content-Type", "application/json")); MultipartEntityBuilder builder = MultipartEntityBuilder.create(); @@ -118,7 +120,9 @@ public IResponse sendRequestPFX(IRequest request) throws ClientProtocolException requestJSON.put("b64Pfx", ((CfdiRelacionadosOptionsRequest) request).getB64Pfx()); CloseableHttpClient client = HttpClients.createDefault(); HttpPost httppost = new HttpPost(request.URI); - RequestHelper.setTimeOut(httppost, requestJSON.toString().length()); + RequestHelper.setTimeOut(request.options, requestJSON.toString().length()); + RequestHelper.setProxy(request.options, request.proxyHost, request.proxyPort); + httppost.setConfig(request.options.build()); httppost.setHeader(new BasicHeader("Authorization", "bearer " + request.Token)); httppost.addHeader(new BasicHeader("Content-Type", "application/json")); MultipartEntityBuilder builder = MultipartEntityBuilder.create(); @@ -193,7 +197,9 @@ public IResponse sendRequestXML(IRequest request) throws GeneralException, AuthE + xmlStr + "\r\n--" + boundary + "--"; CloseableHttpClient client = HttpClients.createDefault(); HttpPost httppost = new HttpPost(request.URI); - RequestHelper.setTimeOut(httppost, raw.length()); + RequestHelper.setTimeOut(request.options, raw.length()); + RequestHelper.setProxy(request.options, request.proxyHost, request.proxyPort); + httppost.setConfig(request.options.build()); httppost.setHeader(new BasicHeader("Authorization", "bearer " + request.Token)); httppost.addHeader(new BasicHeader("content-type", "multipart/form-data; boundary=" + boundary)); MultipartEntityBuilder builder = MultipartEntityBuilder.create(); @@ -264,7 +270,9 @@ public IResponse sendRequestUUID(IRequest request) throws ClientProtocolExceptio try { CloseableHttpClient client = HttpClients.createDefault(); HttpPost httppost = new HttpPost(request.URI); - RequestHelper.setTimeOut(httppost, 7000); + RequestHelper.setTimeOut(request.options, 7000); + RequestHelper.setProxy(request.options, request.proxyHost, request.proxyPort); + httppost.setConfig(request.options.build()); httppost.setHeader(new BasicHeader("Authorization", "bearer " + request.Token)); CloseableHttpResponse responseB = client.execute(httppost); diff --git a/src/main/java/Utils/Requests/Stamp/StampOptionsRequest.java b/src/main/java/Utils/Requests/Stamp/StampOptionsRequest.java index 3afa9b8..61a83b1 100644 --- a/src/main/java/Utils/Requests/Stamp/StampOptionsRequest.java +++ b/src/main/java/Utils/Requests/Stamp/StampOptionsRequest.java @@ -5,36 +5,21 @@ public class StampOptionsRequest extends IRequest { private String xml; - private String proxyHost; - private String proxyPort; - public StampOptionsRequest(String token, String URI, String xml, String version, boolean isb64, String proxyHost, String proxyPort) { + public StampOptionsRequest(String token, String URI, String xml, String version, boolean isb64, String proxyHost, int proxyPort) { - super(token, URI + Constants.STAMP_PATH + version + "/b64", version, isb64); + super(token, URI + Constants.STAMP_PATH + version + "/b64", version, isb64, proxyHost, proxyPort); this.xml = xml; this.version = version; - this.proxyHost = proxyHost; - this.proxyPort = proxyPort; } - public StampOptionsRequest(String token, String URI, String xml, String version, String proxyHost, String proxyPort) { - super(token, URI + Constants.STAMP_PATH + version, xml, version); + public StampOptionsRequest(String token, String URI, String xml, String version, String proxyHost, int proxyPort) { + super(token, URI + Constants.STAMP_PATH + version, xml, version, proxyHost, proxyPort); this.xml = xml; this.version = version; - this.proxyHost = proxyHost; - this.proxyPort = proxyPort; } public String getXml() { return xml; } - - public String getProxyHost() { - return proxyHost; - } - - public String getProxyPort() { - return proxyPort; - } - } \ No newline at end of file diff --git a/src/main/java/Utils/Requests/Stamp/StampRequest.java b/src/main/java/Utils/Requests/Stamp/StampRequest.java index cc6df89..e047122 100644 --- a/src/main/java/Utils/Requests/Stamp/StampRequest.java +++ b/src/main/java/Utils/Requests/Stamp/StampRequest.java @@ -37,7 +37,7 @@ public IResponse sendRequest(IRequest request) throws GeneralException, AuthExce CloseableHttpClient client = HttpClients.createDefault(); HttpPost httppost = new HttpPost(request.URI); RequestHelper.setTimeOut(request.options, raw.length()); - RequestHelper.setProxy(request.options, ((StampOptionsRequest) request).getProxyHost(), ((StampOptionsRequest) request).getProxyPort()); + RequestHelper.setProxy(request.options, request.proxyHost, request.proxyPort); httppost.setConfig(request.options.build()); httppost.setHeader("Authorization", "bearer " + request.Token); httppost.addHeader("Content-Type", "multipart/form-data; boundary=" + boundary); diff --git a/src/main/java/Utils/Requests/StatusCfdi/StatusCancelationOptionsRequest.java b/src/main/java/Utils/Requests/StatusCfdi/StatusCancelationOptionsRequest.java index 0ea9847..f776624 100644 --- a/src/main/java/Utils/Requests/StatusCfdi/StatusCancelationOptionsRequest.java +++ b/src/main/java/Utils/Requests/StatusCfdi/StatusCancelationOptionsRequest.java @@ -9,8 +9,8 @@ public class StatusCancelationOptionsRequest extends IRequest{ private String uuid; private String action; - public StatusCancelationOptionsRequest(String URI, String action, String rfcEmisor, String rfcReceptor, String total, String uuid) { - super("",URI); + public StatusCancelationOptionsRequest(String URI, String action, String rfcEmisor, String rfcReceptor, String total, String uuid, String proxyHost, int proxyPort) { + super("", URI, proxyHost, proxyPort); this.rfcEmisor = rfcEmisor; this.rfcReceptor = rfcReceptor; this.total = total; diff --git a/src/main/java/Utils/Requests/Validate/ValidateLcoOptionsRequest.java b/src/main/java/Utils/Requests/Validate/ValidateLcoOptionsRequest.java index 1549e14..6fc0f42 100644 --- a/src/main/java/Utils/Requests/Validate/ValidateLcoOptionsRequest.java +++ b/src/main/java/Utils/Requests/Validate/ValidateLcoOptionsRequest.java @@ -4,10 +4,8 @@ import Utils.Requests.IRequest; public class ValidateLcoOptionsRequest extends IRequest { - private String lco; - public ValidateLcoOptionsRequest(String token, String URI, String Lco) { - super(token, URI+ Constants.VALIDATE_LCO_PATH+Lco); - this.lco = Lco; + public ValidateLcoOptionsRequest(String token, String URI, String Lco, String proxyHost, int proxyPort) { + super(token, URI + Constants.VALIDATE_LCO_PATH + Lco, proxyHost, proxyPort); } } \ No newline at end of file diff --git a/src/main/java/Utils/Requests/Validate/ValidateLcoRequest.java b/src/main/java/Utils/Requests/Validate/ValidateLcoRequest.java index 11abd3c..5f172c1 100644 --- a/src/main/java/Utils/Requests/Validate/ValidateLcoRequest.java +++ b/src/main/java/Utils/Requests/Validate/ValidateLcoRequest.java @@ -25,7 +25,9 @@ public IResponse sendRequest(IRequest request) throws GeneralException, AuthExce try { CloseableHttpClient client = HttpClients.createDefault(); HttpGet http = new HttpGet(request.URI); - RequestHelper.setTimeOut(http, 7000); + RequestHelper.setTimeOut(request.options, 7000); + RequestHelper.setProxy(request.options, request.proxyHost, request.proxyPort); + http.setConfig(request.options.build()); http.setHeader("Authorization", "bearer " + request.Token); CloseableHttpResponse responseB = client.execute(http); diff --git a/src/main/java/Utils/Requests/Validate/ValidateLrfcOptionsRequest.java b/src/main/java/Utils/Requests/Validate/ValidateLrfcOptionsRequest.java index 1e96b45..3dd9820 100644 --- a/src/main/java/Utils/Requests/Validate/ValidateLrfcOptionsRequest.java +++ b/src/main/java/Utils/Requests/Validate/ValidateLrfcOptionsRequest.java @@ -4,10 +4,8 @@ import Utils.Requests.IRequest; public class ValidateLrfcOptionsRequest extends IRequest { - private String lrfc; - public ValidateLrfcOptionsRequest(String token, String URI, String Lrfc) { - super(token, URI+ Constants.VALIDATE_LRFC_PATH+Lrfc); - this.lrfc = Lrfc; + public ValidateLrfcOptionsRequest(String token, String URI, String Lrfc, String proxyHost, int proxyPort) { + super(token, URI + Constants.VALIDATE_LRFC_PATH + Lrfc, proxyHost, proxyPort); } } \ No newline at end of file diff --git a/src/main/java/Utils/Requests/Validate/ValidateLrfcRequest.java b/src/main/java/Utils/Requests/Validate/ValidateLrfcRequest.java index a5a3f08..25b42d0 100644 --- a/src/main/java/Utils/Requests/Validate/ValidateLrfcRequest.java +++ b/src/main/java/Utils/Requests/Validate/ValidateLrfcRequest.java @@ -25,7 +25,9 @@ public IResponse sendRequest(IRequest request) throws GeneralException, AuthExce try { CloseableHttpClient client = HttpClients.createDefault(); HttpGet http = new HttpGet(request.URI); - RequestHelper.setTimeOut(http, 7000); + RequestHelper.setTimeOut(request.options, 7000); + RequestHelper.setProxy(request.options, request.proxyHost, request.proxyPort); + http.setConfig(request.options.build()); http.setHeader("Authorization", "bearer " + request.Token); CloseableHttpResponse responseB = client.execute(http); diff --git a/src/main/java/Utils/Requests/Validate/ValidateXmlOptionsRequest.java b/src/main/java/Utils/Requests/Validate/ValidateXmlOptionsRequest.java index 3eb4ad5..ec6e691 100644 --- a/src/main/java/Utils/Requests/Validate/ValidateXmlOptionsRequest.java +++ b/src/main/java/Utils/Requests/Validate/ValidateXmlOptionsRequest.java @@ -6,8 +6,8 @@ public class ValidateXmlOptionsRequest extends IRequest { private String xml; - public ValidateXmlOptionsRequest(String token, String URI, String Xml) { - super(token, URI+ Constants.VALIDATE_XML_PATH); + public ValidateXmlOptionsRequest(String token, String URI, String Xml, String proxyHost, int proxyPort) { + super(token, URI+ Constants.VALIDATE_XML_PATH, proxyHost, proxyPort); this.xml = Xml; } diff --git a/src/main/java/Utils/Requests/Validate/ValidateXmlRequest.java b/src/main/java/Utils/Requests/Validate/ValidateXmlRequest.java index f34b3b6..34a95a8 100644 --- a/src/main/java/Utils/Requests/Validate/ValidateXmlRequest.java +++ b/src/main/java/Utils/Requests/Validate/ValidateXmlRequest.java @@ -37,7 +37,9 @@ public IResponse sendRequest(IRequest request) throws GeneralException, AuthExce String raw = "--"+boundary+"\r\nContent-Disposition: form-data; name=xml; filename=xml\r\nContent-Type: application/xml\r\n\r\n"+xmlStr+"\r\n--"+boundary+"--"; CloseableHttpClient client = HttpClients.createDefault(); HttpPost httppost = new HttpPost(request.URI); - RequestHelper.setTimeOut(httppost, raw.length()); + RequestHelper.setTimeOut(request.options, raw.length()); + RequestHelper.setProxy(request.options, request.proxyHost, request.proxyPort); + httppost.setConfig(request.options.build()); httppost.setHeader("Authorization", "bearer " + request.Token); httppost.addHeader("Content-Type", "multipart/form-data; boundary="+boundary); MultipartEntityBuilder builder = MultipartEntityBuilder.create(); diff --git a/src/test/java/Tests/Csd/SWCsdServiceTest.java b/src/test/java/Tests/Csd/SWCsdServiceTest.java index b07ffb0..11bc0ec 100644 --- a/src/test/java/Tests/Csd/SWCsdServiceTest.java +++ b/src/test/java/Tests/Csd/SWCsdServiceTest.java @@ -14,7 +14,20 @@ public class SWCsdServiceTest extends TestCase { public String b64Key = "MIIFDjBABgkqhkiG9w0BBQ0wMzAbBgkqhkiG9w0BBQwwDgQIAgEAAoIBAQACAggAMBQGCCqGSIb3DQMHBAgwggS9AgEAMASCBMh4EHl7aNSCaMDA1VlRoXCZ5UUmqErAbucRBAKNQXH8t1GNfLDIQejtcocS39VvWnpNXjZJeCg65Y2wI36UGn78gvnU0NOmyUkXksPVrkz7hqNtAVojPUtN65l+MVAsIRVD6OLJeKZ2bLx5z78zrx6Tp1zCGT/NpxL+CJSy5iY6TKqbJcK/9198noOvT2p8rKVqUUF3wLRvD6R/b3BC5wCon/exp3BUTZeiWJqGRRgaW4rn49ZbJPVIcDmUO8mojPesFHjJDSnA0nBnWaUvTYXi0srT+dLZOewsBR8d5GdSWh9ZkM29wJbjYHCMsXkObZjaap3YM8fU29zRyZ8KAqaCnBHCfYjbib56m+Lmnk+ScqMkQQ+S/+2pzn2LzauvBI4p/OjQgBDeblo22X7sX9OA9YaqB3q6CCjQ5tkDNrz3HOgTm+amh/kI8TEn9rcKf4Ru7mC1T7VMaFgBqpIS8YJNbcgegF0IF1FpCS05wjdU5CktYAnPnvC+Pj+MFDeH+184kIHBWqPNG6dAzALxRgtKTlGdJ1l5Do+4EWI+0mvKojREnKoDczFnDeCFnM51u3I9Vce3rkf0djRQKFomPVUnPDqxlR5lDAssYAYNcECAkvGxKcBDbjWi/6NHlwjS1r28+0Jhvfxjx9O6hi4AW82Q2/kBE5P/eOwln/jKSbLgi7Iyim1FFHxkQH1FY5kcKhAzFcIq85rGFlzHRfPF9OIQSmONI9kcWQCxkk8aG1u1zwbjZRYLTxlwmZvynOgaWRpTN8Y4ReBDIG1klhva7nqqoM416oXBG71IKaCtjAwRlE6pgaqnIz/WQAb2FR541pqynX6dB6DB1nIWnatsWZJZlu+Bnhf9DBlUsO9ZSAf9Fa9nJAzwFCzaKIsvGJIeKSZ/h+vInkjaO/rxswErVROTfZy1lO2CJ/xnAgzFGrpDxNJPliv3McO9TGwYy/zHhE6Pdo8Xu6NsMisNU6TB8Bc26uLNv/7kWhNmNnBA1qt5akln6hOHrPBXGBiTNUL0IoFVPNdCbS0834zAYXfgtZLDzVpeLqmeMpqXbIYK0/NXe9etxuOcN40O+B/fTHHmO7dMgBZ4vAApVQUPr7ilumVHsWSMRP/0p5R9q4qr1bDm9S5YCPevdyYWTSceGSrXHmjYzJLBtpc/s77mynNqZEYjhnKk2XRNp6kp/FYRu+QdsX9vaDJbLKR2EnSC4fU6UOTO03IZU15j3wOsg30QrXoKntSJ/beF99cvFHuPrQPWxCtws0lLwkkHNVOm6XNO948Moy1w1pL4i68CwmceYZaYrYhmHGdLuescFQrZQaULDWhpK2Stys8Vs/XwwxNi9MHAFSXpdy/b+Aro5n87w+0MHRcllF8ZKbtQ/ym4oG7aREuo7o71JXJQPjZKTOtVM1EQx/FLM/5brnDSoyvLtoYtv9/tTnIC+8gR6eErkzaGmn8pftPhGNuz6yzx8JeLFoMD7VWbGTefj46KS+yMweFJnpReHEqwnukXpEYq19EWVyQa/Sb7navtKt80y/vRs0aNZp3iL23AOs0u1kQ1CFNY2y12Gor1koaH2FUd5jAQnaSKmgarLy0H/QVvR2g8B3+Fh49QhKYrd8N6LvvI80cwbEoqYWn5DWA="; public String token = "T2lYQ0t4L0RHVkR4dHZ5Nkk1VHNEakZ3Y0J4Nk9GODZuRyt4cE1wVm5tbXB3YVZxTHdOdHAwVXY2NTdJb1hkREtXTzE3dk9pMmdMdkFDR2xFWFVPUXpTUm9mTG1ySXdZbFNja3FRa0RlYURqbzdzdlI2UUx1WGJiKzViUWY2dnZGbFloUDJ6RjhFTGF4M1BySnJ4cHF0YjUvbmRyWWpjTkVLN3ppd3RxL0dJPQ.T2lYQ0t4L0RHVkR4dHZ5Nkk1VHNEakZ3Y0J4Nk9GODZuRyt4cE1wVm5tbFlVcU92YUJTZWlHU3pER1kySnlXRTF4alNUS0ZWcUlVS0NhelhqaXdnWTRncklVSWVvZlFZMWNyUjVxYUFxMWFxcStUL1IzdGpHRTJqdS9Zakw2UGRiMTFPRlV3a2kyOWI5WUZHWk85ODJtU0M2UlJEUkFTVXhYTDNKZVdhOXIySE1tUVlFdm1jN3kvRStBQlpLRi9NeWJrd0R3clhpYWJrVUMwV0Mwd3FhUXdpUFF5NW5PN3J5cklMb0FETHlxVFRtRW16UW5ZVjAwUjdCa2g0Yk1iTExCeXJkVDRhMGMxOUZ1YWlIUWRRVC8yalFTNUczZXdvWlF0cSt2UW0waFZKY2gyaW5jeElydXN3clNPUDNvU1J2dm9weHBTSlZYNU9aaGsvalpQMUxrUndzK0dHS2dpTittY1JmR3o2M3NqNkh4MW9KVXMvUHhZYzVLQS9UK2E1SVhEZFJKYWx4ZmlEWDFuSXlqc2ZRYXlUQk1ldlZkU2tEdU10NFVMdHZKUURLblBxakw0SDl5bUxabDFLNmNPbEp6b3Jtd2Q1V2htRHlTdDZ6eTFRdUNnYnVvK2tuVUdhMmwrVWRCZi9rQkU9.7k2gVCGSZKLzJK5Ky3Nr5tKxvGSJhL13Q8W-YhT0uIo"; public void testCargaCsd_authUser() throws Exception { - SWCsdService app = new SWCsdService("demo", "123456789", Utils.url_pruebas, "127.0.0.1", "8888"); + SWCsdService app = new SWCsdService("demo", "123456789", Utils.url_pruebas, "127.0.0.1", 8888); + UploadCsdResponse response = null; + response = (UploadCsdResponse) app.UploadMyCsd(b64Cer, b64Key, password_csd, "stamp", true); + System.out.println(response.HttpStatusCode); + System.out.println(response.data); + System.out.println(response.Status); + System.out.println(response.message); + System.out.println(response.messageDetail); + String expect_status = "success"; + Assert.assertTrue(expect_status.equalsIgnoreCase(response.Status)); + } + + public void testCargaCsd_authToken() throws Exception { + SWCsdService app = new SWCsdService(token, Utils.url_pruebas); UploadCsdResponse response = null; response = (UploadCsdResponse) app.UploadMyCsd(b64Cer, b64Key, password_csd, "stamp", true); System.out.println(response.HttpStatusCode);