Revision 49590
Added by Sofia Baltzi over 6 years ago
modules/dnet-openaire-users/trunk/src/main/java/eu/dnetlib/openaire/usermanagement/RegisterServlet.java | ||
---|---|---|
1 |
package eu.dnetlib.openaire.usermanagement; |
|
2 |
|
|
3 |
import eu.dnetlib.openaire.user.utils.LDAPActions; |
|
4 |
import eu.dnetlib.openaire.user.utils.VerificationActions; |
|
5 |
import org.apache.log4j.Logger; |
|
6 |
import org.springframework.beans.factory.annotation.Autowired; |
|
7 |
import org.springframework.web.context.support.SpringBeanAutowiringSupport; |
|
8 |
|
|
9 |
import javax.servlet.ServletConfig; |
|
10 |
import javax.servlet.ServletException; |
|
11 |
import javax.servlet.http.HttpServlet; |
|
12 |
import javax.servlet.http.HttpServletRequest; |
|
13 |
import javax.servlet.http.HttpServletResponse; |
|
14 |
import java.io.IOException; |
|
15 |
import java.io.PrintWriter; |
|
16 |
|
|
17 |
/** |
|
18 |
* Created by sofia on 20/10/2017. |
|
19 |
*/ |
|
20 |
public class RegisterServlet extends HttpServlet { |
|
21 |
|
|
22 |
public void init(ServletConfig config) throws ServletException { |
|
23 |
super.init(config); |
|
24 |
SpringBeanAutowiringSupport.processInjectionBasedOnServletContext(this, |
|
25 |
config.getServletContext()); |
|
26 |
} |
|
27 |
|
|
28 |
@Autowired |
|
29 |
private VerificationActions verificationActions; |
|
30 |
|
|
31 |
@Autowired |
|
32 |
private LDAPActions ldapActions; |
|
33 |
|
|
34 |
private Logger logger = Logger.getLogger(RegisterServlet.class); |
|
35 |
|
|
36 |
@Override |
|
37 |
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException { |
|
38 |
response.setContentType("text/html"); |
|
39 |
PrintWriter printWriter = response.getWriter(); |
|
40 |
|
|
41 |
logger.info("Mphkaaa!!!"); |
|
42 |
|
|
43 |
String firstName = request.getParameter("first_name"); |
|
44 |
String lastName = request.getParameter("last_name"); |
|
45 |
String organization = request.getParameter("organization"); |
|
46 |
String username = request.getParameter("username"); |
|
47 |
String email =request.getParameter("email"); |
|
48 |
String confirmEmail = request.getParameter("email_conf"); |
|
49 |
//String password = request.getParameter("password"); |
|
50 |
//String confirmPassword = request.getParameter("password_conf"); |
|
51 |
|
|
52 |
if (organization == null){ |
|
53 |
logger.info("organization is null"); |
|
54 |
} |
|
55 |
if (firstName != null && lastName != null && username != null && |
|
56 |
email.equals(confirmEmail) /*&& password.equals(confirmPassword)*/ ) { |
|
57 |
try { |
|
58 |
ldapActions.createUser(username, email, firstName, lastName, organization/*, password*/); |
|
59 |
logger.info("User successfully created"); |
|
60 |
} catch (Exception e) { |
|
61 |
logger.error("LDAP error in creating user", e); |
|
62 |
response.sendRedirect("./error.jsp"); |
|
63 |
} |
|
64 |
} |
|
65 |
response.sendRedirect("./success.jsp"); |
|
66 |
printWriter.close(); |
|
67 |
|
|
68 |
} |
|
69 |
} |
|
70 |
|
Also available in: Unified diff
Add RegisterServlet.java