1
|
/*
|
2
|
package eu.dnetlib.repo.manager.service.utils;
|
3
|
|
4
|
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
|
5
|
import org.springframework.security.core.Authentication;
|
6
|
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
|
7
|
|
8
|
import javax.servlet.ServletException;
|
9
|
import javax.servlet.http.Cookie;
|
10
|
import javax.servlet.http.HttpServletRequest;
|
11
|
import javax.servlet.http.HttpServletResponse;
|
12
|
import java.io.IOException;
|
13
|
|
14
|
public class FrontEndLinkURIAuthenticationSuccessHandler implements AuthenticationSuccessHandler {
|
15
|
|
16
|
private String frontEndURI;
|
17
|
|
18
|
@Override
|
19
|
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
|
20
|
OIDCAuthenticationToken authOIDC = (OIDCAuthenticationToken) authentication;
|
21
|
Cookie sessionCookie = new Cookie("currentUser", authOIDC.getSub());
|
22
|
int expireSec = -1;
|
23
|
sessionCookie.setMaxAge(expireSec);
|
24
|
sessionCookie.setPath("/");
|
25
|
response.addCookie(sessionCookie);
|
26
|
response.sendRedirect(frontEndURI);
|
27
|
}
|
28
|
|
29
|
public String getFrontEndURI() {
|
30
|
return frontEndURI;
|
31
|
}
|
32
|
|
33
|
public void setFrontEndURI(String frontEndURI) {
|
34
|
this.frontEndURI = frontEndURI;
|
35
|
}
|
36
|
}
|
37
|
|
38
|
*/
|