diff --git a/src/main/java/org/gcube/portal/oauth/OauthService.java b/src/main/java/org/gcube/portal/oauth/OauthService.java index e2bc9de..ab79677 100644 --- a/src/main/java/org/gcube/portal/oauth/OauthService.java +++ b/src/main/java/org/gcube/portal/oauth/OauthService.java @@ -171,7 +171,7 @@ public class OauthService { String errorMessage = checkRequest(clientId, clientSecret, redirectUri, code, grantType); if(errorMessage != null){ logger.error("The request fails because of " + errorMessage); - return Response.status(status).entity(new AccessTokenErrorResponse(errorMessage, null, null)).build(); + return Response.status(status).entity(new AccessTokenErrorResponse(errorMessage, null)).build(); }else{ logger.info("The request is ok"); String tokenToReturn = entries.get(code).getToken(); @@ -182,7 +182,7 @@ public class OauthService { }catch(Exception e){ logger.error("Failed to perform this operation", e); status = Status.BAD_REQUEST; - return Response.status(status).entity(new AccessTokenErrorResponse("invalid_request", null, null)).build(); + return Response.status(status).entity(new AccessTokenErrorResponse("invalid_request", null)).build(); } } diff --git a/src/main/java/org/gcube/portal/oauth/output/AccessTokenErrorResponse.java b/src/main/java/org/gcube/portal/oauth/output/AccessTokenErrorResponse.java index fc4e621..affe976 100644 --- a/src/main/java/org/gcube/portal/oauth/output/AccessTokenErrorResponse.java +++ b/src/main/java/org/gcube/portal/oauth/output/AccessTokenErrorResponse.java @@ -1,7 +1,5 @@ package org.gcube.portal.oauth.output; -import javax.validation.constraints.NotNull; - import com.fasterxml.jackson.annotation.JsonProperty; /** @@ -10,16 +8,12 @@ import com.fasterxml.jackson.annotation.JsonProperty; */ public class AccessTokenErrorResponse { - @NotNull @JsonProperty("error") private String error; @JsonProperty("error_description") private String errorDescription; - @JsonProperty("error_uri") - private String errorUri; - public AccessTokenErrorResponse() { super(); } @@ -29,12 +23,10 @@ public class AccessTokenErrorResponse { * @param errorDescription * @param errorUri */ - public AccessTokenErrorResponse(String error, String errorDescription, - String errorUri) { + public AccessTokenErrorResponse(String error, String errorDescription) { super(); this.error = error; this.errorDescription = errorDescription; - this.errorUri = errorUri; } public String getError() { @@ -53,18 +45,11 @@ public class AccessTokenErrorResponse { this.errorDescription = errorDescription; } - public String getErrorUri() { - return errorUri; - } - - public void setErrorUri(String errorUri) { - this.errorUri = errorUri; - } - @Override public String toString() { - return "AccessTokenErrorResponse [error=" + error - + ", errorDescription=" + errorDescription + ", errorUri=" - + errorUri + "]"; + return "AccessTokenErrorResponse [" + + (error != null ? "error=" + error + ", " : "") + + (errorDescription != null ? "errorDescription=" + + errorDescription : "") + "]"; } }