diff --git a/annotation-web/src/main/java/eu/europeana/annotation/web/service/controller/jsonld/BaseJsonldRest.java b/annotation-web/src/main/java/eu/europeana/annotation/web/service/controller/jsonld/BaseJsonldRest.java index 8e66cc10..0ed12360 100644 --- a/annotation-web/src/main/java/eu/europeana/annotation/web/service/controller/jsonld/BaseJsonldRest.java +++ b/annotation-web/src/main/java/eu/europeana/annotation/web/service/controller/jsonld/BaseJsonldRest.java @@ -1,6 +1,5 @@ package eu.europeana.annotation.web.service.controller.jsonld; -import static org.springframework.http.HttpStatus.UNAUTHORIZED; import java.util.ArrayList; import java.util.Date; import java.util.LinkedHashMap; @@ -8,6 +7,7 @@ import java.util.Set; import javax.servlet.http.HttpServletRequest; + import org.apache.commons.lang3.StringUtils; import org.apache.stanbol.commons.exception.JsonParseException; import org.apache.stanbol.commons.jsonld.JsonLd; @@ -60,14 +60,12 @@ import eu.europeana.annotation.web.service.authorization.AnnotationAuthorizationUtils; import eu.europeana.annotation.web.service.controller.BaseRest; import eu.europeana.api.common.config.I18nConstantsAnnotation; -import eu.europeana.api.commons.definitions.config.i18n.I18nConstants; import eu.europeana.api.commons.oauth2.model.impl.EuropeanaApiCredentials; import eu.europeana.api.commons.web.definitions.WebFields; import eu.europeana.api.commons.web.exception.ApplicationAuthenticationException; import eu.europeana.api.commons.web.exception.HttpException; import eu.europeana.api.commons.web.exception.InternalServerException; import eu.europeana.api.commons.web.http.HttpHeaders; -import eu.europeana.api.commons.web.model.vocabulary.Operations; public class BaseJsonldRest extends BaseRest { @@ -179,10 +177,8 @@ private String verifyClient(Authentication authentication) throws ApplicationAuthenticationException { String clientId = ((EuropeanaApiCredentials) authentication.getCredentials()).getClientId(); if (StringUtils.isBlank(clientId)) { - final String message = "ClientID is mandatory, please contact the support Team"; - throw new ApplicationAuthenticationException(message, - I18nConstants.OPERATION_NOT_AUTHORIZED, new String[] {message}, - UNAUTHORIZED); + throw new ApplicationAuthenticationException(I18nConstantsAnnotation.CLIENT_NOT_PUBLIC, + I18nConstantsAnnotation.CLIENT_NOT_PUBLIC, null, HttpStatus.FORBIDDEN); } return clientId; } diff --git a/annotation-web/src/main/java/eu/europeana/api/common/config/I18nConstantsAnnotation.java b/annotation-web/src/main/java/eu/europeana/api/common/config/I18nConstantsAnnotation.java index 7911ad0d..63d8c8bc 100644 --- a/annotation-web/src/main/java/eu/europeana/api/common/config/I18nConstantsAnnotation.java +++ b/annotation-web/src/main/java/eu/europeana/api/common/config/I18nConstantsAnnotation.java @@ -3,6 +3,7 @@ public interface I18nConstantsAnnotation extends eu.europeana.api.commons.definitions.config.i18n.I18nConstants{ String ANNOTATION_NOT_FOUND = "error.annotation_not_found"; String CLIENT_NOT_AUTHORIZED = "error.annotation_client_not_authorized"; + String CLIENT_NOT_PUBLIC = "error.annotation_client_not_public"; String USER_NOT_AUTHORIZED = "error.annotation_user_not_authorized"; String ANNOTATION_NOT_ACCESSIBLE = "error.annotation_not_accessible"; String ANNOTATION_INVALID_BODY = "error.annotation_invalid_body"; diff --git a/annotation-web/src/main/resources/messages_en.properties b/annotation-web/src/main/resources/messages_en.properties index dbec0487..46503f35 100644 --- a/annotation-web/src/main/resources/messages_en.properties +++ b/annotation-web/src/main/resources/messages_en.properties @@ -18,6 +18,7 @@ error.annotation_not_found=No annotation found with the given identifier! {0} error.annotation_apikey_file_not_found=No apiKey file found in {0} folder! #error.annotation_operation_not_authorized=The user is not allowed to perform the given operation! error.annotation_client_not_authorized=The client application is not allowed to perform the given operation! +error.annotation_client_not_public=The client is not authorized to perform the given operation because the public id for the client is missing. Please get in contact with the Europeana APIs customer support via api@europeana.eu error.annotation_invalid_token=The provided authentication token is invalid! {0} error.annotation_user_not_authorized=The user is not authorized to perform the given action! {0}