From 4b9c9914399d1cfdf29b00b9cba3ee33df3ecc46 Mon Sep 17 00:00:00 2001 From: Dusan Jakub Date: Tue, 19 Sep 2023 10:35:22 +0200 Subject: [PATCH] remove deprecated error constructor --- src/main/java/com/ysoft/geecon/OAuthResource.java | 10 ++++------ .../java/com/ysoft/geecon/error/OAuthException.java | 5 ----- .../geecon/helpers/DeviceAuthorizationGrantFlow.java | 4 +--- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/ysoft/geecon/OAuthResource.java b/src/main/java/com/ysoft/geecon/OAuthResource.java index f7f58a3..7dbf74f 100644 --- a/src/main/java/com/ysoft/geecon/OAuthResource.java +++ b/src/main/java/com/ysoft/geecon/OAuthResource.java @@ -25,14 +25,12 @@ public class OAuthResource { @POST @Produces(MediaType.TEXT_HTML) @Consumes(MediaType.APPLICATION_FORM_URLENCODED) - public Object post(AuthParams params, - @FormParam("sessionId") String sessionId, + public Object post(@FormParam("sessionId") String sessionId, @FormParam("username") String username, - @FormParam("password") String password, - @FormParam("scope") List scopes) { + @FormParam("password") String password) { - sessionsRepo.getSession(sessionId).orElseThrow(() -> new OAuthException("Invalid session")); + sessionsRepo.getSession(sessionId).orElseThrow(() -> new OAuthException(ErrorResponse.Error.access_denied, "Invalid session")); var user = validateUser(username, password); if (user == null) { return Templates.login(username, sessionId, "invalid_credentials"); @@ -67,7 +65,7 @@ public class OAuthResource { @FormParam("sessionId") String sessionId, @FormParam("scope") List scopes) { - sessionsRepo.getSession(sessionId).orElseThrow(() -> new OAuthException("Invalid session")); + sessionsRepo.getSession(sessionId).orElseThrow(() -> new OAuthException(ErrorResponse.Error.access_denied, "Invalid session")); var session = sessionsRepo.authorizeSession(sessionId, scopes); String redirectUri = session.params().getRedirectUri(); diff --git a/src/main/java/com/ysoft/geecon/error/OAuthException.java b/src/main/java/com/ysoft/geecon/error/OAuthException.java index d691fd4..bfc762a 100644 --- a/src/main/java/com/ysoft/geecon/error/OAuthException.java +++ b/src/main/java/com/ysoft/geecon/error/OAuthException.java @@ -12,11 +12,6 @@ public class OAuthException extends RuntimeException { this(new ErrorResponse(error, description)); } - @Deprecated - public OAuthException(String message) { - this(ErrorResponse.Error.server_error, message); - } - public ErrorResponse getResponse() { return response; } diff --git a/src/test/java/com/ysoft/geecon/helpers/DeviceAuthorizationGrantFlow.java b/src/test/java/com/ysoft/geecon/helpers/DeviceAuthorizationGrantFlow.java index 2e6152c..2a7bb65 100644 --- a/src/test/java/com/ysoft/geecon/helpers/DeviceAuthorizationGrantFlow.java +++ b/src/test/java/com/ysoft/geecon/helpers/DeviceAuthorizationGrantFlow.java @@ -5,8 +5,6 @@ import com.ysoft.geecon.dto.DeviceResponse; import com.ysoft.geecon.dto.OAuthClient; import com.ysoft.geecon.error.ErrorResponse; -import java.io.IOException; - import static io.restassured.RestAssured.given; import static io.restassured.http.ContentType.JSON; import static org.hamcrest.CoreMatchers.is; @@ -22,7 +20,7 @@ public class DeviceAuthorizationGrantFlow { this.client = client; } - public DeviceResponse start() throws IOException { + public DeviceResponse start() { deviceResponse = given(). formParam("client_id", client.clientId()). when().post(deviceUrl)