1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.syncope.client.enduser.pages;
20
21 import org.apache.commons.lang3.StringUtils;
22 import org.apache.syncope.client.enduser.SyncopeEnduserSession;
23 import org.apache.syncope.client.ui.commons.Constants;
24 import org.apache.syncope.client.ui.commons.panels.OIDCC4UIConstants;
25 import org.apache.wicket.authentication.IAuthenticationStrategy;
26 import org.apache.wicket.markup.html.WebPage;
27 import org.apache.wicket.request.mapper.parameter.PageParameters;
28 import org.slf4j.Logger;
29 import org.slf4j.LoggerFactory;
30
31 public class OIDCClientLogin extends WebPage {
32
33 private static final long serialVersionUID = 8581614051773949262L;
34
35 private static final Logger LOG = LoggerFactory.getLogger(OIDCClientLogin.class);
36
37 private static final String OIDC_ACCESS_ERROR = "OIDC access error";
38
39 public OIDCClientLogin(final PageParameters parameters) {
40 super(parameters);
41
42 String token = parameters.get(OIDCC4UIConstants.OIDCC4UI_JWT).toOptionalString();
43 if (StringUtils.isBlank(token)) {
44 LOG.error("No JWT found, redirecting to default greeter");
45
46 PageParameters params = new PageParameters();
47 params.add("errorMessage", OIDC_ACCESS_ERROR);
48 setResponsePage(Login.class, params);
49 }
50
51 IAuthenticationStrategy strategy = getApplication().getSecuritySettings().getAuthenticationStrategy();
52
53 if (SyncopeEnduserSession.get().authenticate(token)) {
54 if (parameters.get(OIDCC4UIConstants.OIDCC4UI_SLO_SUPPORTED).toBoolean(false)) {
55 SyncopeEnduserSession.get().setAttribute(Constants.BEFORE_LOGOUT_PAGE, OIDCClientBeforeLogout.class);
56 }
57
58
59
60 continueToOriginalDestination();
61 setResponsePage(getApplication().getHomePage());
62 } else {
63 PageParameters params = new PageParameters();
64 params.add("errorMessage", OIDC_ACCESS_ERROR);
65 setResponsePage(Login.class, params);
66 }
67 strategy.remove();
68 }
69 }