Skip to content

Commit

Permalink
logging for Moodle autologin
Browse files Browse the repository at this point in the history
  • Loading branch information
anhefti committed Dec 10, 2024
1 parent 6ef05b6 commit b5f4f61
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 170 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import ch.ethz.seb.sebserver.gbl.model.EntityKey;
import ch.ethz.seb.sebserver.gbl.util.Result;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.auth.AuthorizationContextHolder;
import ch.ethz.seb.sebserver.gui.service.remote.webservice.auth.SEBServerAuthorizationContext;
Expand Down Expand Up @@ -67,21 +66,19 @@ public final class InstitutionalAuthenticationEntryPoint implements Authenticati

private final String guiEntryPoint;

private final String remoteProctoringEndpoint;

private final String defaultLogo;
private final WebserviceURIService webserviceURIService;
private final ClientHttpRequestFactoryService clientHttpRequestFactoryService;

protected InstitutionalAuthenticationEntryPoint(
public InstitutionalAuthenticationEntryPoint(
@Value("${sebserver.gui.entrypoint}") final String guiEntryPoint,
@Value("${sebserver.gui.remote.proctoring.entrypoint:/remote-proctoring}") final String remoteProctoringEndpoint,
@Value("${sebserver.gui.defaultLogo:" + Constants.NO_NAME + "}") final String defaultLogoFileName,
final WebserviceURIService webserviceURIService,
final ClientHttpRequestFactoryService clientHttpRequestFactoryService,
final ResourceLoader resourceLoader) {

this.guiEntryPoint = guiEntryPoint;
this.remoteProctoringEndpoint = remoteProctoringEndpoint;
this.webserviceURIService = webserviceURIService;
this.clientHttpRequestFactoryService = clientHttpRequestFactoryService;

Expand Down Expand Up @@ -139,7 +136,7 @@ public void commence(

if (authorizationContext.autoLogin(jwt)) {
log.info("Autologin successful, redirect to: {}", this.guiEntryPoint);
forwardToEntryPoint(request, response, this.guiEntryPoint, true);
forwardToEntryPoint(request, response, /* this.guiEntryPoint */ "/", true);
return;
}
}
Expand Down Expand Up @@ -209,17 +206,6 @@ private void forwardToEntryPoint(
final String entryPoint,
final boolean redirect) throws ServletException, IOException {

final String requestURI = request.getRequestURI();
if (requestURI.startsWith(this.remoteProctoringEndpoint)) {

final RequestDispatcher dispatcher = request
.getServletContext()
.getRequestDispatcher(this.remoteProctoringEndpoint);

dispatcher.forward(request, response);
return;
}

if (redirect) {
response.sendRedirect(entryPoint);
} else {
Expand Down
103 changes: 0 additions & 103 deletions src/main/java/ch/ethz/seb/sebserver/gui/ProctoringServlet.java

This file was deleted.

67 changes: 30 additions & 37 deletions src/main/java/ch/ethz/seb/sebserver/gui/RAPConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,6 @@ public InputStream getResourceAsStream(final String resourceName) throws IOExcep

application.addEntryPoint(guiEntrypoint, new RAPSpringEntryPointFactory(), properties);

properties.put(WebClient.PAGE_TITLE, "SEB Server Proctoring");
properties.put(WebClient.BODY_HTML, "<big>Loading Application<big>");
properties.put(WebClient.THEME_ID, DEFAULT_THEME_NAME);
properties.put(WebClient.FAVICON, "fav_icon");

application.addEntryPoint(proctoringEntrypoint, new RAPRemoteProcotringEntryPointFactory(), properties);

} catch (final RuntimeException re) {
throw re;
} catch (final Exception e) {
Expand All @@ -103,36 +96,36 @@ public interface EntryPointService {

}

public static final class RAPRemoteProcotringEntryPointFactory implements EntryPointFactory {

@Override
public EntryPoint create() {
return new AbstractEntryPoint() {

private static final long serialVersionUID = -1299125117752916270L;

@Override
protected void createContents(final Composite parent) {

final HttpSession httpSession = RWT
.getUISession(parent.getDisplay())
.getHttpSession();

final WebApplicationContext webApplicationContext = getWebApplicationContext(httpSession);
final boolean authenticated = isAuthenticated(httpSession, webApplicationContext);
if (authenticated) {

final EntryPointService entryPointService = webApplicationContext
.getBean(EntryPointService.class);
entryPointService.loadProctoringView(parent);
} else {
final HttpServletResponse response = RWT.getResponse();
response.setStatus(HttpStatus.FORBIDDEN.value());
}
}
};
}
}
// public static final class RAPRemoteProcotringEntryPointFactory implements EntryPointFactory {
//
// @Override
// public EntryPoint create() {
// return new AbstractEntryPoint() {
//
// private static final long serialVersionUID = -1299125117752916270L;
//
// @Override
// protected void createContents(final Composite parent) {
//
// final HttpSession httpSession = RWT
// .getUISession(parent.getDisplay())
// .getHttpSession();
//
// final WebApplicationContext webApplicationContext = getWebApplicationContext(httpSession);
// final boolean authenticated = isAuthenticated(httpSession, webApplicationContext);
// if (authenticated) {
//
// final EntryPointService entryPointService = webApplicationContext
// .getBean(EntryPointService.class);
// entryPointService.loadProctoringView(parent);
// } else {
// final HttpServletResponse response = RWT.getResponse();
// response.setStatus(HttpStatus.FORBIDDEN.value());
// }
// }
// };
// }
// }

public static final class RAPSpringEntryPointFactory implements EntryPointFactory {

Expand Down
12 changes: 0 additions & 12 deletions src/main/java/ch/ethz/seb/sebserver/gui/RAPSpringConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.springframework.boot.web.servlet.ServletContextInitializer;
import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand Down Expand Up @@ -72,17 +71,6 @@ public ServletRegistrationBean<RWTServlet> servletRegistrationBean() {
this.remoteProctoringEndpoint + "/*");
}

@Bean
public ServletRegistrationBean<ProctoringServlet> servletProctoringRegistrationBean(
final ApplicationContext applicationContext) {

final ProctoringServlet proctoringServlet = applicationContext
.getBean(ProctoringServlet.class);
return new ServletRegistrationBean<>(
proctoringServlet,
this.remoteProctoringEndpoint + this.remoteProctoringViewServletEndpoint + "/*");
}

@Bean
public MessageSource messageSource() {
final ReloadableResourceBundleMessageSource reloadableResourceBundleMessageSource =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ public class MonitoringRunningExam implements TemplateComposer {
new LocTextKey("sebserver.monitoring.exam.connection.action.closeTownhall.confirm");
private static final LocTextKey CONFIRM_DISABLE_SELECTED =
new LocTextKey("sebserver.monitoring.exam.connection.action.instruction.disable.selected.confirm");
private static final LocTextKey NOT_RUNNING_MESSAGE =
new LocTextKey("sebserver.monitoring.exam.notrunning.message");

private final ServerPushService serverPushService;
private final PageService pageService;
Expand Down Expand Up @@ -174,6 +176,11 @@ public void compose(final PageContext pageContext) {
new LocTextKey(
"sebserver.monitoring.exam",
StringEscapeUtils.escapeXml11(exam.name)));

if (exam.status != Exam.ExamStatus.RUNNING) {
pageContext.publishInfo(NOT_RUNNING_MESSAGE);
return;
}

final Composite tablePane = new Composite(content, SWT.NONE);
tablePane.setLayout(new GridLayout());
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2281,7 +2281,7 @@ sebserver.exam.overall.action.category.proctoring=Live Proctoring
sebserver.monitoring.exam.action.proctoring.openTownhall=Open Townhall
sebserver.monitoring.exam.action.proctoring.showTownhall=Show Townhall
sebserver.monitoring.exam.action.proctoring.closeTownhall=Close Townhall

sebserver.monitoring.exam.notrunning.message=This Exam is not running (anymore)!
sebserver.exam.overall.action.category.screenproctoring=Screen Proctoring

sebserver.monitoring.exam.proctoring.room.all.name=Townhall Room
Expand Down

0 comments on commit b5f4f61

Please sign in to comment.