-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Bernard Labno
committed
Feb 25, 2019
1 parent
208cad5
commit d40e1d2
Showing
18 changed files
with
1,495 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
api/src/main/java/bisq/api/http/exceptions/ExceptionMappers.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package bisq.api.http.exceptions; | ||
|
||
import com.fasterxml.jackson.core.JsonParseException; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
|
||
|
||
|
||
import javax.ws.rs.core.Response; | ||
import javax.ws.rs.ext.ExceptionMapper; | ||
import org.eclipse.jetty.io.EofException; | ||
import org.glassfish.jersey.server.ResourceConfig; | ||
|
||
@Slf4j | ||
public final class ExceptionMappers { | ||
|
||
private ExceptionMappers() { | ||
} | ||
|
||
public static void register(ResourceConfig environment) { | ||
environment.register(new ExceptionMappers.EofExceptionMapper(), 1); | ||
environment.register(new ExceptionMappers.JsonParseExceptionMapper(), 1); | ||
environment.register(new ExceptionMappers.UnauthorizedExceptionMapper()); | ||
} | ||
|
||
public static class EofExceptionMapper implements ExceptionMapper<EofException> { | ||
@Override | ||
public Response toResponse(EofException e) { | ||
return Response.status(Response.Status.BAD_REQUEST).build(); | ||
} | ||
} | ||
|
||
public static class JsonParseExceptionMapper implements ExceptionMapper<JsonParseException> { | ||
@Override | ||
public Response toResponse(JsonParseException e) { | ||
return Response.status(Response.Status.BAD_REQUEST).build(); | ||
} | ||
} | ||
|
||
public static class UnauthorizedExceptionMapper implements ExceptionMapper<UnauthorizedException> { | ||
@Override | ||
public Response toResponse(UnauthorizedException exception) { | ||
return Response.status(Response.Status.UNAUTHORIZED).build(); | ||
} | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
api/src/main/java/bisq/api/http/exceptions/UnauthorizedException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package bisq.api.http.exceptions; | ||
|
||
public class UnauthorizedException extends RuntimeException { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package bisq.api.http.model; | ||
|
||
import org.hibernate.validator.constraints.NotEmpty; | ||
|
||
public class AuthForm { | ||
|
||
@NotEmpty | ||
public String password; | ||
|
||
@SuppressWarnings("unused") | ||
public AuthForm() { | ||
} | ||
|
||
public AuthForm(String password) { | ||
this.password = password; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package bisq.api.http.model; | ||
|
||
public class AuthResult { | ||
|
||
public String token; | ||
|
||
@SuppressWarnings("unused") | ||
public AuthResult() { | ||
} | ||
|
||
public AuthResult(String token) { | ||
this.token = token; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package bisq.api.http.model; | ||
|
||
public class ChangePassword { | ||
|
||
public String newPassword; | ||
public String oldPassword; | ||
|
||
@SuppressWarnings("unused") | ||
public ChangePassword() { | ||
} | ||
|
||
public ChangePassword(String newPassword, String oldPassword) { | ||
this.newPassword = newPassword; | ||
this.oldPassword = oldPassword; | ||
} | ||
} |
22 changes: 21 additions & 1 deletion
22
api/src/main/java/bisq/api/http/service/HttpApiInterfaceV1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.