diff --git a/pom.xml b/pom.xml index 4b71f31f..99def859 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ org.springframework.boot spring-boot-starter-parent - 2.1.0.RELEASE + 2.3.0.RELEASE jar @@ -283,6 +283,10 @@ spring-security-jwt 1.0.9.RELEASE + + org.springframework.boot + spring-boot-starter-validation + @@ -322,6 +326,7 @@ joda-time joda-time + 2.10.9 com.fasterxml.jackson.datatype diff --git a/src/main/java/ch/ethz/seb/sebserver/SEBServer.java b/src/main/java/ch/ethz/seb/sebserver/SEBServer.java index f0ae0de5..293f76b7 100644 --- a/src/main/java/ch/ethz/seb/sebserver/SEBServer.java +++ b/src/main/java/ch/ethz/seb/sebserver/SEBServer.java @@ -18,6 +18,8 @@ import org.springframework.boot.web.servlet.server.ServletWebServerFactory; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.core.env.Environment; +import org.springframework.security.web.firewall.HttpFirewall; +import org.springframework.security.web.firewall.StrictHttpFirewall; import ch.ethz.seb.sebserver.gbl.Constants; import ch.ethz.seb.sebserver.gbl.profile.ProdGuiProfile; @@ -75,6 +77,13 @@ public class SEBServer { return tomcat; } + @Bean + public HttpFirewall allowEncodedParamsFirewall() { + final StrictHttpFirewall firewall = new StrictHttpFirewall(); + firewall.setAllowUrlEncodedPercent(true); + return firewall; + } + private Connector redirectConnector(final Environment env) { final String sslPort = env.getRequiredProperty("server.port"); final String httpPort = env.getProperty("sebserver.ssl.redirect.html.port", "80"); diff --git a/src/main/java/ch/ethz/seb/sebserver/gbl/util/Utils.java b/src/main/java/ch/ethz/seb/sebserver/gbl/util/Utils.java index 0c5d77ca..60ff5b9e 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gbl/util/Utils.java +++ b/src/main/java/ch/ethz/seb/sebserver/gbl/util/Utils.java @@ -535,7 +535,7 @@ public final class Utils { final MultiValueMap headers = new LinkedMultiValueMap<>(); headers.set( HttpHeaders.CONTENT_TYPE, - org.springframework.http.MediaType.APPLICATION_JSON_UTF8_VALUE); + org.springframework.http.MediaType.APPLICATION_JSON_VALUE); return headers; } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/InstitutionalAuthenticationEntryPoint.java b/src/main/java/ch/ethz/seb/sebserver/gui/InstitutionalAuthenticationEntryPoint.java index c56f03fb..7c46a35c 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/InstitutionalAuthenticationEntryPoint.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/InstitutionalAuthenticationEntryPoint.java @@ -11,6 +11,7 @@ package ch.ethz.seb.sebserver.gui; import java.io.IOException; import java.io.InputStreamReader; import java.io.Reader; +import java.nio.charset.StandardCharsets; import java.util.List; import javax.servlet.RequestDispatcher; @@ -18,7 +19,6 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.apache.commons.codec.Charsets; import org.apache.commons.codec.binary.Base64InputStream; import org.apache.commons.lang3.StringUtils; import org.eclipse.rap.rwt.RWT; @@ -93,7 +93,7 @@ public final class InstitutionalAuthenticationEntryPoint implements Authenticati final Resource resource = resourceLoader.getResource(defaultLogoFileName); final Reader reader = new InputStreamReader( new Base64InputStream(resource.getInputStream(), true), - Charsets.UTF_8); + StandardCharsets.UTF_8); _defaultLogo = FileCopyUtils.copyToString(reader); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/RestCall.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/RestCall.java index 575b139b..95785864 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/RestCall.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/RestCall.java @@ -364,7 +364,8 @@ public abstract class RestCall { .cloneBuilder() .path(RestCall.this.path) .queryParams(this.queryParams) - .toUriString(); + .build(false) + .toString(); } public HttpEntity buildRequestEntity() { diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/ActivateSEBRestriction.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/ActivateSEBRestriction.java index 67de13f7..8c97cb46 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/ActivateSEBRestriction.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/ActivateSEBRestriction.java @@ -33,7 +33,7 @@ public class ActivateSEBRestriction extends RestCall { new TypeReference() { }), HttpMethod.PUT, - MediaType.APPLICATION_JSON_UTF8, + MediaType.APPLICATION_JSON, API.EXAM_ADMINISTRATION_ENDPOINT + API.MODEL_ID_VAR_PATH_SEGMENT + API.EXAM_ADMINISTRATION_SEB_RESTRICTION_PATH_SEGMENT); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/CheckSEBRestriction.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/CheckSEBRestriction.java index d7a02885..e86f869b 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/CheckSEBRestriction.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/CheckSEBRestriction.java @@ -32,7 +32,7 @@ public class CheckSEBRestriction extends RestCall { new TypeReference() { }), HttpMethod.GET, - MediaType.APPLICATION_JSON_UTF8, + MediaType.APPLICATION_JSON, API.EXAM_ADMINISTRATION_ENDPOINT + API.MODEL_ID_VAR_PATH_SEGMENT + API.EXAM_ADMINISTRATION_CHECK_RESTRICTION_PATH_SEGMENT); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/DeactivateSEBRestriction.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/DeactivateSEBRestriction.java index 1d327f13..b1953d09 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/DeactivateSEBRestriction.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/DeactivateSEBRestriction.java @@ -33,7 +33,7 @@ public class DeactivateSEBRestriction extends RestCall { new TypeReference() { }), HttpMethod.DELETE, - MediaType.APPLICATION_JSON_UTF8, + MediaType.APPLICATION_JSON, API.EXAM_ADMINISTRATION_ENDPOINT + API.MODEL_ID_VAR_PATH_SEGMENT + API.EXAM_ADMINISTRATION_SEB_RESTRICTION_PATH_SEGMENT); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/DeleteExamConfigMapping.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/DeleteExamConfigMapping.java index 23d7c5e9..a0092230 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/DeleteExamConfigMapping.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/DeleteExamConfigMapping.java @@ -33,7 +33,7 @@ public class DeleteExamConfigMapping extends RestCall { new TypeReference() { }), HttpMethod.DELETE, - MediaType.APPLICATION_JSON_UTF8, + MediaType.APPLICATION_JSON, API.EXAM_CONFIGURATION_MAP_ENDPOINT + API.MODEL_ID_VAR_PATH_SEGMENT); } } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/DeleteIndicator.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/DeleteIndicator.java index d6517105..0bcfd39b 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/DeleteIndicator.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/DeleteIndicator.java @@ -33,7 +33,7 @@ public class DeleteIndicator extends RestCall { new TypeReference() { }), HttpMethod.DELETE, - MediaType.APPLICATION_JSON_UTF8, + MediaType.APPLICATION_JSON, API.EXAM_INDICATOR_ENDPOINT + API.MODEL_ID_VAR_PATH_SEGMENT); } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/GetProctoringSettings.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/GetProctoringSettings.java index 7a16bd22..3e336d25 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/GetProctoringSettings.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/GetProctoringSettings.java @@ -33,7 +33,7 @@ public class GetProctoringSettings extends RestCall { new TypeReference() { }), HttpMethod.GET, - MediaType.APPLICATION_JSON_UTF8, + MediaType.APPLICATION_JSON, API.EXAM_ADMINISTRATION_ENDPOINT + API.MODEL_ID_VAR_PATH_SEGMENT + API.EXAM_ADMINISTRATION_PROCTORING_PATH_SEGMENT); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/GetSEBRestrictionSettings.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/GetSEBRestrictionSettings.java index 701239c5..33fc140d 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/GetSEBRestrictionSettings.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/GetSEBRestrictionSettings.java @@ -33,7 +33,7 @@ public class GetSEBRestrictionSettings extends RestCall { new TypeReference() { }), HttpMethod.GET, - MediaType.APPLICATION_JSON_UTF8, + MediaType.APPLICATION_JSON, API.EXAM_ADMINISTRATION_ENDPOINT + API.MODEL_ID_VAR_PATH_SEGMENT + API.EXAM_ADMINISTRATION_SEB_RESTRICTION_PATH_SEGMENT); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/SaveExam.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/SaveExam.java index f75b9d77..4a1fcf02 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/SaveExam.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/SaveExam.java @@ -33,7 +33,7 @@ public class SaveExam extends RestCall { new TypeReference() { }), HttpMethod.PUT, - MediaType.APPLICATION_JSON_UTF8, + MediaType.APPLICATION_JSON, API.EXAM_ADMINISTRATION_ENDPOINT); } } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/SaveExamConfigMapping.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/SaveExamConfigMapping.java index d42bda83..df3d269c 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/SaveExamConfigMapping.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/SaveExamConfigMapping.java @@ -33,7 +33,7 @@ public class SaveExamConfigMapping extends RestCall { new TypeReference() { }), HttpMethod.PUT, - MediaType.APPLICATION_JSON_UTF8, + MediaType.APPLICATION_JSON, API.EXAM_CONFIGURATION_MAP_ENDPOINT); } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/SaveIndicator.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/SaveIndicator.java index 23a03406..96529032 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/SaveIndicator.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/SaveIndicator.java @@ -33,7 +33,7 @@ public class SaveIndicator extends RestCall { new TypeReference() { }), HttpMethod.PUT, - MediaType.APPLICATION_JSON_UTF8, + MediaType.APPLICATION_JSON, API.EXAM_INDICATOR_ENDPOINT); } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/SaveProctoringSettings.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/SaveProctoringSettings.java index e0249b68..dbacc253 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/SaveProctoringSettings.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/SaveProctoringSettings.java @@ -33,7 +33,7 @@ public class SaveProctoringSettings extends RestCall { new TypeReference() { }), HttpMethod.POST, - MediaType.APPLICATION_JSON_UTF8, + MediaType.APPLICATION_JSON, API.EXAM_ADMINISTRATION_ENDPOINT + API.MODEL_ID_VAR_PATH_SEGMENT + API.EXAM_ADMINISTRATION_PROCTORING_PATH_SEGMENT); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/SaveSEBRestriction.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/SaveSEBRestriction.java index d3e79c18..dac28050 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/SaveSEBRestriction.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/exam/SaveSEBRestriction.java @@ -33,7 +33,7 @@ public class SaveSEBRestriction extends RestCall { new TypeReference() { }), HttpMethod.POST, - MediaType.APPLICATION_JSON_UTF8, + MediaType.APPLICATION_JSON, API.EXAM_ADMINISTRATION_ENDPOINT + API.MODEL_ID_VAR_PATH_SEGMENT + API.EXAM_ADMINISTRATION_SEB_RESTRICTION_PATH_SEGMENT); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/institution/SaveInstitution.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/institution/SaveInstitution.java index 373b087b..61786491 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/institution/SaveInstitution.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/institution/SaveInstitution.java @@ -33,7 +33,7 @@ public class SaveInstitution extends RestCall { new TypeReference() { }), HttpMethod.PUT, - MediaType.APPLICATION_JSON_UTF8, + MediaType.APPLICATION_JSON, API.INSTITUTION_ENDPOINT); } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/lmssetup/SaveLmsSetup.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/lmssetup/SaveLmsSetup.java index 2e9445f2..102551b4 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/lmssetup/SaveLmsSetup.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/lmssetup/SaveLmsSetup.java @@ -33,7 +33,7 @@ public class SaveLmsSetup extends RestCall { new TypeReference() { }), HttpMethod.PUT, - MediaType.APPLICATION_JSON_UTF8, + MediaType.APPLICATION_JSON, API.LMS_SETUP_ENDPOINT); } } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/lmssetup/TestLmsSetupAdHoc.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/lmssetup/TestLmsSetupAdHoc.java index 93c2fbf8..cbe7eefd 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/lmssetup/TestLmsSetupAdHoc.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/lmssetup/TestLmsSetupAdHoc.java @@ -33,7 +33,7 @@ public class TestLmsSetupAdHoc extends RestCall { new TypeReference() { }), HttpMethod.PUT, - MediaType.APPLICATION_JSON_UTF8, + MediaType.APPLICATION_JSON, API.LMS_SETUP_TEST_AD_HOC_ENDPOINT); } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/seb/clientconfig/SaveClientConfig.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/seb/clientconfig/SaveClientConfig.java index e3884e2a..236d6f0f 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/seb/clientconfig/SaveClientConfig.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/seb/clientconfig/SaveClientConfig.java @@ -33,7 +33,7 @@ public class SaveClientConfig extends RestCall { new TypeReference() { }), HttpMethod.PUT, - MediaType.APPLICATION_JSON_UTF8, + MediaType.APPLICATION_JSON, API.SEB_CLIENT_CONFIG_ENDPOINT); } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/seb/examconfig/CopyConfiguration.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/seb/examconfig/CopyConfiguration.java index 58c4e176..ccc573b7 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/seb/examconfig/CopyConfiguration.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/seb/examconfig/CopyConfiguration.java @@ -33,7 +33,7 @@ public class CopyConfiguration extends RestCall { new TypeReference() { }), HttpMethod.PUT, - MediaType.APPLICATION_JSON_UTF8, + MediaType.APPLICATION_JSON, API.CONFIGURATION_NODE_ENDPOINT + API.CONFIGURATION_COPY_PATH_SEGMENT); } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/seb/examconfig/SaveExamConfig.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/seb/examconfig/SaveExamConfig.java index c0ffb056..2d60e5fe 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/seb/examconfig/SaveExamConfig.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/seb/examconfig/SaveExamConfig.java @@ -33,7 +33,7 @@ public class SaveExamConfig extends RestCall { new TypeReference() { }), HttpMethod.PUT, - MediaType.APPLICATION_JSON_UTF8, + MediaType.APPLICATION_JSON, API.CONFIGURATION_NODE_ENDPOINT); } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/seb/examconfig/SaveExamConfigTableValues.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/seb/examconfig/SaveExamConfigTableValues.java index 5399b545..6144f76e 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/seb/examconfig/SaveExamConfigTableValues.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/seb/examconfig/SaveExamConfigTableValues.java @@ -33,7 +33,7 @@ public class SaveExamConfigTableValues extends RestCall() { }), HttpMethod.PUT, - MediaType.APPLICATION_JSON_UTF8, + MediaType.APPLICATION_JSON, API.CONFIGURATION_VALUE_ENDPOINT + API.CONFIGURATION_TABLE_VALUE_PATH_SEGMENT); } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/seb/examconfig/SaveExamConfigValue.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/seb/examconfig/SaveExamConfigValue.java index 6ee26bb0..50e9516e 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/seb/examconfig/SaveExamConfigValue.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/seb/examconfig/SaveExamConfigValue.java @@ -33,7 +33,7 @@ public class SaveExamConfigValue extends RestCall { new TypeReference() { }), HttpMethod.PUT, - MediaType.APPLICATION_JSON_UTF8, + MediaType.APPLICATION_JSON, API.CONFIGURATION_VALUE_ENDPOINT); } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/session/PropagateInstruction.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/session/PropagateInstruction.java index dfed4714..442df26a 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/session/PropagateInstruction.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/session/PropagateInstruction.java @@ -32,7 +32,7 @@ public class PropagateInstruction extends RestCall { new TypeReference() { }), HttpMethod.POST, - MediaType.APPLICATION_JSON_UTF8, + MediaType.APPLICATION_JSON, API.EXAM_MONITORING_ENDPOINT + API.PARENT_MODEL_ID_VAR_PATH_SEGMENT + API.EXAM_MONITORING_INSTRUCTION_ENDPOINT); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/useraccount/ChangePassword.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/useraccount/ChangePassword.java index ac908c07..3c108f7d 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/useraccount/ChangePassword.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/useraccount/ChangePassword.java @@ -33,7 +33,7 @@ public class ChangePassword extends RestCall { new TypeReference() { }), HttpMethod.PUT, - MediaType.APPLICATION_JSON_UTF8, + MediaType.APPLICATION_JSON, API.USER_ACCOUNT_ENDPOINT + API.PASSWORD_PATH_SEGMENT); } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/useraccount/SaveUserAccount.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/useraccount/SaveUserAccount.java index ee16e0ac..0e826008 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/useraccount/SaveUserAccount.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/api/useraccount/SaveUserAccount.java @@ -34,7 +34,7 @@ public class SaveUserAccount extends RestCall { new TypeReference() { }), HttpMethod.PUT, - MediaType.APPLICATION_JSON_UTF8, + MediaType.APPLICATION_JSON, API.USER_ACCOUNT_ENDPOINT); } diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/WebServiceSecurityConfig.java b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/WebServiceSecurityConfig.java index 27917766..722bdcb9 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/WebServiceSecurityConfig.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/WebServiceSecurityConfig.java @@ -239,7 +239,7 @@ public class WebServiceSecurityConfig extends WebSecurityConfigurerAdapter { webServiceClientDetails, authenticationManager, (request, response, exception) -> { - response.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE); + response.setContentType(MediaType.APPLICATION_JSON_VALUE); response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); log.warn("Unauthorized Request: {}", request, exception); log.info("Redirect to login after unauthorized request"); @@ -279,13 +279,16 @@ public class WebServiceSecurityConfig extends WebSecurityConfigurerAdapter { } @Override - protected void addConfiguration(final String apiEndpoint, final HttpSecurity http) throws Exception { - http.antMatcher(apiEndpoint + "/**") + protected void addConfiguration( + final ConfigurerAdapter configurerAdapter, + final HttpSecurity http) throws Exception { + + http.antMatcher(configurerAdapter.apiEndpoint + "/**") .authorizeRequests() + .anyRequest() .hasAuthority(UserRole.SEB_SERVER_ADMIN.name()); } - } private static class LoginRedirectOnUnauthorized implements AuthenticationEntryPoint { diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/APIExceptionHandler.java b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/APIExceptionHandler.java index 2b56b838..4667dbef 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/APIExceptionHandler.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/APIExceptionHandler.java @@ -92,8 +92,8 @@ public class APIExceptionHandler extends ResponseEntityExceptionHandler { final RuntimeException ex, final WebRequest request) { - log.error("Unexpected generic error catched at the API endpoint: ", ex); - final List errors = Arrays.asList(APIMessage.ErrorMessage.GENERIC.of(ex.getMessage())); + log.error("Unexpected internal error catched at the API endpoint: ", ex); + final List errors = Arrays.asList(APIMessage.ErrorMessage.UNEXPECTED.of(ex.getMessage())); return new ResponseEntity<>( errors, Utils.createJsonContentHeader(), @@ -188,12 +188,12 @@ public class APIExceptionHandler extends ResponseEntityExceptionHandler { } @ExceptionHandler(Exception.class) - public ResponseEntity handleUnexpected( + public ResponseEntity handleGeneric( final Exception ex, final WebRequest request) { - log.error("Unexpected internal error catched at the API endpoint: ", ex); - return APIMessage.ErrorMessage.UNEXPECTED + log.error("Unexpected generic error catched at the API endpoint: ", ex); + return APIMessage.ErrorMessage.GENERIC .createErrorResponse(ex.getMessage()); } diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ActivatableEntityController.java b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ActivatableEntityController.java index 82c90739..ca941abe 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ActivatableEntityController.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ActivatableEntityController.java @@ -62,7 +62,7 @@ public abstract class ActivatableEntityController allActive( @RequestParam( name = Entity.FILTER_ATTR_INSTITUTION, @@ -90,7 +90,7 @@ public abstract class ActivatableEntityController allInactive( @RequestParam( name = Entity.FILTER_ATTR_INSTITUTION, @@ -118,7 +118,7 @@ public abstract class ActivatableEntityController getExtendedPage( @RequestParam( name = API.PARAM_INSTITUTION_ID, @@ -129,7 +129,7 @@ public class ClientEventController extends ReadonlyEntityController ids, @RequestParam(name = API.PARAM_BULK_ACTION_ADD_INCLUDES, defaultValue = "false") final boolean addIncludes, diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ConfigurationAttributeController.java b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ConfigurationAttributeController.java index 4dd60fe6..817a7ab9 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ConfigurationAttributeController.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ConfigurationAttributeController.java @@ -59,7 +59,7 @@ public class ConfigurationAttributeController extends EntityController getForIds( @RequestParam(name = API.PARAM_MODEL_ID_LIST, required = false) final String modelIds) { diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ConfigurationController.java b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ConfigurationController.java index 40bc1246..9b77e053 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ConfigurationController.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ConfigurationController.java @@ -70,7 +70,7 @@ public class ConfigurationController extends ReadonlyEntityController getTemplateAttributePage( @PathVariable(name = API.PARAM_PARENT_MODEL_ID, required = true) final Long parentModelId, @RequestParam( @@ -397,7 +397,7 @@ public class ConfigurationNodeController extends EntityController { @RequestMapping( method = RequestMethod.GET, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, - produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + produces = MediaType.APPLICATION_JSON_VALUE) public Page getPage( @RequestParam( name = API.PARAM_INSTITUTION_ID, @@ -172,7 +172,7 @@ public abstract class EntityController { path = API.NAMES_PATH_SEGMENT, method = RequestMethod.GET, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, - produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + produces = MediaType.APPLICATION_JSON_VALUE) public Collection getNames( @RequestParam( name = API.PARAM_INSTITUTION_ID, @@ -209,7 +209,7 @@ public abstract class EntityController { path = API.MODEL_ID_VAR_PATH_SEGMENT + API.DEPENDENCY_PATH_SEGMENT, method = RequestMethod.GET, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, - produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + produces = MediaType.APPLICATION_JSON_VALUE) public Collection getDependencies( @PathVariable final String modelId, @RequestParam(name = API.PARAM_BULK_ACTION_TYPE, required = true) final BulkActionType bulkActionType, @@ -238,7 +238,7 @@ public abstract class EntityController { path = API.MODEL_ID_VAR_PATH_SEGMENT, method = RequestMethod.GET, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, - produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + produces = MediaType.APPLICATION_JSON_VALUE) public T getBy(@PathVariable final String modelId) { return this.entityDAO @@ -255,7 +255,7 @@ public abstract class EntityController { path = API.LIST_PATH_SEGMENT, method = RequestMethod.GET, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, - produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + produces = MediaType.APPLICATION_JSON_VALUE) public List getForIds(@RequestParam(name = API.PARAM_MODEL_ID_LIST, required = true) final String modelIds) { return Result.tryCatch(() -> Arrays.stream(StringUtils.split(modelIds, Constants.LIST_SEPARATOR_CHAR)) @@ -275,7 +275,7 @@ public abstract class EntityController { @RequestMapping( method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, - produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + produces = MediaType.APPLICATION_JSON_VALUE) public T create( @RequestParam final MultiValueMap allRequestParams, @RequestParam( @@ -306,8 +306,8 @@ public abstract class EntityController { @RequestMapping( method = RequestMethod.PUT, - consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, - produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + consumes = MediaType.APPLICATION_JSON_VALUE, + produces = MediaType.APPLICATION_JSON_VALUE) public T savePut(@Valid @RequestBody final T modifyData) { return this.checkModifyAccess(modifyData) .flatMap(this::validForSave) @@ -324,7 +324,7 @@ public abstract class EntityController { @RequestMapping( path = API.MODEL_ID_VAR_PATH_SEGMENT, method = RequestMethod.DELETE, - produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + produces = MediaType.APPLICATION_JSON_VALUE) public EntityProcessingReport hardDelete( @PathVariable final String modelId, @RequestParam(name = API.PARAM_BULK_ACTION_ADD_INCLUDES, defaultValue = "false") final boolean addIncludes, @@ -346,7 +346,7 @@ public abstract class EntityController { @RequestMapping( method = RequestMethod.DELETE, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, - produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + produces = MediaType.APPLICATION_JSON_VALUE) public EntityProcessingReport hardDeleteAll( @RequestParam(name = API.PARAM_MODEL_ID_LIST) final List ids, @RequestParam(name = API.PARAM_BULK_ACTION_ADD_INCLUDES, defaultValue = "false") final boolean addIncludes, diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ExamAPIDiscoveryController.java b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ExamAPIDiscoveryController.java index 62e5690f..b2d46c99 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ExamAPIDiscoveryController.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ExamAPIDiscoveryController.java @@ -81,7 +81,7 @@ public class ExamAPIDiscoveryController { @RequestMapping( method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + produces = MediaType.APPLICATION_JSON_VALUE) public ExamAPIDiscovery getDiscovery() { return this.DISCOVERY_INFO; } diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ExamAPI_V1_Controller.java b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ExamAPI_V1_Controller.java index e0367431..ba0868a4 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ExamAPI_V1_Controller.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ExamAPI_V1_Controller.java @@ -86,7 +86,7 @@ public class ExamAPI_V1_Controller { path = API.EXAM_API_HANDSHAKE_ENDPOINT, method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, - produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + produces = MediaType.APPLICATION_JSON_VALUE) public CompletableFuture> handshakeCreate( @RequestParam(name = API.PARAM_INSTITUTION_ID, required = false) final Long instIdRequestParam, @RequestParam(name = API.EXAM_API_PARAM_EXAM_ID, required = false) final Long examIdRequestParam, @@ -274,7 +274,7 @@ public class ExamAPI_V1_Controller { path = API.EXAM_API_PING_ENDPOINT, method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, - produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + produces = MediaType.APPLICATION_JSON_VALUE) public void ping(final HttpServletRequest request, final HttpServletResponse response) { final String connectionToken = request.getHeader(API.EXAM_API_SEB_CONNECTION_TOKEN); @@ -308,7 +308,7 @@ public class ExamAPI_V1_Controller { @RequestMapping( path = API.EXAM_API_EVENT_ENDPOINT, method = RequestMethod.POST, - consumes = MediaType.APPLICATION_JSON_UTF8_VALUE) + consumes = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(value = HttpStatus.NO_CONTENT) public void event( @RequestHeader(name = API.EXAM_API_SEB_CONNECTION_TOKEN, required = true) final String connectionToken, diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ExamAdministrationController.java b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ExamAdministrationController.java index 8d328d45..ff1a9994 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ExamAdministrationController.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ExamAdministrationController.java @@ -128,7 +128,7 @@ public class ExamAdministrationController extends EntityController { @RequestMapping( method = RequestMethod.GET, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, - produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + produces = MediaType.APPLICATION_JSON_VALUE) @Override public Page getPage( @RequestParam( @@ -215,7 +215,7 @@ public class ExamAdministrationController extends EntityController { path = API.MODEL_ID_VAR_PATH_SEGMENT + API.EXAM_ADMINISTRATION_CHECK_IMPORTED_PATH_SEGMENT, method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + produces = MediaType.APPLICATION_JSON_VALUE) public Collection checkImported( @PathVariable final String modelId, @RequestParam( @@ -236,7 +236,7 @@ public class ExamAdministrationController extends EntityController { path = API.MODEL_ID_VAR_PATH_SEGMENT + API.EXAM_ADMINISTRATION_CONSISTENCY_CHECK_PATH_SEGMENT, method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + produces = MediaType.APPLICATION_JSON_VALUE) public Collection checkExamConsistency( @PathVariable final Long modelId, @RequestParam( @@ -257,7 +257,7 @@ public class ExamAdministrationController extends EntityController { path = API.MODEL_ID_VAR_PATH_SEGMENT + API.EXAM_ADMINISTRATION_CHECK_RESTRICTION_PATH_SEGMENT, method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + produces = MediaType.APPLICATION_JSON_VALUE) public Boolean checkSEBRestriction( @PathVariable final Long modelId, @RequestParam( @@ -275,7 +275,7 @@ public class ExamAdministrationController extends EntityController { path = API.MODEL_ID_VAR_PATH_SEGMENT + API.EXAM_ADMINISTRATION_SEB_RESTRICTION_PATH_SEGMENT, method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + produces = MediaType.APPLICATION_JSON_VALUE) public SEBRestriction getSEBRestriction( @RequestParam( name = API.PARAM_INSTITUTION_ID, @@ -294,7 +294,7 @@ public class ExamAdministrationController extends EntityController { path = API.MODEL_ID_VAR_PATH_SEGMENT + API.EXAM_ADMINISTRATION_SEB_RESTRICTION_PATH_SEGMENT, method = RequestMethod.POST, - produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + produces = MediaType.APPLICATION_JSON_VALUE) public Exam saveSEBRestrictionData( @RequestParam( name = API.PARAM_INSTITUTION_ID, @@ -317,7 +317,7 @@ public class ExamAdministrationController extends EntityController { path = API.MODEL_ID_VAR_PATH_SEGMENT + API.EXAM_ADMINISTRATION_SEB_RESTRICTION_PATH_SEGMENT, method = RequestMethod.PUT, - produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + produces = MediaType.APPLICATION_JSON_VALUE) public Exam applySEBRestriction( @RequestParam( name = API.PARAM_INSTITUTION_ID, @@ -337,7 +337,7 @@ public class ExamAdministrationController extends EntityController { path = API.MODEL_ID_VAR_PATH_SEGMENT + API.EXAM_ADMINISTRATION_SEB_RESTRICTION_PATH_SEGMENT, method = RequestMethod.DELETE, - produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + produces = MediaType.APPLICATION_JSON_VALUE) public Exam deleteSEBRestriction( @RequestParam( name = API.PARAM_INSTITUTION_ID, @@ -357,7 +357,7 @@ public class ExamAdministrationController extends EntityController { path = API.MODEL_ID_VAR_PATH_SEGMENT + API.EXAM_ADMINISTRATION_SEB_RESTRICTION_CHAPTERS_PATH_SEGMENT, method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + produces = MediaType.APPLICATION_JSON_VALUE) public Chapters getChapters( @RequestParam( name = API.PARAM_INSTITUTION_ID, @@ -385,7 +385,7 @@ public class ExamAdministrationController extends EntityController { path = API.MODEL_ID_VAR_PATH_SEGMENT + API.EXAM_ADMINISTRATION_PROCTORING_PATH_SEGMENT, method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + produces = MediaType.APPLICATION_JSON_VALUE) public ProctoringSettings getExamProctoring( @RequestParam( name = API.PARAM_INSTITUTION_ID, @@ -404,7 +404,7 @@ public class ExamAdministrationController extends EntityController { path = API.MODEL_ID_VAR_PATH_SEGMENT + API.EXAM_ADMINISTRATION_PROCTORING_PATH_SEGMENT, method = RequestMethod.POST, - produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + produces = MediaType.APPLICATION_JSON_VALUE) public Exam saveExamProctoring( @RequestParam( name = API.PARAM_INSTITUTION_ID, diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ExamConfigurationMappingController.java b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ExamConfigurationMappingController.java index 77e63223..69400d22 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ExamConfigurationMappingController.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ExamConfigurationMappingController.java @@ -133,7 +133,7 @@ public class ExamConfigurationMappingController extends EntityController allRequestParams, @RequestParam( @@ -163,7 +163,7 @@ public class ExamConfigurationMappingController extends EntityController getPage( @RequestParam( name = API.PARAM_INSTITUTION_ID, @@ -158,7 +158,7 @@ public class ExamMonitoringController { path = API.PARENT_MODEL_ID_VAR_PATH_SEGMENT, method = RequestMethod.GET, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, - produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + produces = MediaType.APPLICATION_JSON_VALUE) public Collection getConnectionData( @RequestParam( name = API.PARAM_INSTITUTION_ID, @@ -203,7 +203,7 @@ public class ExamMonitoringController { API.EXAM_MONITORING_SEB_CONNECTION_TOKEN_PATH_SEGMENT, method = RequestMethod.GET, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, - produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + produces = MediaType.APPLICATION_JSON_VALUE) public ClientConnectionData getConnectionDataForSingleConnection( @RequestParam( name = API.PARAM_INSTITUTION_ID, @@ -235,7 +235,7 @@ public class ExamMonitoringController { path = API.PARENT_MODEL_ID_VAR_PATH_SEGMENT + API.EXAM_MONITORING_INSTRUCTION_ENDPOINT, method = RequestMethod.POST, - consumes = MediaType.APPLICATION_JSON_UTF8_VALUE) + consumes = MediaType.APPLICATION_JSON_VALUE) public void registerInstruction( @RequestParam( name = API.PARAM_INSTITUTION_ID, @@ -253,7 +253,7 @@ public class ExamMonitoringController { API.EXAM_MONITORING_SEB_CONNECTION_TOKEN_PATH_SEGMENT, method = RequestMethod.GET, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, - produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + produces = MediaType.APPLICATION_JSON_VALUE) public Collection pendingNotifications( @RequestParam( name = API.PARAM_INSTITUTION_ID, diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ExamProctoringController.java b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ExamProctoringController.java index a963b71a..7464140d 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ExamProctoringController.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/ExamProctoringController.java @@ -90,7 +90,7 @@ public class ExamProctoringController { + API.EXAM_PROCTORING_ROOMS_SEGMENT, method = RequestMethod.GET, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, - produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + produces = MediaType.APPLICATION_JSON_VALUE) public Collection getProcotringCollectingRoomsOfExam( @RequestParam( name = API.PARAM_INSTITUTION_ID, @@ -107,7 +107,7 @@ public class ExamProctoringController { path = API.MODEL_ID_VAR_PATH_SEGMENT, method = RequestMethod.GET, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, - produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + produces = MediaType.APPLICATION_JSON_VALUE) public SEBProctoringConnectionData getProctorRoomData( @RequestParam( name = API.PARAM_INSTITUTION_ID, @@ -136,7 +136,7 @@ public class ExamProctoringController { + API.EXAM_PROCTORING_ROOM_CONNECTIONS_PATH_SEGMENT, method = RequestMethod.GET, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, - produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + produces = MediaType.APPLICATION_JSON_VALUE) public Collection getProctorRoomConnectionData( @RequestParam( name = API.PARAM_INSTITUTION_ID, @@ -157,7 +157,7 @@ public class ExamProctoringController { path = API.MODEL_ID_VAR_PATH_SEGMENT + API.EXAM_PROCTORING_BROADCAST_SEND_ATTRIBUTES, method = RequestMethod.POST, - produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + produces = MediaType.APPLICATION_JSON_VALUE) public void sendBroadcastAttributes( @RequestParam( name = API.PARAM_INSTITUTION_ID, @@ -204,7 +204,7 @@ public class ExamProctoringController { path = API.MODEL_ID_VAR_PATH_SEGMENT + API.EXAM_PROCTORING_REJOIN_COLLECTING_ROOM_PATH_SEGMENT, method = RequestMethod.POST, - produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + produces = MediaType.APPLICATION_JSON_VALUE) public void sendRejoinExamCollectingRoomToClients( @RequestParam( name = API.PARAM_INSTITUTION_ID, @@ -244,7 +244,7 @@ public class ExamProctoringController { path = API.MODEL_ID_VAR_PATH_SEGMENT + API.EXAM_PROCTORING_JOIN_ROOM_PATH_SEGMENT, method = RequestMethod.POST, - produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + produces = MediaType.APPLICATION_JSON_VALUE) public SEBProctoringConnectionData sendJoinProctoringRoomToClients( @RequestParam( name = API.PARAM_INSTITUTION_ID, @@ -319,7 +319,7 @@ public class ExamProctoringController { path = API.MODEL_ID_VAR_PATH_SEGMENT + API.EXAM_PROCTORING_TOWNHALL_ROOM_DATA, method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + produces = MediaType.APPLICATION_JSON_VALUE) public RemoteProctoringRoom getTownhallRoomData( @RequestParam( name = API.PARAM_INSTITUTION_ID, @@ -337,7 +337,7 @@ public class ExamProctoringController { path = API.MODEL_ID_VAR_PATH_SEGMENT + API.EXAM_PROCTORING_ACTIVATE_TOWNHALL_ROOM, method = RequestMethod.POST, - produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + produces = MediaType.APPLICATION_JSON_VALUE) public SEBProctoringConnectionData activateTownhall( @RequestParam( name = API.PARAM_INSTITUTION_ID, @@ -401,7 +401,7 @@ public class ExamProctoringController { path = API.MODEL_ID_VAR_PATH_SEGMENT + API.EXAM_PROCTORING_DEACTIVATE_TOWNHALL_ROOM, method = RequestMethod.POST, - produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + produces = MediaType.APPLICATION_JSON_VALUE) public void deactivateTownhall( @RequestParam( name = API.PARAM_INSTITUTION_ID, diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/InfoController.java b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/InfoController.java index ae8ebbb5..eae1ca9f 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/InfoController.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/InfoController.java @@ -93,7 +93,7 @@ public class InfoController { @RequestMapping( path = API.PRIVILEGES_PATH_SEGMENT, method = RequestMethod.GET, - produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + produces = MediaType.APPLICATION_JSON_VALUE) public Collection privileges() { return this.authorizationGrantService.getAllPrivileges(); } diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/LmsSetupController.java b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/LmsSetupController.java index 1b02580b..53108690 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/LmsSetupController.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/LmsSetupController.java @@ -79,7 +79,7 @@ public class LmsSetupController extends ActivatableEntityController getQuizPage( @RequestParam( name = Entity.FILTER_ATTR_INSTITUTION, @@ -113,7 +113,7 @@ public class QuizController { path = API.MODEL_ID_VAR_PATH_SEGMENT, method = RequestMethod.GET, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, - produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + produces = MediaType.APPLICATION_JSON_VALUE) public QuizData getQuiz( @PathVariable final String modelId, @RequestParam(name = QuizData.QUIZ_ATTR_LMS_SETUP_ID, required = true) final Long lmsSetupId) { diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/RegisterUserController.java b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/RegisterUserController.java index 755f5a6e..09ea96a5 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/RegisterUserController.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/RegisterUserController.java @@ -63,7 +63,7 @@ public class RegisterUserController { @RequestMapping( method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, - produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + produces = MediaType.APPLICATION_JSON_VALUE) public UserInfo registerNewUser( @RequestParam final MultiValueMap allRequestParams, final HttpServletRequest request) { diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/UserAccountController.java b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/UserAccountController.java index a157108b..18b84619 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/UserAccountController.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/api/UserAccountController.java @@ -148,8 +148,8 @@ public class UserAccountController extends ActivatableEntityController ids, @RequestParam(name = API.PARAM_BULK_ACTION_ADD_INCLUDES, defaultValue = "false") final boolean addIncludes, diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/oauth/WebserviceResourceConfiguration.java b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/oauth/WebserviceResourceConfiguration.java index 9dde8429..ccd93952 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/oauth/WebserviceResourceConfiguration.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/weblayer/oauth/WebserviceResourceConfiguration.java @@ -67,22 +67,41 @@ public abstract class WebserviceResourceConfiguration extends ResourceServerConf super.setConfigurers(configurers); } - protected void addConfiguration(final String apiEndpoint, final HttpSecurity http) throws Exception { + protected void addConfiguration(final ConfigurerAdapter configurerAdapter, final HttpSecurity http) + throws Exception { // To override of additional configuration is needed + http + .sessionManagement() + .sessionCreationPolicy(SessionCreationPolicy.STATELESS) + .and() + .antMatcher(configurerAdapter.apiEndpoint + "/**") + .authorizeRequests() + .anyRequest() + .authenticated() + .and() + .exceptionHandling() + .authenticationEntryPoint(configurerAdapter.authenticationEntryPoint) + .and() + .formLogin().disable() + .httpBasic().disable() + .logout().disable() + .headers().frameOptions().disable() + .and() + .csrf().disable(); } - private static final class ConfigurerAdapter extends ResourceServerConfigurerAdapter { + protected static final class ConfigurerAdapter extends ResourceServerConfigurerAdapter { - private final WebserviceResourceConfiguration webserviceResourceConfiguration; - private final TokenStore tokenStore; - private final WebClientDetailsService webServiceClientDetails; - private final AuthenticationManager authenticationManager; - private final AuthenticationEntryPoint authenticationEntryPoint; - private final String resourceId; - private final String apiEndpoint; - private final boolean supportRefreshToken; - private final int accessTokenValiditySeconds; - private final int refreshTokenValiditySeconds; + public final WebserviceResourceConfiguration webserviceResourceConfiguration; + public final TokenStore tokenStore; + public final WebClientDetailsService webServiceClientDetails; + public final AuthenticationManager authenticationManager; + public final AuthenticationEntryPoint authenticationEntryPoint; + public final String resourceId; + public final String apiEndpoint; + public final boolean supportRefreshToken; + public final int accessTokenValiditySeconds; + public final int refreshTokenValiditySeconds; public ConfigurerAdapter( final WebserviceResourceConfiguration webserviceResourceConfiguration, @@ -124,26 +143,7 @@ public abstract class WebserviceResourceConfiguration extends ResourceServerConf @Override public void configure(final HttpSecurity http) throws Exception { - http - .sessionManagement() - .sessionCreationPolicy(SessionCreationPolicy.STATELESS) - .and() - .antMatcher(this.apiEndpoint + "/**") - .authorizeRequests() - .anyRequest() - .authenticated() - .and() - .exceptionHandling() - .authenticationEntryPoint(this.authenticationEntryPoint) - .and() - .formLogin().disable() - .httpBasic().disable() - .logout().disable() - .headers().frameOptions().disable() - .and() - .csrf().disable(); - - this.webserviceResourceConfiguration.addConfiguration(this.apiEndpoint, http); + this.webserviceResourceConfiguration.addConfiguration(this, http); } } diff --git a/src/test/java/ch/ethz/seb/sebserver/gui/integration/OpenEdxTestController.java b/src/test/java/ch/ethz/seb/sebserver/gui/integration/OpenEdxTestController.java index 0fc53dae..de96f0b9 100644 --- a/src/test/java/ch/ethz/seb/sebserver/gui/integration/OpenEdxTestController.java +++ b/src/test/java/ch/ethz/seb/sebserver/gui/integration/OpenEdxTestController.java @@ -25,7 +25,7 @@ public class OpenEdxTestController { @RequestMapping( method = RequestMethod.GET, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, - produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + produces = MediaType.APPLICATION_JSON_VALUE) public String getCourses() { return "{\"pagination\":{\"count\":6,\"previous\":null,\"num_pages\":1,\"next\":null},\"results\":[{\"blocks_url\":\"http://ralph.ethz.ch:18000/api/courses/v1/blocks/?course_id=course-v1%3AedX%2BDemoX%2BDemo_Course\",\"effort\":null,\"end\":null,\"enrollment_start\":null,\"enrollment_end\":null,\"id\":\"course-v1:edX+DemoX+Demo_Course\",\"media\":{\"course_image\":{\"uri\":\"/asset-v1:edX+DemoX+Demo_Course+type@asset+block@images_course_image.jpg\"},\"course_video\":{\"uri\":null},\"image\":{\"raw\":\"http://ralph.ethz.ch:18000/asset-v1:edX+DemoX+Demo_Course+type@asset+block@images_course_image.jpg\",\"small\":\"http://ralph.ethz.ch:18000/asset-v1:edX+DemoX+Demo_Course+type@asset+block@images_course_image.jpg\",\"large\":\"http://ralph.ethz.ch:18000/asset-v1:edX+DemoX+Demo_Course+type@asset+block@images_course_image.jpg\"}},\"name\":\"edX Demonstration Course\",\"number\":\"DemoX\",\"org\":\"edX\",\"short_description\":null,\"start\":\"2013-02-05T05:00:00Z\",\"start_display\":\"Feb. 5, 2013\",\"start_type\":\"timestamp\",\"pacing\":\"instructor\",\"mobile_available\":false,\"hidden\":false,\"invitation_only\":false,\"course_id\":\"course-v1:edX+DemoX+Demo_Course\"},{\"blocks_url\":\"http://ralph.ethz.ch:18000/api/courses/v1/blocks/?course_id=course-v1%3AedX%2BE2E-101%2Bcourse\",\"effort\":null,\"end\":\"2018-12-31T00:00:00Z\",\"enrollment_start\":null,\"enrollment_end\":null,\"id\":\"course-v1:edX+E2E-101+course\",\"media\":{\"course_image\":{\"uri\":\"/static/studio/images/pencils.jpg\"},\"course_video\":{\"uri\":null},\"image\":{\"raw\":\"http://ralph.ethz.ch:18000/static/studio/images/pencils.jpg\",\"small\":\"http://ralph.ethz.ch:18000/static/studio/images/pencils.jpg\",\"large\":\"http://ralph.ethz.ch:18000/static/studio/images/pencils.jpg\"}},\"name\":\"E2E Test Course\",\"number\":\"E2E-101\",\"org\":\"edX\",\"short_description\":\"\",\"start\":\"2016-01-01T00:00:00Z\",\"start_display\":\"Jan. 1, 2016\",\"start_type\":\"timestamp\",\"pacing\":\"instructor\",\"mobile_available\":false,\"hidden\":false,\"invitation_only\":false,\"course_id\":\"course-v1:edX+E2E-101+course\"},{\"blocks_url\":\"http://ralph.ethz.ch:18000/api/courses/v1/blocks/?course_id=course-v1%3Asebserver%2BSEBServer1%2Bseb\",\"effort\":null,\"end\":\"2019-09-30T00:00:00Z\",\"enrollment_start\":null,\"enrollment_end\":null,\"id\":\"course-v1:sebserver+SEBServer1+seb\",\"media\":{\"course_image\":{\"uri\":\"/asset-v1:sebserver+SEBServer1+seb+type@asset+block@images_course_image.jpg\"},\"course_video\":{\"uri\":null},\"image\":{\"raw\":\"http://ralph.ethz.ch:18000/asset-v1:sebserver+SEBServer1+seb+type@asset+block@images_course_image.jpg\",\"small\":\"http://ralph.ethz.ch:18000/asset-v1:sebserver+SEBServer1+seb+type@asset+block@images_course_image.jpg\",\"large\":\"http://ralph.ethz.ch:18000/asset-v1:sebserver+SEBServer1+seb+type@asset+block@images_course_image.jpg\"}},\"name\":\"test course 1\",\"number\":\"SEBServer1\",\"org\":\"sebserver\",\"short_description\":\"test for SEB Server LMS binding\\nmore text here\",\"start\":\"2019-09-04T14:00:00Z\",\"start_display\":\"Sept. 4, 2019\",\"start_type\":\"timestamp\",\"pacing\":\"instructor\",\"mobile_available\":false,\"hidden\":false,\"invitation_only\":false,\"course_id\":\"course-v1:sebserver+SEBServer1+seb\"},{\"blocks_url\":\"http://ralph.ethz.ch:18000/api/courses/v1/blocks/?course_id=course-v1%3Asebserver%2BSEBServer2%2Bseb\",\"effort\":null,\"end\":\"2019-11-30T01:30:00Z\",\"enrollment_start\":null,\"enrollment_end\":null,\"id\":\"course-v1:sebserver+SEBServer2+seb\",\"media\":{\"course_image\":{\"uri\":\"/asset-v1:sebserver+SEBServer2+seb+type@asset+block@images_course_image.jpg\"},\"course_video\":{\"uri\":null},\"image\":{\"raw\":\"http://ralph.ethz.ch:18000/asset-v1:sebserver+SEBServer2+seb+type@asset+block@images_course_image.jpg\",\"small\":\"http://ralph.ethz.ch:18000/asset-v1:sebserver+SEBServer2+seb+type@asset+block@images_course_image.jpg\",\"large\":\"http://ralph.ethz.ch:18000/asset-v1:sebserver+SEBServer2+seb+type@asset+block@images_course_image.jpg\"}},\"name\":\"test course 2\",\"number\":\"SEBServer2\",\"org\":\"sebserver\",\"short_description\":\"\",\"start\":\"2019-08-31T00:00:00Z\",\"start_display\":\"Aug. 31, 2019\",\"start_type\":\"timestamp\",\"pacing\":\"instructor\",\"mobile_available\":false,\"hidden\":false,\"invitation_only\":false,\"course_id\":\"course-v1:sebserver+SEBServer2+seb\"},{\"blocks_url\":\"http://ralph.ethz.ch:18000/api/courses/v1/blocks/?course_id=course-v1%3Asebserver%2BSEBServer3%2Bseb\",\"effort\":null,\"end\":\"2020-03-31T00:00:00Z\",\"enrollment_start\":null,\"enrollment_end\":null,\"id\":\"course-v1:sebserver+SEBServer3+seb\",\"media\":{\"course_image\":{\"uri\":\"/asset-v1:sebserver+SEBServer3+seb+type@asset+block@images_course_image.jpg\"},\"course_video\":{\"uri\":null},\"image\":{\"raw\":\"http://ralph.ethz.ch:18000/asset-v1:sebserver+SEBServer3+seb+type@asset+block@images_course_image.jpg\",\"small\":\"http://ralph.ethz.ch:18000/asset-v1:sebserver+SEBServer3+seb+type@asset+block@images_course_image.jpg\",\"large\":\"http://ralph.ethz.ch:18000/asset-v1:sebserver+SEBServer3+seb+type@asset+block@images_course_image.jpg\"}},\"name\":\"test course 3\",\"number\":\"SEBServer3\",\"org\":\"sebserver\",\"short_description\":\"\",\"start\":\"2019-08-31T00:00:00Z\",\"start_display\":\"Aug. 31, 2019\",\"start_type\":\"timestamp\",\"pacing\":\"instructor\",\"mobile_available\":false,\"hidden\":false,\"invitation_only\":false,\"course_id\":\"course-v1:sebserver+SEBServer3+seb\"},{\"blocks_url\":\"http://ralph.ethz.ch:18000/api/courses/v1/blocks/?course_id=course-v1%3Asebserver%2BSEBServer4%2Bseb\",\"effort\":null,\"end\":\"2020-02-29T00:00:00Z\",\"enrollment_start\":null,\"enrollment_end\":null,\"id\":\"course-v1:sebserver+SEBServer4+seb\",\"media\":{\"course_image\":{\"uri\":\"/asset-v1:sebserver+SEBServer4+seb+type@asset+block@images_course_image.jpg\"},\"course_video\":{\"uri\":null},\"image\":{\"raw\":\"http://ralph.ethz.ch:18000/asset-v1:sebserver+SEBServer4+seb+type@asset+block@images_course_image.jpg\",\"small\":\"http://ralph.ethz.ch:18000/asset-v1:sebserver+SEBServer4+seb+type@asset+block@images_course_image.jpg\",\"large\":\"http://ralph.ethz.ch:18000/asset-v1:sebserver+SEBServer4+seb+type@asset+block@images_course_image.jpg\"}},\"name\":\"test course new\",\"number\":\"SEBServer4\",\"org\":\"sebserver\",\"short_description\":\"\",\"start\":\"2018-12-07T10:23:00Z\",\"start_display\":\"Dec. 7, 2018\",\"start_type\":\"timestamp\",\"pacing\":\"instructor\",\"mobile_available\":false,\"hidden\":false,\"invitation_only\":false,\"course_id\":\"course-v1:sebserver+SEBServer4+seb\"}]}"; } diff --git a/src/test/java/ch/ethz/seb/sebserver/gui/integration/SEBClientBot.java b/src/test/java/ch/ethz/seb/sebserver/gui/integration/SEBClientBot.java index 0b7eef7e..d8a46b04 100644 --- a/src/test/java/ch/ethz/seb/sebserver/gui/integration/SEBClientBot.java +++ b/src/test/java/ch/ethz/seb/sebserver/gui/integration/SEBClientBot.java @@ -195,7 +195,7 @@ public class SEBClientBot { headers.set(EXAM_API_SEB_CONNECTION_TOKEN, connectionToken); final MultiValueMap eventHeaders = new LinkedMultiValueMap<>(); - eventHeaders.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_UTF8_VALUE); + eventHeaders.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE); eventHeaders.set(EXAM_API_SEB_CONNECTION_TOKEN, connectionToken); if (connectionToken != null) { diff --git a/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/admin/AdministrationAPIIntegrationTester.java b/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/admin/AdministrationAPIIntegrationTester.java index 9c94bc5d..5722dd74 100644 --- a/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/admin/AdministrationAPIIntegrationTester.java +++ b/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/admin/AdministrationAPIIntegrationTester.java @@ -156,7 +156,7 @@ public abstract class AdministrationAPIIntegrationTester { } public RestAPITestHelper withBodyJson(final Object object) throws Exception { - this.contentType = MediaType.APPLICATION_JSON_UTF8; + this.contentType = MediaType.APPLICATION_JSON; this.body = AdministrationAPIIntegrationTester.this.jsonMapper.writeValueAsString(object); return this; } diff --git a/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/admin/UserAPITest.java b/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/admin/UserAPITest.java index d2ad9fa6..5d3b8495 100644 --- a/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/admin/UserAPITest.java +++ b/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/admin/UserAPITest.java @@ -547,7 +547,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester { // final String contentAsString = this.mockMvc // .perform(post(this.endpoint + RestAPI.ENDPOINT_USER_ACCOUNT + "/save") // .header("Authorization", "Bearer " + token) -// .contentType(MediaType.APPLICATION_JSON_UTF8) +// .contentType(MediaType.APPLICATION_JSON) // .content(modifyUserJson)) // .andReturn().getResponse().getContentAsString(); // @@ -603,7 +603,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester { UserInfo modifiedUserResult = this.jsonMapper.readValue( this.mockMvc.perform(put(this.endpoint + API.USER_ACCOUNT_ENDPOINT) .header("Authorization", "Bearer " + token) - .contentType(MediaType.APPLICATION_JSON_UTF8) + .contentType(MediaType.APPLICATION_JSON) .content(modifyUserJson)) .andExpect(status().isOk()) .andReturn().getResponse().getContentAsString(), @@ -732,7 +732,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester { this.mockMvc.perform(put(this.endpoint + API.USER_ACCOUNT_ENDPOINT) .header("Authorization", "Bearer " + examAdminToken1) - .contentType(MediaType.APPLICATION_JSON_UTF8) + .contentType(MediaType.APPLICATION_JSON) .content(modifiedUserJson)) .andExpect(status().isOk()) .andReturn().getResponse().getContentAsString(); @@ -759,7 +759,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester { final String newUserJson = this.jsonMapper.writeValueAsString(userInfo); this.mockMvc.perform(put(this.endpoint + API.USER_ACCOUNT_ENDPOINT) .header("Authorization", "Bearer " + token) - .contentType(MediaType.APPLICATION_JSON_UTF8) + .contentType(MediaType.APPLICATION_JSON) .content(newUserJson)) .andExpect(status().isForbidden()) .andReturn().getResponse().getContentAsString(); @@ -787,7 +787,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester { final String newUserJson = this.jsonMapper.writeValueAsString(userInfo); this.mockMvc.perform(put(this.endpoint + API.USER_ACCOUNT_ENDPOINT) .header("Authorization", "Bearer " + token) - .contentType(MediaType.APPLICATION_JSON_UTF8) + .contentType(MediaType.APPLICATION_JSON) .content(newUserJson)) .andExpect(status().isForbidden()) .andReturn().getResponse().getContentAsString(); @@ -819,7 +819,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester { this.mockMvc.perform( put(this.endpoint + API.USER_ACCOUNT_ENDPOINT + API.PASSWORD_PATH_SEGMENT) .header("Authorization", "Bearer " + sebAdminToken) - .contentType(MediaType.APPLICATION_JSON_UTF8) + .contentType(MediaType.APPLICATION_JSON) .content(modifiedUserJson)) .andExpect(status().isOk()) .andReturn().getResponse().getContentAsString(); @@ -870,7 +870,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester { this.mockMvc.perform( put(this.endpoint + API.USER_ACCOUNT_ENDPOINT + API.PASSWORD_PATH_SEGMENT) .header("Authorization", "Bearer " + sebAdminToken) - .contentType(MediaType.APPLICATION_JSON_UTF8) + .contentType(MediaType.APPLICATION_JSON) .content(modifiedUserJson)) .andExpect(status().isBadRequest()) .andReturn().getResponse().getContentAsString(), @@ -894,7 +894,7 @@ public class UserAPITest extends AdministrationAPIIntegrationTester { this.mockMvc.perform( put(this.endpoint + API.USER_ACCOUNT_ENDPOINT + API.PASSWORD_PATH_SEGMENT) .header("Authorization", "Bearer " + sebAdminToken) - .contentType(MediaType.APPLICATION_JSON_UTF8) + .contentType(MediaType.APPLICATION_JSON) .content(modifiedUserJson)) .andExpect(status().isBadRequest()) .andReturn().getResponse().getContentAsString(), diff --git a/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/exam/ExamAPIIntegrationTester.java b/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/exam/ExamAPIIntegrationTester.java index 1757b7f0..93c7f360 100644 --- a/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/exam/ExamAPIIntegrationTester.java +++ b/src/test/java/ch/ethz/seb/sebserver/webservice/integration/api/exam/ExamAPIIntegrationTester.java @@ -126,7 +126,7 @@ public abstract class ExamAPIIntegrationTester { final ResultActions result = this.mockMvc.perform(post("/oauth/token") .params(params) .with(httpBasic(clientId, clientSecret)) - .accept(MediaType.APPLICATION_JSON_UTF8_VALUE)) + .accept(MediaType.APPLICATION_JSON_VALUE)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)); @@ -144,7 +144,7 @@ public abstract class ExamAPIIntegrationTester { final MockHttpServletRequestBuilder builder = post(this.endpoint + "/handshake") .header("Content-Type", "application/x-www-form-urlencoded") .header("Authorization", "Bearer " + accessToken) - .accept(MediaType.APPLICATION_JSON_UTF8_VALUE); + .accept(MediaType.APPLICATION_JSON_VALUE); String body = ""; @@ -163,7 +163,7 @@ public abstract class ExamAPIIntegrationTester { .andReturn(); final ResultActions result = this.mockMvc.perform(asyncDispatch(mvcResult)) - .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)); + .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE)); return result.andReturn().getResponse(); } @@ -198,12 +198,12 @@ public abstract class ExamAPIIntegrationTester { .header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED_VALUE) .header("Authorization", "Bearer " + accessToken) .header(API.EXAM_API_SEB_CONNECTION_TOKEN, connectionToken) - .accept(MediaType.APPLICATION_JSON_UTF8_VALUE) + .accept(MediaType.APPLICATION_JSON_VALUE) : patch(this.endpoint + "/handshake") .header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED_VALUE) .header("Authorization", "Bearer " + accessToken) .header(API.EXAM_API_SEB_CONNECTION_TOKEN, connectionToken) - .accept(MediaType.APPLICATION_JSON_UTF8_VALUE); + .accept(MediaType.APPLICATION_JSON_VALUE); String body = ""; if (examId != null) { @@ -235,7 +235,7 @@ public abstract class ExamAPIIntegrationTester { .header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED_VALUE) .header("Authorization", "Bearer " + accessToken) .header(API.EXAM_API_SEB_CONNECTION_TOKEN, connectionToken) - .accept(MediaType.APPLICATION_JSON_UTF8_VALUE); + .accept(MediaType.APPLICATION_JSON_VALUE); final MvcResult mvcResult = this.mockMvc .perform(builder) @@ -254,7 +254,7 @@ public abstract class ExamAPIIntegrationTester { .header("Content-Type", MediaType.APPLICATION_FORM_URLENCODED_VALUE) .header("Authorization", "Bearer " + accessToken) .header(API.EXAM_API_SEB_CONNECTION_TOKEN, connectionToken) - .accept(MediaType.APPLICATION_JSON_UTF8_VALUE); + .accept(MediaType.APPLICATION_JSON_VALUE); final String body = API.EXAM_API_PING_TIMESTAMP + "=" + DateTime.now(DateTimeZone.UTC).getMillis() + "&" + API.EXAM_API_PING_NUMBER + "=" + num; @@ -274,10 +274,10 @@ public abstract class ExamAPIIntegrationTester { final String text) throws Exception { final MockHttpServletRequestBuilder builder = post(this.endpoint + API.EXAM_API_EVENT_ENDPOINT) - .header("Content-Type", MediaType.APPLICATION_JSON_UTF8_VALUE) + .header("Content-Type", MediaType.APPLICATION_JSON_VALUE) .header("Authorization", "Bearer " + accessToken) .header(API.EXAM_API_SEB_CONNECTION_TOKEN, connectionToken) - .accept(MediaType.APPLICATION_JSON_UTF8_VALUE); + .accept(MediaType.APPLICATION_JSON_VALUE); final String body = "{ \"type\": \"%s\", \"timestamp\": %s, \"numericValue\": %s, \"text\": \"%s\" }"; builder.content(String.format(body, type, timestamp, value, text)); diff --git a/src/test/resources/schema-test.sql b/src/test/resources/schema-test.sql index 07927d5c..d46f5a39 100644 --- a/src/test/resources/schema-test.sql +++ b/src/test/resources/schema-test.sql @@ -1,3 +1,6 @@ + +DROP ALL OBJECTS; + -- ----------------------------------------------------- -- Table `institution` -- ----------------------------------------------------- @@ -574,4 +577,3 @@ CREATE TABLE IF NOT EXISTS `client_instruction` ( ON UPDATE NO ACTION) ; -