Merge remote-tracking branch 'origin/dev-1.1-patch-1' into development

This commit is contained in:
anhefti 2021-04-30 16:07:59 +02:00
commit 1a67ec773d
6 changed files with 48 additions and 16 deletions

View file

@ -15,6 +15,7 @@ import org.springframework.stereotype.Component;
import ch.ethz.seb.sebserver.SEBServerInit;
import ch.ethz.seb.sebserver.gbl.profile.GuiProfile;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.auth.WebserviceURIService;
@Component
@GuiProfile
@ -23,15 +24,18 @@ public class GuiInit implements ApplicationListener<ApplicationReadyEvent> {
private final SEBServerInit sebServerInit;
private final Environment environment;
private final GuiServiceInfo guiServiceInfo;
private final WebserviceURIService webserviceURIService;
protected GuiInit(
final SEBServerInit sebServerInit,
final Environment environment,
final GuiServiceInfo guiServiceInfo) {
final GuiServiceInfo guiServiceInfo,
final WebserviceURIService webserviceURIService) {
this.sebServerInit = sebServerInit;
this.environment = environment;
this.guiServiceInfo = guiServiceInfo;
this.webserviceURIService = webserviceURIService;
}
@Override
@ -46,13 +50,13 @@ public class GuiInit implements ApplicationListener<ApplicationReadyEvent> {
SEBServerInit.INIT_LOGGER.info("----> GUI Service successfully successfully started up!");
SEBServerInit.INIT_LOGGER.info("---->");
final String webServiceProtocol = this.environment.getProperty("sebserver.gui.webservice.protocol", "http");
final String webServiceAddress = this.environment.getRequiredProperty("sebserver.gui.webservice.address");
final String webServicePort = this.environment.getProperty("sebserver.gui.webservice.port", "80");
// final String webServiceProtocol = this.environment.getProperty("sebserver.gui.webservice.protocol", "http");
// final String webServiceAddress = this.environment.getRequiredProperty("sebserver.gui.webservice.address");
// final String webServicePort = this.environment.getProperty("sebserver.gui.webservice.port", "80");
SEBServerInit.INIT_LOGGER
.info("----> Webservice connection: " + webServiceProtocol + "://" + webServiceAddress
+ ":" + webServicePort);
SEBServerInit.INIT_LOGGER.info(
"----> Webservice connection: {}",
this.webserviceURIService.getURIBuilder().build());
SEBServerInit.INIT_LOGGER.info(
"----> GUI service internal connection : "
+ this.guiServiceInfo.getInternalServerURIBuilder().toUriString());

View file

@ -25,6 +25,7 @@ public class GuiServiceInfo {
private final String internalPort;
private final String externalPort;
private final String entryPoint;
private final String contextPath;
private final UriComponentsBuilder internalServerURIBuilder;
private final UriComponentsBuilder externalServerURIBuilder;
@ -34,7 +35,8 @@ public class GuiServiceInfo {
@Value("${sebserver.gui.http.external.scheme}") final String externalScheme,
@Value("${sebserver.gui.http.external.servername}") final String externalServer,
@Value("${sebserver.gui.http.external.port}") final String externalPort,
@Value("${sebserver.gui.entrypoint:/gui}") final String entryPoint) {
@Value("${sebserver.gui.entrypoint:/gui}") final String entryPoint,
@Value("${server.servlet.context-path:/}") final String contextPath) {
if (StringUtils.isBlank(externalScheme)) {
throw new RuntimeException("Missing mandatory inital parameter sebserver.gui.http.external.servername");
@ -50,16 +52,23 @@ public class GuiServiceInfo {
this.internalPort = internalPort;
this.externalPort = externalPort;
this.entryPoint = entryPoint;
this.contextPath = contextPath;
this.internalServerURIBuilder = UriComponentsBuilder
.fromHttpUrl("http://" + this.internalServer);
if (StringUtils.isNotBlank(internalPort)) {
this.internalServerURIBuilder.port(this.internalPort);
}
if (StringUtils.isNotBlank(contextPath) && !contextPath.equals("/")) {
this.internalServerURIBuilder.path(contextPath);
}
this.externalServerURIBuilder = UriComponentsBuilder
.fromHttpUrl(this.externalScheme + "://" + this.externalServer);
if (StringUtils.isNotBlank(externalPort)) {
this.externalServerURIBuilder.port(this.externalPort);
}
if (StringUtils.isNotBlank(contextPath) && !contextPath.equals("/")) {
this.externalServerURIBuilder.path(contextPath);
}
}
public String getExternalScheme() {
@ -86,6 +95,10 @@ public class GuiServiceInfo {
return this.entryPoint;
}
public String getContextPath() {
return this.contextPath;
}
public UriComponentsBuilder getInternalServerURIBuilder() {
return this.internalServerURIBuilder.cloneBuilder();
}

View file

@ -19,7 +19,7 @@ import ch.ethz.seb.sebserver.gbl.profile.GuiProfile;
@GuiProfile
public class WebserviceURIService {
private final String servletContextPath;
private final String contextPath;
private final String webserviceServerAddress;
private final UriComponentsBuilder webserviceURIBuilder;
@ -27,19 +27,23 @@ public class WebserviceURIService {
@Value("${sebserver.gui.webservice.protocol}") final String webserviceProtocol,
@Value("${sebserver.gui.webservice.address}") final String webserviceServerAddress,
@Value("${sebserver.gui.webservice.port}") final String webserviceServerPort,
@Value("${server.servlet.context-path}") final String servletContextPath,
@Value("${sebserver.gui.http.webservice.contextPath}") final String contextPath,
@Value("${sebserver.gui.webservice.apipath}") final String webserviceAPIPath) {
this.servletContextPath = servletContextPath;
this.contextPath = contextPath;
this.webserviceServerAddress =
webserviceProtocol + "://" + webserviceServerAddress + ":" + webserviceServerPort;
this.webserviceURIBuilder = UriComponentsBuilder
.fromHttpUrl(webserviceProtocol + "://" + webserviceServerAddress)
.port(webserviceServerPort)
.path(servletContextPath)
.path(contextPath)
.path(webserviceAPIPath);
}
public String getContextPath() {
return this.contextPath;
}
public String getWebserviceServerAddress() {
return this.webserviceServerAddress;
}
@ -50,14 +54,14 @@ public class WebserviceURIService {
public String getOAuthTokenURI() {
return UriComponentsBuilder.fromHttpUrl(this.webserviceServerAddress)
.path(this.servletContextPath)
.path(this.contextPath)
.path(API.OAUTH_TOKEN_ENDPOINT)
.toUriString();
}
public String getOAuthRevokeTokenURI() {
return UriComponentsBuilder.fromHttpUrl(this.webserviceServerAddress)
.path(this.servletContextPath)
.path(this.contextPath)
.path(API.OAUTH_REVOKE_TOKEN_ENDPOINT)
.toUriString();
}

View file

@ -44,6 +44,7 @@ public class WebserviceInfo {
private static final String WEB_SERVICE_EXAM_API_DISCOVERY_ENDPOINT_KEY =
"sebserver.webservice.api.exam.endpoint.discovery";
private static final String WEB_SERVICE_EXTERNAL_ADDRESS_ALIAS = "sebserver.webservice.lms.address.alias";
private static final String WEB_SERVICE_CONTEXT_PATH = "server.servlet.context-path";
private final String sebServerVersion;
private final String testProperty;
@ -53,6 +54,7 @@ public class WebserviceInfo {
private final String serverPort; // internal
private final String webserverPort; // external
private final String discoveryEndpoint;
private final String contextPath;
private final String serverURLPrefix;
private final boolean isDistributed;
@ -70,6 +72,7 @@ public class WebserviceInfo {
this.serverPort = environment.getRequiredProperty(WEB_SERVICE_SERVER_PORT_KEY);
this.webserverPort = environment.getProperty(WEB_SERVICE_HTTP_PORT);
this.discoveryEndpoint = environment.getRequiredProperty(WEB_SERVICE_EXAM_API_DISCOVERY_ENDPOINT_KEY);
this.contextPath = environment.getProperty(WEB_SERVICE_CONTEXT_PATH, "");
if (StringUtils.isEmpty(this.webserverName)) {
log.warn("NOTE: External server name, property : 'sebserver.webservice.http.external.servername' "
@ -84,7 +87,9 @@ public class WebserviceInfo {
if (StringUtils.isNotBlank(this.webserverPort)) {
builder.port(this.webserverPort);
}
if (StringUtils.isNotBlank(this.contextPath) && !this.contextPath.equals("/")) {
builder.path(this.contextPath);
}
this.serverURLPrefix = builder.toUriString();
this.isDistributed = BooleanUtils.toBoolean(environment.getProperty(
@ -143,6 +148,10 @@ public class WebserviceInfo {
return this.webserverPort;
}
public Object getContextPath() {
return this.contextPath;
}
public String getDiscoveryEndpoint() {
return this.discoveryEndpoint;
}

View file

@ -99,6 +99,7 @@ public class WebserviceInit implements ApplicationListener<ApplicationReadyEvent
}
SEBServerInit.INIT_LOGGER.info("---->");
SEBServerInit.INIT_LOGGER.info("----> Context Path: {}", this.webserviceInfo.getContextPath());
SEBServerInit.INIT_LOGGER.info("----> External-Host URL: {}", this.webserviceInfo.getExternalServerURL());
SEBServerInit.INIT_LOGGER.info("----> LMS-External-Address-Alias: {}",
this.webserviceInfo.getLmsExternalAddressAlias());

View file

@ -20,6 +20,7 @@ sebserver.gui.http.external.port=${sebserver.webservice.http.external.port}
sebserver.gui.http.webservice.scheme=https
sebserver.gui.http.webservice.servername=localhost
sebserver.gui.http.webservice.port=8080
sebserver.gui.http.webservice.contextPath=${server.servlet.context-path}
sebserver.gui.entrypoint=/gui
sebserver.gui.webservice.apipath=${sebserver.webservice.api.admin.endpoint}
@ -45,7 +46,7 @@ sebserver.webservice.api.admin.endpoint=/admin-api/v1
sebserver.webservice.api.admin.clientId=guiClient
sebserver.webservice.api.admin.clientSecret=${sebserver.password}
# NOTE: this is for convinience to have the same as in webservice (ws)
# NOTE: this is for convenience to have the same as in webservice (ws)
sebserver.gui.webservice.protocol=${sebserver.gui.http.webservice.scheme}
sebserver.gui.webservice.address=${sebserver.gui.http.webservice.servername}
sebserver.gui.webservice.port=${sebserver.gui.http.webservice.port}