mirror of
https://github.com/ysoftdevs/oauth-playground-server.git
synced 2026-03-27 03:21:47 +01:00
remove deprecated error constructor
This commit is contained in:
@@ -25,14 +25,12 @@ public class OAuthResource {
|
|||||||
@POST
|
@POST
|
||||||
@Produces(MediaType.TEXT_HTML)
|
@Produces(MediaType.TEXT_HTML)
|
||||||
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
|
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
|
||||||
public Object post(AuthParams params,
|
public Object post(@FormParam("sessionId") String sessionId,
|
||||||
@FormParam("sessionId") String sessionId,
|
|
||||||
@FormParam("username") String username,
|
@FormParam("username") String username,
|
||||||
@FormParam("password") String password,
|
@FormParam("password") String password) {
|
||||||
@FormParam("scope") List<String> scopes) {
|
|
||||||
|
|
||||||
|
|
||||||
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);
|
var user = validateUser(username, password);
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
return Templates.login(username, sessionId, "invalid_credentials");
|
return Templates.login(username, sessionId, "invalid_credentials");
|
||||||
@@ -67,7 +65,7 @@ public class OAuthResource {
|
|||||||
@FormParam("sessionId") String sessionId,
|
@FormParam("sessionId") String sessionId,
|
||||||
@FormParam("scope") List<String> scopes) {
|
@FormParam("scope") List<String> 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);
|
var session = sessionsRepo.authorizeSession(sessionId, scopes);
|
||||||
|
|
||||||
String redirectUri = session.params().getRedirectUri();
|
String redirectUri = session.params().getRedirectUri();
|
||||||
|
|||||||
@@ -12,11 +12,6 @@ public class OAuthException extends RuntimeException {
|
|||||||
this(new ErrorResponse(error, description));
|
this(new ErrorResponse(error, description));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public OAuthException(String message) {
|
|
||||||
this(ErrorResponse.Error.server_error, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ErrorResponse getResponse() {
|
public ErrorResponse getResponse() {
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ import com.ysoft.geecon.dto.DeviceResponse;
|
|||||||
import com.ysoft.geecon.dto.OAuthClient;
|
import com.ysoft.geecon.dto.OAuthClient;
|
||||||
import com.ysoft.geecon.error.ErrorResponse;
|
import com.ysoft.geecon.error.ErrorResponse;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import static io.restassured.RestAssured.given;
|
import static io.restassured.RestAssured.given;
|
||||||
import static io.restassured.http.ContentType.JSON;
|
import static io.restassured.http.ContentType.JSON;
|
||||||
import static org.hamcrest.CoreMatchers.is;
|
import static org.hamcrest.CoreMatchers.is;
|
||||||
@@ -22,7 +20,7 @@ public class DeviceAuthorizationGrantFlow {
|
|||||||
this.client = client;
|
this.client = client;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DeviceResponse start() throws IOException {
|
public DeviceResponse start() {
|
||||||
deviceResponse = given().
|
deviceResponse = given().
|
||||||
formParam("client_id", client.clientId()).
|
formParam("client_id", client.clientId()).
|
||||||
when().post(deviceUrl)
|
when().post(deviceUrl)
|
||||||
|
|||||||
Reference in New Issue
Block a user