removed openAIREUser cookie

This commit is contained in:
Konstantinos Spyrou 2021-07-19 11:38:24 +00:00
parent 026747dcaa
commit a34bed1d62
1 changed files with 0 additions and 45 deletions

View File

@ -1,7 +1,5 @@
package eu.dnetlib.repo.manager.config;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import org.apache.log4j.Logger;
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
@ -15,7 +13,6 @@ import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.Base64;
import java.util.Date;
import java.util.regex.Matcher;
@ -41,35 +38,6 @@ public class FrontEndLinkURIAuthenticationSuccessHandler implements Authenticati
OIDCAuthenticationToken authOIDC = (OIDCAuthenticationToken) authentication;
request.getSession().setAttribute(FindByIndexNameSessionRepository.PRINCIPAL_NAME_INDEX_NAME, authOIDC.getUserInfo().getEmail());
JsonObject userInfo = new JsonObject();
if (authOIDC.getUserInfo().getSub() == null)
userInfo.addProperty("sub", "");
else
userInfo.addProperty("sub", URLEncoder.encode(authOIDC.getUserInfo().getSub(), "UTF-8"));
if (authOIDC.getUserInfo().getName() != null)
userInfo.addProperty("fullname", URLEncoder.encode(authOIDC.getUserInfo().getName(), "UTF-8"));
if (authOIDC.getUserInfo().getGivenName() == null)
userInfo.addProperty("firstname", "");
else
userInfo.addProperty("firstname", URLEncoder.encode(authOIDC.getUserInfo().getGivenName(), "UTF-8") + "");
if (authOIDC.getUserInfo().getFamilyName() == null)
userInfo.addProperty("lastname", "");
else
userInfo.addProperty("lastname", URLEncoder.encode(authOIDC.getUserInfo().getFamilyName(), "UTF-8") + "");
userInfo.addProperty("email", authOIDC.getUserInfo().getEmail() + "");
// if (authOIDC.getUserInfo().getSource().getAsJsonArray("edu_person_entitlements") == null)
// userInfo.addProperty("role", "");
// else
// userInfo.addProperty("role", URLEncoder.encode(authOIDC.getUserInfo()
// .getSource().getAsJsonArray("edu_person_entitlements").toString(), "UTF-8") + "");
Cookie accessToken = new Cookie("AccessToken", authOIDC.getAccessTokenValue());
String regex = "^([A-Za-z0-9-_=]+)\\.([A-Za-z0-9-_=]+)\\.?([A-Za-z0-9-_.+=]*)$";
Matcher matcher = Pattern.compile(regex).matcher(authOIDC.getAccessTokenValue());
@ -83,19 +51,6 @@ public class FrontEndLinkURIAuthenticationSuccessHandler implements Authenticati
accessToken.setDomain(".openaire.eu");
accessToken.setPath("/");
Cookie openAIREUser = new Cookie("openAIREUser", URLEncoder.encode(new Gson().toJson(userInfo), "UTF-8"));
openAIREUser.setMaxAge(accessToken.getMaxAge());
openAIREUser.setPath("/");
if (aai_mode.equalsIgnoreCase("production") || aai_mode.equalsIgnoreCase("beta"))
openAIREUser.setDomain(".openaire.eu");
// if (frontDomain!=null) {
// accessToken.setDomain(frontDomain);
// // openAIREUser.setDomain(frontDomain);
// }
response.addCookie(openAIREUser);
response.addCookie(accessToken);
response.sendRedirect(frontEndURI);
}