diff --git a/src/main/java/ch/ethz/seb/sebserver/gbl/Constants.java b/src/main/java/ch/ethz/seb/sebserver/gbl/Constants.java index f466f023..74ae8d43 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gbl/Constants.java +++ b/src/main/java/ch/ethz/seb/sebserver/gbl/Constants.java @@ -8,9 +8,17 @@ package ch.ethz.seb.sebserver.gbl; +import java.util.Collection; + import org.eclipse.swt.graphics.RGB; import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormatter; +import org.springframework.core.ParameterizedTypeReference; + +import com.fasterxml.jackson.core.type.TypeReference; + +import ch.ethz.seb.sebserver.gbl.api.APIMessage; +import ch.ethz.seb.sebserver.gbl.api.authorization.Privilege; /** Global Constants used in SEB Server web-service as well as in web-gui component */ public final class Constants { @@ -107,4 +115,11 @@ public final class Constants { public static final RGB WHITE_RGB = new RGB(255, 255, 255); public static final RGB BLACK_RGB = new RGB(0, 0, 0); + public static final TypeReference> TYPE_REFERENCE_API_MESSAGE = new TypeReference<>() { + }; + + public static final ParameterizedTypeReference> TYPE_REFERENCE_PRIVILEGES = + new ParameterizedTypeReference<>() { + }; + } diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/auth/CurrentUser.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/auth/CurrentUser.java index 94502b4f..37bda322 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/auth/CurrentUser.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/remote/webservice/auth/CurrentUser.java @@ -17,7 +17,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.ScopedProxyMode; -import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.HttpEntity; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; @@ -25,6 +24,7 @@ import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; import org.springframework.web.context.WebApplicationContext; +import ch.ethz.seb.sebserver.gbl.Constants; import ch.ethz.seb.sebserver.gbl.api.API; import ch.ethz.seb.sebserver.gbl.api.EntityType; import ch.ethz.seb.sebserver.gbl.api.authorization.Privilege; @@ -183,6 +183,8 @@ public class CurrentUser { this.attributes.clear(); } + this.privileges = null; + if (isAvailable()) { if (this.authContext.logout()) { this.authContext = null; @@ -225,8 +227,7 @@ public class CurrentUser { .toUriString(), HttpMethod.GET, HttpEntity.EMPTY, - new ParameterizedTypeReference>() { - }); + Constants.TYPE_REFERENCE_PRIVILEGES); if (exchange.getStatusCodeValue() == HttpStatus.OK.value()) { final Collection privileges = exchange.getBody(); diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/session/InstructionProcessor.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/session/InstructionProcessor.java index ef3b2add..ff9a4d5e 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/session/InstructionProcessor.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/session/InstructionProcessor.java @@ -22,8 +22,6 @@ import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; -import com.fasterxml.jackson.core.type.TypeReference; - import ch.ethz.seb.sebserver.gbl.Constants; import ch.ethz.seb.sebserver.gbl.api.API; import ch.ethz.seb.sebserver.gbl.api.APIMessage; @@ -149,8 +147,7 @@ public class InstructionProcessor { try { final Collection errorMessage = this.jsonMapper.readValue( response, - new TypeReference>() { - }); + Constants.TYPE_REFERENCE_API_MESSAGE); pageContext.notifyUnexpectedError(new RestCallError( "Failed to propagate SEB client instruction: ",