Skip to content

Commit

Permalink
Se ajusta exception de Authentication para que el usuario la pueda ca…
Browse files Browse the repository at this point in the history
…pturar en caso de que no se brinden credenciales correctas.
  • Loading branch information
JuanGamezSW committed Dec 10, 2018
1 parent 354a314 commit af30cb2
Show file tree
Hide file tree
Showing 14 changed files with 18 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import Utils.Responses.IResponse;

public class SWAcceptRejectService extends SWService{
public SWAcceptRejectService(String user, String password, String URI) {
public SWAcceptRejectService(String user, String password, String URI) throws AuthException {
super(user, password, URI);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import Utils.Responses.IResponse;

public class SWAuthenticationService extends SWService {
public SWAuthenticationService(String user, String password, String URI) {
public SWAuthenticationService(String user, String password, String URI) throws AuthException {
super(user, password, URI);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

public class SWBalanceAccountService extends SWService {

public SWBalanceAccountService(String user, String password, String URI) {
public SWBalanceAccountService(String user, String password, String URI) throws AuthException {
super(user, password, URI);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

public class SWCancelationService extends SWService {

public SWCancelationService(String user, String password, String URI) {
public SWCancelationService(String user, String password, String URI) throws AuthException {
super(user, password, URI);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/Services/Issue/SWIssueService.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

public class SWIssueService extends SWService {

public SWIssueService(String user, String password, String URI) {
public SWIssueService(String user, String password, String URI) throws AuthException {
super(user, password, URI);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/Services/Pdf/SWPdfService.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

public class SWPdfService extends SWService {

public SWPdfService(String user, String password, String URI) {
public SWPdfService(String user, String password, String URI) throws AuthException {
super(user, password, URI);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/Services/Pendings/SWPendingsService.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import Utils.Responses.IResponse;

public class SWPendingsService extends SWService{
public SWPendingsService(String user, String password, String URI) {
public SWPendingsService(String user, String password, String URI) throws AuthException {
super(user, password, URI);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/Services/Relations/SWRelationsService.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import Utils.Responses.IResponse;

public class SWRelationsService extends SWService{
public SWRelationsService(String user, String password, String URI) {
public SWRelationsService(String user, String password, String URI) throws AuthException {
super(user, password, URI);
}

Expand Down
10 changes: 5 additions & 5 deletions src/main/java/Services/SWService.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@ public String getURI() {

private String URI;

protected SWService(String user, String password, String URI) {
protected SWService(String user, String password, String URI) throws AuthException {
User = user;
Password = password;
this.URI = URI;
try {
generateToken();
} catch (AuthException e) {
e.printStackTrace();
throw new AuthException(e.getHttpStatusCode(), e.getErrorMSG());
} catch (GeneralException e) {
e.printStackTrace();
throw new AuthException(e.getHttpStatusCode(), e.getErrorMSG());
} catch (IOException e) {
e.printStackTrace();
throw new AuthException(99, e.getMessage());
}
}

Expand Down Expand Up @@ -75,7 +75,7 @@ public void setPassword(String password) {

public void generateToken() throws AuthException, GeneralException, IOException {
if (User == null || Password == null) {
throw new AuthException(400, "no existen elementos de autenticación");
throw new AuthException(400, "no existen elementos de autenticación");
}
AuthOptionsRequest settings = new AuthOptionsRequest(URI, getUser(), getPassword());
AuthRequest req = new AuthRequest();
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/Services/Stamp/SWStampService.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

public class SWStampService extends SWService {

public SWStampService(String user, String password, String URI) {
public SWStampService(String user, String password, String URI) throws AuthException {
super(user, password, URI);
}

Expand All @@ -40,7 +40,7 @@ public IResponse Stamp(String xml, String version, boolean isb64)
}
}

public IResponse Stamp(byte[] xmlFile, String version, boolean isb64)
public IResponse Stamp(byte[] xmlFile, String version, boolean isb64)
throws AuthException, GeneralException, IOException {
String xmlProcess = new String(xmlFile, Charset.forName("UTF-8"));
StampOptionsRequest settings = new StampOptionsRequest(getToken(), getURI(), xmlProcess, version);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/Services/Validate/SWValidateService.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

public class SWValidateService extends SWService {

public SWValidateService(String user, String password, String URI) {
public SWValidateService(String user, String password, String URI) throws AuthException {
super(user, password, URI);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

public class SWAuthenticationServiceTest extends TestCase {
public void testAuth(){
SWAuthenticationService auth = new SWAuthenticationService("demo","123456789","http://services.test.sw.com.mx");
try {
SWAuthenticationService auth = new SWAuthenticationService("demo","123456789","http://services.test.sw.com.mx");
SuccessAuthResponse res = (SuccessAuthResponse) auth.Token();
String expected = "success";
System.out.println(res.token);
Expand Down
1 change: 0 additions & 1 deletion src/test/java/Tests/Stamp/SWStampServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,6 @@ public void testStampTOKEN_EXPIRES_NOT_USER_NOT_PASSWORD() throws Exception {
Utils ut = new Utils();
response = api.Stamp(ut.StringgenBasico(),"v1");


}catch (Exception e){
System.out.println(e.getMessage());
System.out.println("Something bad happened");
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/Tests/StatusCfdi/StatusCfdiServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void testStatusCancelationService_Real() throws Exception {
Assert.assertTrue(expect_status.equalsIgnoreCase(response.Status));
}
public void testStatusCancelationService_Test() throws Exception {
StatusCfdiService app = new StatusCfdiService("http://consultaqrfacturaelectronicatest.sw.com.mx/ConsultaCFDIService.svc", "http://tempuri.org/IConsultaCFDIService/Consulta");
StatusCfdiService app = new StatusCfdiService("https://pruebacfdiconsultaqr.cloudapp.net/ConsultaCFDIService.svc", "http://tempuri.org/IConsultaCFDIService/Consulta");
StatusCfdiResponse response = null;
response = (StatusCfdiResponse) app.StatusCfdi("LAN8507268IA", "LAN7008173R5", "5800.00", "6ab07bef-4446-43ea-a3fd-04a804309457");
System.out.println(response.Status);
Expand Down

0 comments on commit af30cb2

Please sign in to comment.