Revision 59615
Added by Katerina Iatropoulou over 3 years ago
RegisterServiceServlet.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.openaire.usermanagement; |
2 | 2 |
|
3 | 3 |
import com.google.gson.Gson; |
4 |
import com.google.gson.GsonBuilder; |
|
4 | 5 |
import eu.dnetlib.openaire.user.pojos.RegisteredService; |
5 | 6 |
import eu.dnetlib.openaire.usermanagement.utils.RegisteredServicesUtils; |
6 | 7 |
import eu.dnetlib.openaire.usermanagement.utils.TokenUtils; |
8 |
import org.apache.commons.validator.routines.UrlValidator; |
|
7 | 9 |
import org.apache.log4j.Logger; |
8 | 10 |
import org.mitre.openid.connect.model.OIDCAuthenticationToken; |
9 | 11 |
import org.springframework.beans.factory.annotation.Autowired; |
... | ... | |
16 | 18 |
import javax.servlet.http.HttpServletRequest; |
17 | 19 |
import javax.servlet.http.HttpServletResponse; |
18 | 20 |
import java.io.IOException; |
21 |
import java.net.URL; |
|
19 | 22 |
import java.sql.SQLException; |
20 | 23 |
|
21 | 24 |
|
... | ... | |
40 | 43 |
|
41 | 44 |
public void doPost(HttpServletRequest request, HttpServletResponse response) |
42 | 45 |
throws ServletException, IOException { |
46 |
|
|
47 |
//TODO check user's limit |
|
48 |
|
|
43 | 49 |
response.setContentType("text/html"); |
44 | 50 |
|
45 | 51 |
String name = request.getParameter("first_name").trim(); |
46 | 52 |
String description = request.getParameter("description").trim(); |
47 | 53 |
|
54 |
String keyType = request.getParameter("key_radio").trim(); |
|
55 |
System.out.println("key type " + keyType); |
|
56 |
|
|
57 |
/* |
|
58 |
if (keyType.equals("uri")) { |
|
59 |
String jwksUri = request.getParameter("uri"); |
|
60 |
System.out.println("JWKS URI " + jwksUri); |
|
61 |
UrlValidator urlValidator = new UrlValidator(); |
|
62 |
if (!urlValidator.isValid(jwksUri)){ |
|
63 |
request.getSession().setAttribute("msg_key_uri_error_display", "display:block"); |
|
64 |
} |
|
65 |
} else { |
|
66 |
String jwksString = request.getParameter("value"); |
|
67 |
System.out.println("JWKS String " + jwksString); |
|
68 |
Gson gson = new GsonBuilder().registerTypeAdapter(Jwks.class, new ServiceResponseDeserializer()).create(); |
|
69 |
Jwks jwks = gson.fromJson(jwksString, Jwks.class); |
|
70 |
System.out.println(jwks.keys); |
|
71 |
System.out.println(jwks.keys.length); |
|
72 |
} |
|
73 |
*/ |
|
74 |
|
|
48 | 75 |
OIDCAuthenticationToken authentication = (OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication(); |
49 | 76 |
String userid = authentication.getSub(); |
50 | 77 |
String email = authentication.getUserInfo().getEmail(); |
Also available in: Unified diff
service registration with keys enabled