Add RequestActivationCode.java and .jsp, Fix titles of .jps pages, Fix email messages
This commit is contained in:
parent
a1d622e2f1
commit
4eb8263687
|
@ -98,7 +98,9 @@ public class ForgotPasswordServlet extends HttpServlet {
|
||||||
"<p> The verification code is " + vCode + "</p>" +
|
"<p> The verification code is " + vCode + "</p>" +
|
||||||
"Click the URL below and proceed with verification." +
|
"Click the URL below and proceed with verification." +
|
||||||
"<p><a href=" + resultPathWithVCode + ">" + resultPathWithVCode + "</a></p>" +
|
"<p><a href=" + resultPathWithVCode + ">" + resultPathWithVCode + "</a></p>" +
|
||||||
"<p>Thank you</p>";
|
"<p>The verification code is valid for 24 hours.</p>" +
|
||||||
|
"<p>Thank you,</p>" +
|
||||||
|
"<p>OpenAIRE technical team</p>";
|
||||||
|
|
||||||
String verificationCodeSubject = "Your OpenAIRE password reset request";
|
String verificationCodeSubject = "Your OpenAIRE password reset request";
|
||||||
|
|
||||||
|
|
|
@ -109,14 +109,16 @@ public class RegisterServlet extends HttpServlet {
|
||||||
|
|
||||||
String verificationCodeMsg = "<p>Hello " + username + ",</p>" +
|
String verificationCodeMsg = "<p>Hello " + username + ",</p>" +
|
||||||
"<p> A request has been made to verify your email and activate your OpenAIRE account. To activate your " +
|
"<p> A request has been made to verify your email and activate your OpenAIRE account. To activate your " +
|
||||||
"account, you will need to submit your username and this activation code in order to verify that the" +
|
"account, you will need to submit your username and this activation code in order to verify that the " +
|
||||||
"request was legitimate.</p>" +
|
"request was legitimate.</p>" +
|
||||||
"<p>" +
|
"<p>" +
|
||||||
"The activation code is " + vCode +
|
"The activation code is " + vCode +
|
||||||
"</p>" +
|
"</p>" +
|
||||||
"Click the URL below and proceed with activating your password." +
|
"Click the URL below and proceed with activating your password." +
|
||||||
"<p><a href=" + resultPathWithVCode + ">" + resultPathWithVCode + "</a></p>" +
|
"<p><a href=" + resultPathWithVCode + ">" + resultPathWithVCode + "</a></p>" +
|
||||||
"<p>Thank you</p>";
|
"<p>The activation code is valid for 24 hours.</p>" +
|
||||||
|
"<p>Thank you,</p>" +
|
||||||
|
"<p>OpenAIRE technical team</p>";
|
||||||
|
|
||||||
String verificationCodeSubject = "Activate your OpenAIRE account";
|
String verificationCodeSubject = "Activate your OpenAIRE account";
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,8 @@ public class RemindUsernameServlet extends HttpServlet {
|
||||||
String verificationCodeMsg = "<p>Hello,</p>" +
|
String verificationCodeMsg = "<p>Hello,</p>" +
|
||||||
"<p> A username reminder has been requested for your OpenAIRE account.</p>" +
|
"<p> A username reminder has been requested for your OpenAIRE account.</p>" +
|
||||||
"<p> Your username is " + username + ".</p>" +
|
"<p> Your username is " + username + ".</p>" +
|
||||||
"<p> Thank you </p>";
|
"<p> Thank you, </p>" +
|
||||||
|
"<p> OpenAIRE technical team</p>";
|
||||||
|
|
||||||
String verificationCodeSubject = "Your OpenAIRE username";
|
String verificationCodeSubject = "Your OpenAIRE username";
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,159 @@
|
||||||
|
package eu.dnetlib.openaire.usermanagement;
|
||||||
|
|
||||||
|
import eu.dnetlib.openaire.user.utils.EmailSender;
|
||||||
|
import eu.dnetlib.openaire.user.utils.LDAPActions;
|
||||||
|
import eu.dnetlib.openaire.user.utils.VerificationActions;
|
||||||
|
import eu.dnetlib.openaire.user.utils.VerifyRecaptcha;
|
||||||
|
import eu.dnetlib.openaire.usermanagement.utils.UrlConstructor;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.web.context.support.SpringBeanAutowiringSupport;
|
||||||
|
|
||||||
|
import javax.mail.MessagingException;
|
||||||
|
import javax.servlet.ServletConfig;
|
||||||
|
import javax.servlet.ServletException;
|
||||||
|
import javax.servlet.http.HttpServlet;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by sofia on 14/5/2018.
|
||||||
|
*/
|
||||||
|
public class RequestActivationCodeServlet extends HttpServlet {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private VerificationActions verificationActions;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private LDAPActions ldapActions;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EmailSender emailSender;
|
||||||
|
|
||||||
|
@Value("${oidc.home}")
|
||||||
|
private String oidcHomeUrl;
|
||||||
|
|
||||||
|
@Value("${google.recaptcha.secret}")
|
||||||
|
private String secret;
|
||||||
|
|
||||||
|
@Value("${google.recaptcha.key}")
|
||||||
|
private String sitekey;
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(RequestActivationCodeServlet.class);
|
||||||
|
|
||||||
|
public void init(ServletConfig config) throws ServletException {
|
||||||
|
super.init(config);
|
||||||
|
SpringBeanAutowiringSupport.processInjectionBasedOnServletContext(this,
|
||||||
|
config.getServletContext());
|
||||||
|
config.getServletContext().setAttribute("sitekey", sitekey);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||||
|
String formUsername = request.getParameter("username").trim();
|
||||||
|
|
||||||
|
String gRecaptchaResponse = request.getParameter("g-recaptcha-response");
|
||||||
|
|
||||||
|
HttpSession session = request.getSession();
|
||||||
|
session.setAttribute("homeUrl", oidcHomeUrl);
|
||||||
|
|
||||||
|
if (formUsername == null) {
|
||||||
|
request.getSession().setAttribute("message", "Error reading username.");
|
||||||
|
response.sendRedirect("./requestActivationCode.jsp");
|
||||||
|
|
||||||
|
} else if (formUsername.isEmpty()) {
|
||||||
|
request.getSession().setAttribute("message", "Please enter your username.");
|
||||||
|
response.sendRedirect("./requestActivationCode.jsp");
|
||||||
|
|
||||||
|
} else if (!VerifyRecaptcha.verify(gRecaptchaResponse, secret)) {
|
||||||
|
request.getSession().setAttribute("reCAPTCHA_message", "You missed the reCAPTCHA validation!");
|
||||||
|
response.sendRedirect("./requestActivationCode.jsp");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (ldapActions.isZombieUsersUsername(formUsername)) {
|
||||||
|
logger.info("User " + formUsername + " is zombie user!");
|
||||||
|
|
||||||
|
UUID verificationCode = UUID.randomUUID();
|
||||||
|
Date creationDate = new Date();
|
||||||
|
String vCode = verificationCode.toString();
|
||||||
|
|
||||||
|
Timestamp timestamp = new Timestamp(creationDate.getTime());
|
||||||
|
|
||||||
|
if (!verificationActions.verificationEntryExists(formUsername)) {
|
||||||
|
verificationActions.addVerificationEntry(formUsername, vCode, timestamp);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
verificationActions.updateVerificationEntry(formUsername, vCode, timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
String resultPath = UrlConstructor.getRedirectUrl(request, "activate.jsp");
|
||||||
|
String resultPathWithVCode = UrlConstructor.getVerificationLink(resultPath, vCode);
|
||||||
|
|
||||||
|
String verificationCodeMsg = "<p>Hello " + formUsername + ",</p>" +
|
||||||
|
"<p> A request has been made to get a new activation code to verify your email and activate your OpenAIRE account. To activate your " +
|
||||||
|
"account, you will need to submit your username and this activation code in order to verify that the " +
|
||||||
|
"request was legitimate.</p>" +
|
||||||
|
"<p>" +
|
||||||
|
"The activation code is " + vCode +
|
||||||
|
"</p>" +
|
||||||
|
"Click the URL below and proceed with activating your password." +
|
||||||
|
"<p><a href=" + resultPathWithVCode + ">" + resultPathWithVCode + "</a></p>" +
|
||||||
|
"<p>The activation code is valid for 24 hours.</p>" +
|
||||||
|
"<p>Thank you,</p>" +
|
||||||
|
"<p>OpenAIRE technical team</p>";
|
||||||
|
|
||||||
|
String verificationCodeSubject = "Request a new activation code for your OpenAIRE account";
|
||||||
|
|
||||||
|
String email = ldapActions.getZombieUsersEmail(formUsername);
|
||||||
|
|
||||||
|
if (email != null && !email.isEmpty()) {
|
||||||
|
emailSender.sendEmail(email, verificationCodeSubject, verificationCodeMsg);
|
||||||
|
logger.info("Sending activation code to user: " + formUsername);
|
||||||
|
}
|
||||||
|
|
||||||
|
response.sendRedirect("./activate.jsp");
|
||||||
|
|
||||||
|
} else if (ldapActions.usernameExists(formUsername)) {
|
||||||
|
logger.info("User " + formUsername + " has already activated his account.");
|
||||||
|
request.getSession().setAttribute("message", "Your account is already activated.");
|
||||||
|
response.sendRedirect("./requestActivationCode.jsp");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
logger.info("No user with username: " + formUsername);
|
||||||
|
request.getSession().setAttribute("message", "There is no user registered with that username.");
|
||||||
|
response.sendRedirect("./requestActivationCode.jsp");
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (MessagingException e) {
|
||||||
|
logger.error("Error in sending email", e);
|
||||||
|
request.getSession().setAttribute("message", "Error sending email");
|
||||||
|
response.sendRedirect("./requestActivationCode.jsp");
|
||||||
|
} catch (Exception ldape) {
|
||||||
|
logger.error("Could not find zombie user with username " + formUsername, ldape);
|
||||||
|
response.sendRedirect(UrlConstructor.getRedirectUrl(request, "error.jsp"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOidcHomeUrl() {
|
||||||
|
return oidcHomeUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOidcHomeUrl(String oidcHomeUrl) {
|
||||||
|
this.oidcHomeUrl = oidcHomeUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
package eu.dnetlib.openaire.usermanagement.security;
|
package eu.dnetlib.openaire.usermanagement.security;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
|
import org.mitre.openid.connect.model.OIDCAuthenticationToken;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
|
@ -29,15 +30,19 @@ public class FrontEndLinkURIAuthenticationSuccessHandler implements Authenticati
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Cookie jwt = new Cookie("XCsrfToken", JWTGenerator.generateToken(authOIDC, "my-very-secret"));
|
Cookie jwt = new Cookie("XCsrfToken", JWTGenerator.generateToken(authOIDC, "my-very-secret"));
|
||||||
|
// Cookie openAIREUser = new Cookie("openAIREUser", new Gson().toJson(JWTGenerator.generateJsonToken(authOIDC)));
|
||||||
Cookie accessToken = new Cookie("AccessToken", authOIDC.getAccessTokenValue());
|
Cookie accessToken = new Cookie("AccessToken", authOIDC.getAccessTokenValue());
|
||||||
|
|
||||||
// Expire the cookies in four hours (4 * 3600)
|
// Expire the cookies in four hours (4 * 3600)
|
||||||
jwt.setMaxAge(14400);
|
jwt.setMaxAge(14400);
|
||||||
|
// openAIREUser.setMaxAge(14400);
|
||||||
accessToken.setMaxAge(14400);
|
accessToken.setMaxAge(14400);
|
||||||
|
|
||||||
//TODO DELETE LOG
|
//TODO DELETE LOG
|
||||||
logger.info("\n////////////////////////////////////////////////////////////////////////////////////////////////\n");
|
logger.info("\n////////////////////////////////////////////////////////////////////////////////////////////////\n");
|
||||||
|
logger.info("jwt: " + JWTGenerator.generateToken(authOIDC, "my-very-secret"));
|
||||||
logger.info("access token: " + authOIDC.getAccessTokenValue());
|
logger.info("access token: " + authOIDC.getAccessTokenValue());
|
||||||
|
// logger.info("openAIREUser: " + JWTGenerator.generateJsonToken(authOIDC));
|
||||||
logger.info("\n////////////////////////////////////////////////////////////////////////////////////////////////\n");
|
logger.info("\n////////////////////////////////////////////////////////////////////////////////////////////////\n");
|
||||||
|
|
||||||
//TODO DELETE LOG
|
//TODO DELETE LOG
|
||||||
|
@ -48,10 +53,13 @@ public class FrontEndLinkURIAuthenticationSuccessHandler implements Authenticati
|
||||||
|
|
||||||
jwt.setPath(frontPath);
|
jwt.setPath(frontPath);
|
||||||
if (frontDomain!=null) jwt.setDomain(frontDomain);
|
if (frontDomain!=null) jwt.setDomain(frontDomain);
|
||||||
|
// openAIREUser.setPath(frontPath);
|
||||||
|
// if (frontDomain!=null) openAIREUser.setDomain(frontDomain);
|
||||||
accessToken.setPath(frontPath);
|
accessToken.setPath(frontPath);
|
||||||
if (frontDomain!=null) accessToken.setDomain(frontDomain);
|
if (frontDomain!=null) accessToken.setDomain(frontDomain);
|
||||||
|
|
||||||
response.addCookie(jwt);
|
response.addCookie(jwt);
|
||||||
|
// response.addCookie(openAIREUser);
|
||||||
response.addCookie(accessToken);
|
response.addCookie(accessToken);
|
||||||
response.sendRedirect(frontEndURI);
|
response.sendRedirect(frontEndURI);
|
||||||
|
|
||||||
|
|
|
@ -50,16 +50,16 @@ public class JWTGenerator {
|
||||||
if (authOIDC.getUserInfo().getGivenName() == null){
|
if (authOIDC.getUserInfo().getGivenName() == null){
|
||||||
logger.info("User: " + authOIDC.getUserInfo().getName() + "doesn't have first name");
|
logger.info("User: " + authOIDC.getUserInfo().getName() + "doesn't have first name");
|
||||||
claims.put("firstname", URLEncoder.encode(" ", "UTF-8") + "");
|
claims.put("firstname", URLEncoder.encode(" ", "UTF-8") + "");
|
||||||
|
// claims.put("firstname", "");
|
||||||
} else {
|
} else {
|
||||||
claims.put("firstname", URLEncoder.encode(authOIDC.getUserInfo().getGivenName(), "UTF-8") + "");
|
claims.put("firstname", URLEncoder.encode(authOIDC.getUserInfo().getGivenName(), "UTF-8") + "");
|
||||||
|
|
||||||
}
|
}
|
||||||
if (authOIDC.getUserInfo().getFamilyName() == null){
|
if (authOIDC.getUserInfo().getFamilyName() == null){
|
||||||
logger.info("User: " + authOIDC.getUserInfo().getName() + "doesn't have first name");
|
logger.info("User: " + authOIDC.getUserInfo().getName() + "doesn't have first name");
|
||||||
claims.put("lastname", URLEncoder.encode(" ", "UTF-8") + "");
|
claims.put("lastname", URLEncoder.encode(" ", "UTF-8") + "");
|
||||||
|
// claims.put("lastname", "");
|
||||||
} else {
|
} else {
|
||||||
claims.put("lastname", URLEncoder.encode(authOIDC.getUserInfo().getFamilyName(), "UTF-8") + "");
|
claims.put("lastname", URLEncoder.encode(authOIDC.getUserInfo().getFamilyName(), "UTF-8") + "");
|
||||||
|
|
||||||
}
|
}
|
||||||
claims.put("email", authOIDC.getUserInfo().getEmail() + "");
|
claims.put("email", authOIDC.getUserInfo().getEmail() + "");
|
||||||
// claims.put("role", URLEncoder.encode(userInfo.getAsJsonArray("edu_person_entitlements").toString(), "UTF-8") + "");
|
// claims.put("role", URLEncoder.encode(userInfo.getAsJsonArray("edu_person_entitlements").toString(), "UTF-8") + "");
|
||||||
|
@ -72,6 +72,7 @@ public class JWTGenerator {
|
||||||
if (userInfo.getAsJsonArray("edu_person_entitlements") == null){
|
if (userInfo.getAsJsonArray("edu_person_entitlements") == null){
|
||||||
logger.info("User: " + authOIDC.getUserInfo().getName() + "doesn't have role");
|
logger.info("User: " + authOIDC.getUserInfo().getName() + "doesn't have role");
|
||||||
claims.put("role", URLEncoder.encode(" ", "UTF-8") + "");
|
claims.put("role", URLEncoder.encode(" ", "UTF-8") + "");
|
||||||
|
//s claims.put("role", "");
|
||||||
} else {
|
} else {
|
||||||
claims.put("role", URLEncoder.encode(userInfo.getAsJsonArray("edu_person_entitlements").toString(), "UTF-8") + "");
|
claims.put("role", URLEncoder.encode(userInfo.getAsJsonArray("edu_person_entitlements").toString(), "UTF-8") + "");
|
||||||
}
|
}
|
||||||
|
@ -103,11 +104,11 @@ public class JWTGenerator {
|
||||||
// logger.info("expirationTime: " + exp);
|
// logger.info("expirationTime: " + exp);
|
||||||
// logger.info("\n////////////////////////////////////////////////////////////////////////////////////////////////\n");
|
// logger.info("\n////////////////////////////////////////////////////////////////////////////////////////////////\n");
|
||||||
|
|
||||||
return Jwts.builder()
|
return Jwts.builder()
|
||||||
.setClaims(claims)
|
.setClaims(claims)
|
||||||
.setExpiration(exp)
|
.setExpiration(exp)
|
||||||
.signWith(SignatureAlgorithm.HS512, secret)
|
.signWith(SignatureAlgorithm.HS512, secret)
|
||||||
.compact();
|
.compact();
|
||||||
|
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -120,6 +121,62 @@ public class JWTGenerator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static JsonObject generateJsonToken(OIDCAuthenticationToken authOIDC) {
|
||||||
|
try {
|
||||||
|
|
||||||
|
JsonObject userInfo = authOIDC.getUserInfo().getSource();
|
||||||
|
JsonObject userInfo2 = new JsonObject();
|
||||||
|
|
||||||
|
if (authOIDC.getUserInfo().getSub() == null) {
|
||||||
|
logger.info("User doesn't have sub");
|
||||||
|
userInfo2.addProperty("sub", "");
|
||||||
|
} else {
|
||||||
|
userInfo2.addProperty("sub", URLEncoder.encode(authOIDC.getUserInfo().getSub(), "UTF-8"));
|
||||||
|
}
|
||||||
|
if (authOIDC.getUserInfo().getName() == null) {
|
||||||
|
logger.info("User doesn't have fullname");
|
||||||
|
userInfo2.addProperty("fullname", "");
|
||||||
|
} else {
|
||||||
|
userInfo2.addProperty("fullname", URLEncoder.encode(authOIDC.getUserInfo().getName(), "UTF-8"));
|
||||||
|
}
|
||||||
|
if (authOIDC.getUserInfo().getGivenName() == null){
|
||||||
|
logger.info("User: " + authOIDC.getUserInfo().getName() + "doesn't have first name");
|
||||||
|
// userInfo2.addProperty("firstname", URLEncoder.encode(" ", "UTF-8") + "");
|
||||||
|
userInfo2.addProperty("firstname", "");
|
||||||
|
} else {
|
||||||
|
userInfo2.addProperty("firstname", URLEncoder.encode(authOIDC.getUserInfo().getGivenName(), "UTF-8") + "");
|
||||||
|
}
|
||||||
|
if (authOIDC.getUserInfo().getFamilyName() == null){
|
||||||
|
logger.info("User: " + authOIDC.getUserInfo().getName() + "doesn't have first name");
|
||||||
|
// userInfo2.addProperty("lastname", URLEncoder.encode(" ", "UTF-8") + "");
|
||||||
|
userInfo2.addProperty("lastname", "");
|
||||||
|
} else {
|
||||||
|
userInfo2.addProperty("lastname", URLEncoder.encode(authOIDC.getUserInfo().getFamilyName(), "UTF-8") + "");
|
||||||
|
}
|
||||||
|
userInfo2.addProperty("email", authOIDC.getUserInfo().getEmail() + "");
|
||||||
|
|
||||||
|
if (userInfo.getAsJsonArray("edu_person_entitlements") == null){
|
||||||
|
logger.info("User: " + authOIDC.getUserInfo().getName() + "doesn't have role");
|
||||||
|
// userInfo2.addProperty("role", URLEncoder.encode(" ", "UTF-8") + "");
|
||||||
|
userInfo2.addProperty("role", "");
|
||||||
|
} else {
|
||||||
|
userInfo2.addProperty("role", URLEncoder.encode(userInfo.getAsJsonArray("edu_person_entitlements").toString(), "UTF-8") + "");
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.info("UserINFO: " + userInfo2.toString());
|
||||||
|
return userInfo2;
|
||||||
|
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
logger.error("UnsupportedEncodingException UTF-8 ", e);
|
||||||
|
JsonObject error = new JsonObject();
|
||||||
|
error.addProperty("error", "UnsupportedEncodingException UTF-8 " + e);
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//TODO DELETE IF IT IS NOT NECESSARY
|
//TODO DELETE IF IT IS NOT NECESSARY
|
||||||
public static String generateAccessToken(OIDCAuthenticationToken authOIDC, String secret) {
|
public static String generateAccessToken(OIDCAuthenticationToken authOIDC, String secret) {
|
||||||
Claims claims = Jwts.claims().setId(authOIDC.getAccessTokenValue());
|
Claims claims = Jwts.claims().setId(authOIDC.getAccessTokenValue());
|
||||||
|
@ -141,14 +198,14 @@ public class JWTGenerator {
|
||||||
|
|
||||||
JsonObject userInfo = user.getSource();
|
JsonObject userInfo = user.getSource();
|
||||||
|
|
||||||
Claims claims = Jwts.claims().setSubject(user.getSub());
|
Claims claims = Jwts.claims().setSubject(user.getSub());
|
||||||
claims.put("email", user.getEmail() + "");
|
claims.put("email", user.getEmail() + "");
|
||||||
claims.put("role", URLEncoder.encode(userInfo.getAsJsonArray("edu_person_entitlements").toString(), "UTF-8") + "");
|
claims.put("role", URLEncoder.encode(userInfo.getAsJsonArray("edu_person_entitlements").toString(), "UTF-8") + "");
|
||||||
|
|
||||||
return Jwts.builder()
|
return Jwts.builder()
|
||||||
.setClaims(claims)
|
.setClaims(claims)
|
||||||
.signWith(SignatureAlgorithm.HS512, secret)
|
.signWith(SignatureAlgorithm.HS512, secret)
|
||||||
.compact();
|
.compact();
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
logger.error("UnsupportedEncodingException UTF-8 ", e);
|
logger.error("UnsupportedEncodingException UTF-8 ", e);
|
||||||
|
@ -160,6 +217,7 @@ public class JWTGenerator {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// How to add it manually
|
// How to add it manually
|
||||||
// long nowMillis = System.currentTimeMillis();
|
// long nowMillis = System.currentTimeMillis();
|
||||||
// //This is my token
|
// //This is my token
|
||||||
|
|
|
@ -106,6 +106,18 @@
|
||||||
<url-pattern>/remindUsername</url-pattern>
|
<url-pattern>/remindUsername</url-pattern>
|
||||||
</servlet-mapping>
|
</servlet-mapping>
|
||||||
|
|
||||||
|
<servlet>
|
||||||
|
<servlet-name>RequestActivationCodeServlet</servlet-name>
|
||||||
|
<display-name>Request an activation code</display-name>
|
||||||
|
<servlet-class>eu.dnetlib.openaire.usermanagement.RequestActivationCodeServlet</servlet-class>
|
||||||
|
<load-on-startup>1</load-on-startup>
|
||||||
|
</servlet>
|
||||||
|
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>RequestActivationCodeServlet</servlet-name>
|
||||||
|
<url-pattern>/requestActivationCode</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
|
|
||||||
|
|
||||||
<filter>
|
<filter>
|
||||||
<filter-name>CorsFilter</filter-name>
|
<filter-name>CorsFilter</filter-name>
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<base href=".">
|
<base href=".">
|
||||||
<title>OpenAIRE - Forgot password, verification code</title>
|
<title>OpenAIRE - Activation</title>
|
||||||
<script src="./js/jquery.js"></script>
|
<script src="./js/jquery.js"></script>
|
||||||
<script src="./js/uikit.js"></script>
|
<script src="./js/uikit.js"></script>
|
||||||
<script src="./js/validation.js"></script>
|
<script src="./js/validation.js"></script>
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<title>OpenAIRE - Forgot password</title>
|
<title>OpenAIRE - Email Sent</title>
|
||||||
<script src="./js/jquery.js"></script>
|
<script src="./js/jquery.js"></script>
|
||||||
<script src="./js/uikit.js"></script>
|
<script src="./js/uikit.js"></script>
|
||||||
<script src="./js/validation.js"></script>
|
<script src="./js/validation.js"></script>
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<base href=".">
|
<base href=".">
|
||||||
<title>OpenAIRE Single Sign-On Service</title>
|
<title>OpenAIRE - Error</title>
|
||||||
<script src="./js/jquery.js"></script>
|
<script src="./js/jquery.js"></script>
|
||||||
<script src="./js/uikit.js"></script>
|
<script src="./js/uikit.js"></script>
|
||||||
<script src="./js/validation.js"></script>
|
<script src="./js/validation.js"></script>
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<base href=".">
|
<base href=".">
|
||||||
<title>OpenAIRE Single Sign-On Service</title>
|
<title>OpenAIRE - Error 404</title>
|
||||||
<script src="./js/jquery.js"></script>
|
<script src="./js/jquery.js"></script>
|
||||||
<script src="./js/uikit.js"></script>
|
<script src="./js/uikit.js"></script>
|
||||||
<script src="./js/validation.js"></script>
|
<script src="./js/validation.js"></script>
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<base href=".">
|
<base href=".">
|
||||||
<title>OpenAIRE Single Sign-On Service</title>
|
<title>OpenAIRE - Expired Verification Code</title>
|
||||||
<script src="./js/jquery.js"></script>
|
<script src="./js/jquery.js"></script>
|
||||||
<script src="./js/uikit.js"></script>
|
<script src="./js/uikit.js"></script>
|
||||||
<script src="./js/validation.js"></script>
|
<script src="./js/validation.js"></script>
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<title>OpenAIRE - Forgot password</title>
|
<title>OpenAIRE - Successful registration</title>
|
||||||
<script src="./js/jquery.js"></script>
|
<script src="./js/jquery.js"></script>
|
||||||
<script src="./js/uikit.js"></script>
|
<script src="./js/uikit.js"></script>
|
||||||
<script src="./js/validation.js"></script>
|
<script src="./js/validation.js"></script>
|
||||||
|
|
|
@ -0,0 +1,122 @@
|
||||||
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||||
|
<%--
|
||||||
|
Created by IntelliJ IDEA.
|
||||||
|
User: sofia
|
||||||
|
Date: 14/5/2018
|
||||||
|
Time: 5:37 μμ
|
||||||
|
To change this template use File | Settings | File Templates.
|
||||||
|
--%>
|
||||||
|
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<base href=".">
|
||||||
|
<script src="./js/jquery.js"></script>
|
||||||
|
<script src="./js/uikit.js"></script>
|
||||||
|
<link rel="stylesheet" style="text/css" href="./css/theme.css">
|
||||||
|
<link rel="stylesheet" style="text/css" href="./css/custom.css">
|
||||||
|
<link rel="stylesheet" style="text/css" href="./css/aai-custom.css">
|
||||||
|
<script src='https://www.google.com/recaptcha/api.js'></script>
|
||||||
|
<title>OpenAIRE - Request an Activation Code</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="uk-offcanvas-content uk-height-viewport">
|
||||||
|
<!-- MENU STARTS HERE -->
|
||||||
|
<!-- MAIN MENU STARTS HERE -->
|
||||||
|
<div class="tm-header tm-header-transparent" uk-header="">
|
||||||
|
<div class="uk-container uk-container-expand">
|
||||||
|
<nav class="uk-navbar" uk-navbar="{"align":"left"}">
|
||||||
|
<div class="uk-navbar-center">
|
||||||
|
<div class="uk-logo uk-navbar-item">
|
||||||
|
<img alt="OpenAIRE" class="uk-responsive-height" src="./images/Logo_Horizontal.png">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- MENU ENDS HERE -->
|
||||||
|
<!-- CONTENT STARTS HERE -->
|
||||||
|
<div class="first_page_section uk-section-default uk-section uk-padding-remove-vertical">
|
||||||
|
<div class="first_page_banner_headline uk-grid-collapse uk-flex-middle uk-margin-remove-vertical uk-grid" uk-grid="">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class=" uk-section uk-margin-small-top tm-middle custom-main-content" id="tm-main">
|
||||||
|
<div class="uk-container uk-container-small uk-margin-medium-top uk-margin-small-bottom uk-text-center">
|
||||||
|
<h2 class="uk-h2 uk-margin-small-bottom">Request an Activation Code</h2>
|
||||||
|
<div uk-grid="" class="uk-grid uk-grid-stack">
|
||||||
|
<div class="tm-main uk-width-1-2@s uk-width-1-1@m uk-width-1-1@l uk-row-first uk-first-column uk-align-center">
|
||||||
|
<div class="uk-grid ">
|
||||||
|
<!-- CENTER SIDE -->
|
||||||
|
<div class="uk-width-1-1@m uk-width-1-1@s uk-text-center">
|
||||||
|
<div class="middle-box text-center loginscreen animated fadeInDown ">
|
||||||
|
<p>Please enter your username. We will send you an email with a new activation code to activate your account.</p>
|
||||||
|
<div class="uk-width-1-3@m uk-align-center">
|
||||||
|
<!-- REQUEST AN ACTIVATION CODE FORM -->
|
||||||
|
<div id="registerForm">
|
||||||
|
<form action="requestActivationCode" method="POST" role="form" class="m-t" id="register_form">
|
||||||
|
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
|
||||||
|
<div class="alert alert-success" aria-hidden="true" style="display: none;"></div>
|
||||||
|
<div class="alert alert-danger" aria-hidden="true" style="display: none;"></div>
|
||||||
|
<div class="form-group">
|
||||||
|
<span id="server_error" class="uk-text-danger uk-text-small uk-float-left">${message}</span>
|
||||||
|
<c:remove var="message" scope="session" />
|
||||||
|
<span class="msg_username_error uk-text-danger uk-text-small uk-float-left" style="display:none">Please enter your username.</span>
|
||||||
|
<input id="username" name="username" type="text" placeholder="Username" class="form-control"></div>
|
||||||
|
<div class="uk-margin uk-grid-small uk-child-width-auto uk-grid uk-text-left uk-grid-stack" uk-grid="">
|
||||||
|
<span id="server_error" class="uk-text-danger uk-text-small uk-float-left">${reCAPTCHA_message}</span>
|
||||||
|
<c:remove var="reCAPTCHA_message" scope="session" />
|
||||||
|
<div class="uk-width-1-1 uk-grid-margin uk-first-column">
|
||||||
|
<div class="g-recaptcha" data-sitekey=${applicationScope.sitekey}></div>
|
||||||
|
</div>
|
||||||
|
<div class="uk-width-1-1 uk-grid-margin uk-first-column">
|
||||||
|
<button type="submit" class="uk-button uk-button-primary" onclick="return validateForm();">Submit</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
$("#username").focusin(function() {
|
||||||
|
$(this).removeClass('aai-form-danger');
|
||||||
|
$("#server_error").fadeOut();
|
||||||
|
$(".msg_username_error").fadeOut();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<!-- END OF REQUEST AN ACTIVATION CODE FORM -->
|
||||||
|
</div>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- END OF CENTER SIDE -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- CONTENT ENDS HERE -->
|
||||||
|
<!-- FOOTER STARTS HERE-->
|
||||||
|
<div class="custom-footer" style="z-index: 200;">
|
||||||
|
<div class="uk-section-primary uk-section uk-section-small">
|
||||||
|
<div class="uk-container">
|
||||||
|
<div class="uk-grid-margin uk-grid uk-grid-stack" uk-grid="">
|
||||||
|
<div class="uk-width-1-1@m uk-first-column">
|
||||||
|
<div class="uk-margin uk-margin-remove-top uk-margin-remove-bottom uk-text-center">
|
||||||
|
<img alt="OpenAIRE" class="el-image" src="./images/Logo_Horizontal_white_small.png">
|
||||||
|
</div>
|
||||||
|
<div class="footer-license uk-margin uk-margin-remove-bottom uk-text-center uk-text-lead">
|
||||||
|
<div><a href="http://creativecommons.org/licenses/by/4.0/" target="_blank" rel="license"><img alt="Creative" src="./images/80x15.png" style="height: auto; max-width: 100%; vertical-align: middle;"></a> UNLESS OTHERWISE INDICATED, ALL MATERIALS CREATED BY THE OPENAIRE CONSORTIUM ARE LICENSED UNDER A <a href="http://creativecommons.org/licenses/by/4.0/" rel="license">CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE</a>.</div>
|
||||||
|
<div>OPENAIRE IS POWERED BY <a href="http://www.d-net.research-infrastructures.eu/">D-NET</a>.</div>
|
||||||
|
</div>
|
||||||
|
<div class="uk-margin uk-margin-remove-top uk-margin-remove-bottom uk-text-right">
|
||||||
|
<a class="uk-totop uk-icon" href="#" uk-scroll="" uk-totop="">
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div> <!-- FOOTER ENDS HERE -->
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -13,7 +13,7 @@
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<base href=".">
|
<base href=".">
|
||||||
<title>OpenAIRE - Enter new password</title>
|
<title>OpenAIRE - Reset Password</title>
|
||||||
<script src="./js/jquery.js"></script>
|
<script src="./js/jquery.js"></script>
|
||||||
<script src="./js/uikit.js"></script>
|
<script src="./js/uikit.js"></script>
|
||||||
<script src="./js/validation.js"></script>
|
<script src="./js/validation.js"></script>
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<title>OpenAIRE - Forgot password</title>
|
<title>OpenAIRE - Success</title>
|
||||||
<script src="./js/jquery.js"></script>
|
<script src="./js/jquery.js"></script>
|
||||||
<script src="./js/uikit.js"></script>
|
<script src="./js/uikit.js"></script>
|
||||||
<script src="./js/validation.js"></script>
|
<script src="./js/validation.js"></script>
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<title>OpenAIRE - Forgot password</title>
|
<title>OpenAIRE - Success</title>
|
||||||
<script src="./js/jquery.js"></script>
|
<script src="./js/jquery.js"></script>
|
||||||
<script src="./js/uikit.js"></script>
|
<script src="./js/uikit.js"></script>
|
||||||
<script src="./js/validation.js"></script>
|
<script src="./js/validation.js"></script>
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<base href=".">
|
<base href=".">
|
||||||
<title>OpenAIRE - Forgot password, verification code</title>
|
<title>OpenAIRE - Account verification</title>
|
||||||
<script src="./js/jquery.js"></script>
|
<script src="./js/jquery.js"></script>
|
||||||
<script src="./js/uikit.js"></script>
|
<script src="./js/uikit.js"></script>
|
||||||
<script src="./js/validation.js"></script>
|
<script src="./js/validation.js"></script>
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<base href=".">
|
<base href=".">
|
||||||
<title>OpenAIRE - Forgot password, verification code</title>
|
<title>OpenAIRE - Email Verification</title>
|
||||||
<script src="./js/jquery.js"></script>
|
<script src="./js/jquery.js"></script>
|
||||||
<script src="./js/uikit.js"></script>
|
<script src="./js/uikit.js"></script>
|
||||||
<script src="./js/validation.js"></script>
|
<script src="./js/validation.js"></script>
|
||||||
|
|
Loading…
Reference in New Issue