Revision 59495
Added by Katerina Iatropoulou over 3 years ago
modules/dnet-openaire-users/trunk/src/main/java/eu/dnetlib/openaire/usermanagement/ServiceRequest.java | ||
---|---|---|
1 |
package eu.dnetlib.openaire.usermanagement; |
|
2 |
|
|
3 |
import com.google.gson.Gson; |
|
4 |
import com.google.gson.GsonBuilder; |
|
5 |
|
|
6 |
public class ServiceRequest { |
|
7 |
String clientName; |
|
8 |
String clientId; |
|
9 |
String[] redirectUris = new String[]{}; |
|
10 |
String clientDescription; |
|
11 |
String logoUri; |
|
12 |
String policyUri; |
|
13 |
String[] contacts; |
|
14 |
String[] scope = new String[]{"orcid", "openid", "email", "eduperson_entitlement", "profile", "offline_access"}; |
|
15 |
String[] grantTypes = new String[] {"client_credentials"}; |
|
16 |
boolean allowIntrospection = true; |
|
17 |
String tokenEndpointAuthMethod = "PRIVATE KEY"; |
|
18 |
String tokenEndpointAuthSigningAlg = "RS256"; |
|
19 |
String jwksType = "VAL"; |
|
20 |
String jwksUri; |
|
21 |
Jwks jwks = new Jwks(); |
|
22 |
boolean allowRefresh = false; |
|
23 |
boolean reuseRefreshToken = true; |
|
24 |
boolean clearAccessTokensOnRefresh = true; |
|
25 |
|
|
26 |
public String getClientName() { |
|
27 |
return clientName; |
|
28 |
} |
|
29 |
|
|
30 |
public void setClientName(String clientName) { |
|
31 |
this.clientName = clientName; |
|
32 |
} |
|
33 |
|
|
34 |
public String getClientId() { |
|
35 |
return clientId; |
|
36 |
} |
|
37 |
|
|
38 |
public void setClientId(String clientId) { |
|
39 |
this.clientId = clientId; |
|
40 |
} |
|
41 |
|
|
42 |
public String[] getRedirectUris() { |
|
43 |
return redirectUris; |
|
44 |
} |
|
45 |
|
|
46 |
public void setRedirectUris(String[] redirectUris) { |
|
47 |
this.redirectUris = redirectUris; |
|
48 |
} |
|
49 |
|
|
50 |
public String getClientDescription() { |
|
51 |
return clientDescription; |
|
52 |
} |
|
53 |
|
|
54 |
public void setClientDescription(String clientDescription) { |
|
55 |
this.clientDescription = clientDescription; |
|
56 |
} |
|
57 |
|
|
58 |
public String getLogoUri() { |
|
59 |
return logoUri; |
|
60 |
} |
|
61 |
|
|
62 |
public void setLogoUri(String logoUri) { |
|
63 |
this.logoUri = logoUri; |
|
64 |
} |
|
65 |
|
|
66 |
public String getPolicyUri() { |
|
67 |
return policyUri; |
|
68 |
} |
|
69 |
|
|
70 |
public void setPolicyUri(String policyUri) { |
|
71 |
this.policyUri = policyUri; |
|
72 |
} |
|
73 |
|
|
74 |
public String[] getContacts() { |
|
75 |
return contacts; |
|
76 |
} |
|
77 |
|
|
78 |
public void setContacts(String[] contacts) { |
|
79 |
this.contacts = contacts; |
|
80 |
} |
|
81 |
|
|
82 |
public String[] getScope() { |
|
83 |
return scope; |
|
84 |
} |
|
85 |
|
|
86 |
public void setScope(String[] scope) { |
|
87 |
this.scope = scope; |
|
88 |
} |
|
89 |
|
|
90 |
public String[] getGrantTypes() { |
|
91 |
return grantTypes; |
|
92 |
} |
|
93 |
|
|
94 |
public void setGrantTypes(String[] grantTypes) { |
|
95 |
this.grantTypes = grantTypes; |
|
96 |
} |
|
97 |
|
|
98 |
public boolean isAllowIntrospection() { |
|
99 |
return allowIntrospection; |
|
100 |
} |
|
101 |
|
|
102 |
public void setAllowIntrospection(boolean allowIntrospection) { |
|
103 |
this.allowIntrospection = allowIntrospection; |
|
104 |
} |
|
105 |
|
|
106 |
public String getTokenEndpointAuthMethod() { |
|
107 |
return tokenEndpointAuthMethod; |
|
108 |
} |
|
109 |
|
|
110 |
public void setTokenEndpointAuthMethod(String tokenEndpointAuthMethod) { |
|
111 |
this.tokenEndpointAuthMethod = tokenEndpointAuthMethod; |
|
112 |
} |
|
113 |
|
|
114 |
public String getTokenEndpointAuthSigningAlg() { |
|
115 |
return tokenEndpointAuthSigningAlg; |
|
116 |
} |
|
117 |
|
|
118 |
public void setTokenEndpointAuthSigningAlg(String tokenEndpointAuthSigningAlg) { |
|
119 |
this.tokenEndpointAuthSigningAlg = tokenEndpointAuthSigningAlg; |
|
120 |
} |
|
121 |
|
|
122 |
public String getJwksType() { |
|
123 |
return jwksType; |
|
124 |
} |
|
125 |
|
|
126 |
public void setJwksType(String jwksType) { |
|
127 |
this.jwksType = jwksType; |
|
128 |
} |
|
129 |
|
|
130 |
public String getJwksUri() { |
|
131 |
return jwksUri; |
|
132 |
} |
|
133 |
|
|
134 |
public void setJwksUri(String jwksUri) { |
|
135 |
this.jwksUri = jwksUri; |
|
136 |
} |
|
137 |
|
|
138 |
public static void main(String[] args) { |
|
139 |
|
|
140 |
GsonBuilder builder = new GsonBuilder(); |
|
141 |
builder.serializeNulls(); |
|
142 |
|
|
143 |
Gson gson = builder.create(); |
|
144 |
String json = gson.toJson(new ServiceRequest()); |
|
145 |
System.out.println(json); |
|
146 |
|
|
147 |
} |
|
148 |
} |
|
149 |
class Jwks { |
|
150 |
Key[] keys = new Key[]{new Key()}; |
|
151 |
} |
|
152 |
|
|
153 |
class Key { |
|
154 |
String kty = "RSA"; |
|
155 |
String e = "AQAB"; |
|
156 |
String kid = "05794a3c-a6f5-430c-9822-da4e53597ba5"; |
|
157 |
String alg = "RS256"; |
|
158 |
String n = "hm_OUny05OJEwbGBqPjE7wWvnwTMgqUHJFis_S9nM7hTivXQ_LX9f89RaVcPpXboox81Y8rrfuVwV0nc-FGr_" + |
|
159 |
"E0FFpI-IwJ_sUUEDwf-5Qxor3LNc_S_5BiPOfFHY7c-R-ablRIAvVTXqwIjcyLVQnaHLjb9XQPf9lBt9sCZ2jN-" + |
|
160 |
"9HOLztMO3BZWZYIFqvNr8ySKHfVPdlk0Wx3N45KPY0kgxk5RPYW0HLRakSlhIJtqYCJOr2IiDUEMAj9Z9BoWjeUKiAX3E3ZRo-" + |
|
161 |
"DO1TWcc7feq-0Pei2IBw3lvNpgcBBv1_BlrsZYzQqkKOcDbLAppuhR3inUNhc3G67OuWt8ow"; |
|
162 |
} |
|
163 |
|
|
164 |
|
modules/dnet-openaire-users/trunk/src/main/java/eu/dnetlib/openaire/usermanagement/RegisterServiceServlet.java | ||
---|---|---|
1 |
package eu.dnetlib.openaire.usermanagement; |
|
2 |
|
|
3 |
import com.google.gson.Gson; |
|
4 |
import com.google.gson.GsonBuilder; |
|
5 |
import org.apache.commons.io.IOUtils; |
|
6 |
import org.apache.http.HttpHeaders; |
|
7 |
import org.apache.http.HttpResponse; |
|
8 |
import org.apache.http.client.methods.HttpPost; |
|
9 |
import org.apache.http.entity.StringEntity; |
|
10 |
import org.apache.http.impl.client.CloseableHttpClient; |
|
11 |
import org.apache.http.impl.client.HttpClients; |
|
12 |
import org.mitre.openid.connect.model.OIDCAuthenticationToken; |
|
13 |
import org.springframework.beans.factory.annotation.Value; |
|
14 |
import org.springframework.security.core.context.SecurityContextHolder; |
|
15 |
|
|
16 |
import javax.servlet.ServletException; |
|
17 |
import javax.servlet.http.HttpServlet; |
|
18 |
import javax.servlet.http.HttpServletRequest; |
|
19 |
import javax.servlet.http.HttpServletResponse; |
|
20 |
import java.io.IOException; |
|
21 |
import java.nio.charset.StandardCharsets; |
|
22 |
|
|
23 |
public class RegisterServiceServlet extends HttpServlet { |
|
24 |
|
|
25 |
@Value("${oidc.issuer}") |
|
26 |
private String issuer; |
|
27 |
|
|
28 |
public void doGet(HttpServletRequest request, HttpServletResponse response) |
|
29 |
throws ServletException, IOException { |
|
30 |
response.setContentType("text/html"); |
|
31 |
request.getRequestDispatcher("./registerService.jsp").include(request, response); |
|
32 |
} |
|
33 |
|
|
34 |
public void doPost(HttpServletRequest request, HttpServletResponse response) |
|
35 |
throws ServletException, IOException { |
|
36 |
response.setContentType("text/html"); |
|
37 |
|
|
38 |
String name = request.getParameter("first_name").trim(); |
|
39 |
String description = request.getParameter("description").trim(); |
|
40 |
|
|
41 |
if ( name!= null && !name.isEmpty()){ |
|
42 |
ServiceRequest serviceJSON = new ServiceRequest(); |
|
43 |
serviceJSON.setClientName(name); |
|
44 |
serviceJSON.setClientDescription(description); |
|
45 |
|
|
46 |
GsonBuilder builder = new GsonBuilder(); |
|
47 |
builder.serializeNulls(); |
|
48 |
Gson gson = builder.create(); |
|
49 |
String json = gson.toJson(serviceJSON); |
|
50 |
|
|
51 |
System.out.println(json); |
|
52 |
|
|
53 |
OIDCAuthenticationToken authentication = (OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication(); |
|
54 |
|
|
55 |
CloseableHttpClient httpclient = HttpClients.createDefault(); |
|
56 |
//TODO fix this |
|
57 |
HttpPost httppost = new HttpPost("https://openaire-dev.aai-dev.grnet.gr/oidc/api/clients"); |
|
58 |
|
|
59 |
httppost.setHeader(HttpHeaders.CONTENT_TYPE, "application/json"); |
|
60 |
httppost.setHeader(HttpHeaders.AUTHORIZATION, "Bearer " + authentication.getAccessTokenValue()); |
|
61 |
StringEntity params = new StringEntity(json.toString()); |
|
62 |
httppost.setEntity(params); |
|
63 |
HttpResponse httpResponse = null; |
|
64 |
httpResponse = httpclient.execute(httppost); |
|
65 |
|
|
66 |
String serverMessage = IOUtils.toString(httpResponse.getEntity().getContent(), StandardCharsets.UTF_8.name()); |
|
67 |
|
|
68 |
ServiceResponse serviceResponse = new Gson().fromJson(serverMessage, ServiceResponse.class); |
|
69 |
System.out.println("The created id is " + serviceResponse.getId()); |
|
70 |
} |
|
71 |
|
|
72 |
OIDCAuthenticationToken authentication = (OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication(); |
|
73 |
|
|
74 |
request.getSession().setAttribute("accessToken", authentication.getAccessTokenValue()); |
|
75 |
request.getSession().setAttribute("refreshToken", authentication.getRefreshTokenValue()); |
|
76 |
|
|
77 |
request.getRequestDispatcher("./serviceTokens.jsp").include(request, response); |
|
78 |
} |
|
79 |
} |
modules/dnet-openaire-users/trunk/src/main/java/eu/dnetlib/openaire/usermanagement/ServiceResponse.java | ||
---|---|---|
1 |
package eu.dnetlib.openaire.usermanagement; |
|
2 |
|
|
3 |
public class ServiceResponse { |
|
4 |
String id; |
|
5 |
String clientId; |
|
6 |
String clientSecret; |
|
7 |
String[] redirectUris; |
|
8 |
String clientName; |
|
9 |
String clienrtUri; |
|
10 |
String logoUri; |
|
11 |
String[] contacts; |
|
12 |
String tosUri; |
|
13 |
String tokenEndpointAuthMethod; |
|
14 |
String[] scope; |
|
15 |
String grantTypes[]; |
|
16 |
String responseTypes[]; |
|
17 |
String policyUri; |
|
18 |
String jwksUri; |
|
19 |
Jwks jwks; |
|
20 |
String applicationType; |
|
21 |
String sectorIdentifierUri; |
|
22 |
String subjectType; |
|
23 |
String requestObjectSigningAlg; |
|
24 |
String userInfoSignedResponseAlg; |
|
25 |
String userInfoEncryptedResponseAlg; |
|
26 |
String userInfoEncryptedResponseEnc; |
|
27 |
String idTokenSignedResponseAlg; |
|
28 |
String idTokenEncryptedResponseAlg; |
|
29 |
String idTokenEncryptedResponseEnc; |
|
30 |
String tokenEndpointAuthSigningAlg; |
|
31 |
String defaultMaxAge; |
|
32 |
String requireAuthTime; |
|
33 |
String[] defaultACRvalues; |
|
34 |
String initiateLoginUri; |
|
35 |
String[] postLogoutRedirectUris; |
|
36 |
String[] requestUris; |
|
37 |
String[] authorities; |
|
38 |
int accessTokenValiditySeconds; |
|
39 |
int refreshTokenValiditySeconds; |
|
40 |
String[] resourceIds; |
|
41 |
String[] clientDescription; |
|
42 |
boolean reuseRefreshToken; |
|
43 |
boolean dynamicallyRegistered; |
|
44 |
boolean allowIntrospection; |
|
45 |
int idTokenValiditySeconds; |
|
46 |
String createdAt; |
|
47 |
boolean clearAccessTokensOnRefresh; |
|
48 |
String deviceCodeValiditySeconds; |
|
49 |
String[] claimsRedirectUris; |
|
50 |
String softwareStatement; |
|
51 |
String codeChallengeMethod; |
|
52 |
|
|
53 |
public String getId() { |
|
54 |
return id; |
|
55 |
} |
|
56 |
|
|
57 |
public String getClientId() { |
|
58 |
return clientId; |
|
59 |
} |
|
60 |
|
|
61 |
public String getClientSecret() { |
|
62 |
return clientSecret; |
|
63 |
} |
|
64 |
|
|
65 |
public String[] getRedirectUris() { |
|
66 |
return redirectUris; |
|
67 |
} |
|
68 |
|
|
69 |
public String getClientName() { |
|
70 |
return clientName; |
|
71 |
} |
|
72 |
|
|
73 |
public String getClienrtUri() { |
|
74 |
return clienrtUri; |
|
75 |
} |
|
76 |
|
|
77 |
public String getLogoUri() { |
|
78 |
return logoUri; |
|
79 |
} |
|
80 |
|
|
81 |
public String[] getContacts() { |
|
82 |
return contacts; |
|
83 |
} |
|
84 |
|
|
85 |
public String getTosUri() { |
|
86 |
return tosUri; |
|
87 |
} |
|
88 |
|
|
89 |
public String getTokenEndpointAuthMethod() { |
|
90 |
return tokenEndpointAuthMethod; |
|
91 |
} |
|
92 |
|
|
93 |
public String[] getScope() { |
|
94 |
return scope; |
|
95 |
} |
|
96 |
|
|
97 |
public String[] getGrantTypes() { |
|
98 |
return grantTypes; |
|
99 |
} |
|
100 |
|
|
101 |
public String[] getResponseTypes() { |
|
102 |
return responseTypes; |
|
103 |
} |
|
104 |
|
|
105 |
public String getPolicyUri() { |
|
106 |
return policyUri; |
|
107 |
} |
|
108 |
|
|
109 |
public String getJwksUri() { |
|
110 |
return jwksUri; |
|
111 |
} |
|
112 |
|
|
113 |
public Jwks getJwks() { |
|
114 |
return jwks; |
|
115 |
} |
|
116 |
|
|
117 |
public String getApplicationType() { |
|
118 |
return applicationType; |
|
119 |
} |
|
120 |
|
|
121 |
public String getSectorIdentifierUri() { |
|
122 |
return sectorIdentifierUri; |
|
123 |
} |
|
124 |
|
|
125 |
public String getSubjectType() { |
|
126 |
return subjectType; |
|
127 |
} |
|
128 |
|
|
129 |
public String getRequestObjectSigningAlg() { |
|
130 |
return requestObjectSigningAlg; |
|
131 |
} |
|
132 |
|
|
133 |
public String getUserInfoSignedResponseAlg() { |
|
134 |
return userInfoSignedResponseAlg; |
|
135 |
} |
|
136 |
|
|
137 |
public String getUserInfoEncryptedResponseAlg() { |
|
138 |
return userInfoEncryptedResponseAlg; |
|
139 |
} |
|
140 |
|
|
141 |
public String getUserInfoEncryptedResponseEnc() { |
|
142 |
return userInfoEncryptedResponseEnc; |
|
143 |
} |
|
144 |
|
|
145 |
public String getIdTokenSignedResponseAlg() { |
|
146 |
return idTokenSignedResponseAlg; |
|
147 |
} |
|
148 |
|
|
149 |
public String getIdTokenEncryptedResponseAlg() { |
|
150 |
return idTokenEncryptedResponseAlg; |
|
151 |
} |
|
152 |
|
|
153 |
public String getIdTokenEncryptedResponseEnc() { |
|
154 |
return idTokenEncryptedResponseEnc; |
|
155 |
} |
|
156 |
|
|
157 |
public String getTokenEndpointAuthSigningAlg() { |
|
158 |
return tokenEndpointAuthSigningAlg; |
|
159 |
} |
|
160 |
|
|
161 |
public String getDefaultMaxAge() { |
|
162 |
return defaultMaxAge; |
|
163 |
} |
|
164 |
|
|
165 |
public String getRequireAuthTime() { |
|
166 |
return requireAuthTime; |
|
167 |
} |
|
168 |
|
|
169 |
public String[] getDefaultACRvalues() { |
|
170 |
return defaultACRvalues; |
|
171 |
} |
|
172 |
|
|
173 |
public String getInitiateLoginUri() { |
|
174 |
return initiateLoginUri; |
|
175 |
} |
|
176 |
|
|
177 |
public String[] getPostLogoutRedirectUris() { |
|
178 |
return postLogoutRedirectUris; |
|
179 |
} |
|
180 |
|
|
181 |
public String[] getRequestUris() { |
|
182 |
return requestUris; |
|
183 |
} |
|
184 |
|
|
185 |
public String[] getAuthorities() { |
|
186 |
return authorities; |
|
187 |
} |
|
188 |
|
|
189 |
public int getAccessTokenValiditySeconds() { |
|
190 |
return accessTokenValiditySeconds; |
|
191 |
} |
|
192 |
|
|
193 |
public int getRefreshTokenValiditySeconds() { |
|
194 |
return refreshTokenValiditySeconds; |
|
195 |
} |
|
196 |
|
|
197 |
public String[] getResourceIds() { |
|
198 |
return resourceIds; |
|
199 |
} |
|
200 |
|
|
201 |
public String[] getClientDescription() { |
|
202 |
return clientDescription; |
|
203 |
} |
|
204 |
|
|
205 |
public boolean isReuseRefreshToken() { |
|
206 |
return reuseRefreshToken; |
|
207 |
} |
|
208 |
|
|
209 |
public boolean isDynamicallyRegistered() { |
|
210 |
return dynamicallyRegistered; |
|
211 |
} |
|
212 |
|
|
213 |
public boolean isAllowIntrospection() { |
|
214 |
return allowIntrospection; |
|
215 |
} |
|
216 |
|
|
217 |
public int getIdTokenValiditySeconds() { |
|
218 |
return idTokenValiditySeconds; |
|
219 |
} |
|
220 |
|
|
221 |
public String getCreatedAt() { |
|
222 |
return createdAt; |
|
223 |
} |
|
224 |
|
|
225 |
public boolean isClearAccessTokensOnRefresh() { |
|
226 |
return clearAccessTokensOnRefresh; |
|
227 |
} |
|
228 |
|
|
229 |
public String getDeviceCodeValiditySeconds() { |
|
230 |
return deviceCodeValiditySeconds; |
|
231 |
} |
|
232 |
|
|
233 |
public String[] getClaimsRedirectUris() { |
|
234 |
return claimsRedirectUris; |
|
235 |
} |
|
236 |
|
|
237 |
public String getSoftwareStatement() { |
|
238 |
return softwareStatement; |
|
239 |
} |
|
240 |
|
|
241 |
public String getCodeChallengeMethod() { |
|
242 |
return codeChallengeMethod; |
|
243 |
} |
|
244 |
} |
modules/dnet-openaire-users/trunk/src/main/java/eu/dnetlib/openaire/usermanagement/api/Test3Service.java | ||
---|---|---|
101 | 101 |
@GET |
102 | 102 |
@Path("/getAccessToken") |
103 | 103 |
@Produces(MediaType.APPLICATION_JSON) |
104 |
public Response getAccessTokenFromRefreshToken(@Context final HttpServletRequest request){ |
|
104 |
public Response getAccessTokenFromRefreshToken(@Context final HttpServletRequest request, |
|
105 |
@QueryParam("refreshToken") String refreshToken){ |
|
105 | 106 |
|
106 |
String header = request.getHeader("Authorization"); |
|
107 |
|
|
108 |
if (header == null || !header.startsWith("Bearer ")) { |
|
107 |
if (refreshToken == null || refreshToken.isEmpty()) { |
|
109 | 108 |
return Response.status(Response.Status.BAD_REQUEST) |
110 |
.entity(String.format(errorMessage, 400, "No JWT token found in request headers", "No JWT token found in request headers")).build(); |
|
109 |
.entity(String.format(errorMessage, 400, "Bad Request", "Missing refreshToken parameter")) |
|
110 |
.type(MediaType.APPLICATION_JSON).build(); |
|
111 | 111 |
} |
112 | 112 |
|
113 |
String refreshToken = header.substring(7); |
|
114 | 113 |
CloseableHttpClient httpclient = HttpClients.createDefault(); |
115 | 114 |
HttpPost httppost = new HttpPost(issuer+"/token"); |
116 | 115 |
|
... | ... | |
127 | 126 |
try { |
128 | 127 |
httppost.setEntity(new UrlEncodedFormEntity(params, "UTF-8")); |
129 | 128 |
//Execute and get the response. |
130 |
|
|
131 | 129 |
response = httpclient.execute(httppost); |
132 |
|
|
133 | 130 |
org.apache.http.HttpEntity entity = response.getEntity(); |
134 |
logger.debug("entity " + response.getEntity()); |
|
135 | 131 |
|
136 |
logger.debug("I am here"); |
|
132 |
if (response.getStatusLine().getStatusCode() == 401) { |
|
133 |
return Response.status(Response.Status.UNAUTHORIZED) |
|
134 |
.entity(String.format(errorMessage, 401, "Unauthorised", "Invalid refreshToken token " + refreshToken)) |
|
135 |
.type(MediaType.APPLICATION_JSON).build(); |
|
136 |
} |
|
137 |
|
|
137 | 138 |
String serverMessage = IOUtils.toString(entity.getContent(), StandardCharsets.UTF_8.name()); |
138 |
|
|
139 | 139 |
return Response.status(response.getStatusLine().getStatusCode()) |
140 | 140 |
.entity(serverMessage).type(MediaType.APPLICATION_JSON).build(); |
141 | 141 |
|
modules/dnet-openaire-users/trunk/src/main/java/eu/dnetlib/openaire/usermanagement/PersonalTokenServlet.java | ||
---|---|---|
19 | 19 |
public void doGet(HttpServletRequest request, HttpServletResponse response) |
20 | 20 |
throws ServletException, IOException { |
21 | 21 |
response.setContentType("text/html"); |
22 |
PrintWriter printWriter = response.getWriter(); |
|
23 | 22 |
|
24 | 23 |
OIDCAuthenticationToken authentication = (OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication(); |
25 |
System.out.println(authentication); |
|
26 |
|
|
27 | 24 |
request.getSession().setAttribute("accessToken", authentication.getAccessTokenValue()); |
28 | 25 |
request.getSession().setAttribute("refreshToken", authentication.getRefreshTokenValue()); |
29 |
System.out.println("LALALLALLALALALA" + authentication.getAccessTokenValue()); |
|
30 | 26 |
|
31 | 27 |
request.getRequestDispatcher("./personal.jsp").include(request, response); |
32 | 28 |
} |
modules/dnet-openaire-users/trunk/src/main/webapp/WEB-INF/web.xml | ||
---|---|---|
154 | 154 |
<url-pattern>/personalToken</url-pattern> |
155 | 155 |
</servlet-mapping> |
156 | 156 |
|
157 |
<servlet> |
|
158 |
<servlet-name>RegisterServiceServlet</servlet-name> |
|
159 |
<display-name>Activate</display-name> |
|
160 |
<servlet-class>eu.dnetlib.openaire.usermanagement.RegisterServiceServlet</servlet-class> |
|
161 |
<load-on-startup>1</load-on-startup> |
|
162 |
</servlet> |
|
163 |
|
|
164 |
<servlet-mapping> |
|
165 |
<servlet-name>RegisterServiceServlet</servlet-name> |
|
166 |
<url-pattern>/registerService</url-pattern> |
|
167 |
</servlet-mapping> |
|
168 |
|
|
157 | 169 |
<filter> |
158 | 170 |
<filter-name>CorsFilter</filter-name> |
159 | 171 |
<filter-class>org.apache.catalina.filters.CorsFilter</filter-class> |
modules/dnet-openaire-users/trunk/src/main/webapp/registerService.jsp | ||
---|---|---|
1 |
<%-- |
|
2 |
Created by IntelliJ IDEA. |
|
3 |
User: sofia |
|
4 |
Date: 19/10/2017 |
|
5 |
Time: 4:30 μμ |
|
6 |
To change this template use File | Settings | File Templates. |
|
7 |
--%> |
|
8 |
<%@ page contentType="text/html;charset=UTF-8" language="java" %> |
|
9 |
<!DOCTYPE html> |
|
10 |
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> |
|
11 |
<html lang="en-gb" dir="ltr" vocab="http://schema.org/"> |
|
12 |
<head> |
|
13 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
|
14 |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> |
|
15 |
<meta name="viewport" content="width=device-width, initial-scale=1"> |
|
16 |
<base href="."> |
|
17 |
<title>OpenAIRE - Register</title> |
|
18 |
<script src="./js/jquery.js"></script> |
|
19 |
<script src="./js/uikit.js"></script> |
|
20 |
<script src="./js/validation.js"></script> |
|
21 |
<script src="./js/uikit-icons-max.js"></script> |
|
22 |
<link rel="stylesheet" style="text/css" href="./css/theme.css"> |
|
23 |
<link rel="stylesheet" style="text/css" href="./css/custom.css"> |
|
24 |
<link rel="stylesheet" style="text/css" href="./css/aai-custom.css"> |
|
25 |
<link rel="icon" type="image/png" sizes="32x32" href="images/favicon/favicon-32x32.png"> |
|
26 |
<link rel="icon" type="image/png" sizes="96x96" href="images/favicon//favicon-96x96.png"> |
|
27 |
<link rel="icon" type="image/png" sizes="16x16" href="images/favicon/favicon-16x16.png"> |
|
28 |
<link href="images/favicon/favicon.ico" rel="shortcut icon" type="image/vnd.microsoft.icon" /> |
|
29 |
</head> |
|
30 |
<body class="" style=""> |
|
31 |
<div class="uk-offcanvas-content uk-height-viewport"> |
|
32 |
<!-- MENU STARTS HERE --> |
|
33 |
<!-- MAIN MENU STARTS HERE --> |
|
34 |
<div class="tm-header tm-header-transparent" uk-header=""> |
|
35 |
<div class="uk-container uk-container-expand"> |
|
36 |
<nav class="uk-navbar" uk-navbar="{"align":"left"}"> |
|
37 |
<div class="uk-navbar-center"> |
|
38 |
<div class="uk-logo uk-navbar-item"> |
|
39 |
<img alt="OpenAIRE" class="uk-responsive-height" src="./images/Logo_Horizontal.png"> |
|
40 |
</div> |
|
41 |
</div> |
|
42 |
</nav> |
|
43 |
</div> |
|
44 |
</div> |
|
45 |
<!-- MENU ENDS HERE --> |
|
46 |
<!-- CONTENT STARTS HERE --> |
|
47 |
<div class="first_page_section uk-section-default uk-section uk-padding-remove-vertical"> |
|
48 |
<div class="first_page_banner_headline uk-grid-collapse uk-flex-middle uk-margin-remove-vertical uk-grid" uk-grid=""> |
|
49 |
</div> |
|
50 |
</div> |
|
51 |
<div class=" uk-section uk-margin-small-top tm-middle custom-main-content" id="tm-main"> |
|
52 |
<div class="uk-container uk-container-small uk-margin-medium-top uk-margin-small-bottom uk-text-center"> |
|
53 |
<h2 class="uk-h2 uk-margin-small-bottom">Add a new service</h2> |
|
54 |
<%--<div class="uk-text-meta uk-margin-large-bottom">Use the same credentials for all our services</div>--%> |
|
55 |
<div class="tm-main uk-width-2-3@s uk-width-2-3@m uk-width-3-4@l uk-row-first uk-first-column uk-align-center"> |
|
56 |
<div class="uk-grid "> |
|
57 |
<!-- CENTER SIDE --> |
|
58 |
<div class="uk-width-1-1@m uk-width-1-1@s uk-text-center"> |
|
59 |
<h3 class="uk-h3">Please provide the basic information on your new service</h3> |
|
60 |
<div class="middle-box text-center loginscreen animated fadeInDown "> |
|
61 |
<div class="k-width-1-1@m uk-width-1-1@s uk-text-center"> |
|
62 |
<!-- REGISTER FORM --> |
|
63 |
<div id="registerForm"> |
|
64 |
<form action="registerService" method="POST" role="form" class="m-t" id="register_form"> |
|
65 |
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/> |
|
66 |
<div class="alert alert-success" aria-hidden="true" style="display: none;"></div> |
|
67 |
<div class="alert alert-danger" aria-hidden="true" style="display: none;"></div> |
|
68 |
<span id="server_error" class="uk-text-danger uk-text-small uk-float-left">${message}</span> |
|
69 |
<c:remove var="message" scope="session" /> |
|
70 |
<div class="form-group"> |
|
71 |
<span class="msg_first_name_error uk-text-danger uk-text-small uk-float-left" style='${msg_first_name_error_display}'>Please enter a name for your service.</span> |
|
72 |
<input id="first_name" name="first_name" type="text" placeholder="Name (*)" class="form-control" value=${first_name}></div> |
|
73 |
<c:remove var="msg_first_name_error_display" scope="session" /> |
|
74 |
<c:remove var="first_name" scope="session" /> |
|
75 |
<div class="form-group"> |
|
76 |
<textarea id="description" name="description" type="textarea" placeholder="Description:" class="form-control uk-textarea" rows="3" value=${description}></textarea> |
|
77 |
<c:remove var="organization" scope="session" /> |
|
78 |
<div class="uk-width-1-1 uk-grid-margin uk-first-column"> |
|
79 |
<button type="submit" class="uk-button uk-button-default" onclick="">Cancel</button> |
|
80 |
<button type="submit" class="uk-button uk-button-primary" onclick="return validate();">Add new service</button> |
|
81 |
</div> |
|
82 |
</div> |
|
83 |
</form> |
|
84 |
</div> |
|
85 |
<!-- END OF REGISTER FORM --> |
|
86 |
<script> |
|
87 |
function validate() { |
|
88 |
// Check if name is filled |
|
89 |
if($("#first_name").val() != undefined) { |
|
90 |
if($.trim($("#first_name").val()).length <= 0) { |
|
91 |
$("#first_name").addClass('uk-input aai-form-danger'); |
|
92 |
$(".msg_first_name_error").show(); |
|
93 |
return false; |
|
94 |
} else { |
|
95 |
$(".msg_first_name_error").hide(); |
|
96 |
$("#first_name").removeClass('aai-form-danger'); |
|
97 |
} |
|
98 |
return true; |
|
99 |
} |
|
100 |
} |
|
101 |
$("#first_name").focusin(function () { |
|
102 |
$(this).removeClass('aai-form-danger'); |
|
103 |
$(".msg_first_name_error").fadeOut(); |
|
104 |
}); |
|
105 |
</script> |
|
106 |
</div> |
|
107 |
</ul> |
|
108 |
</div> |
|
109 |
</div> |
|
110 |
<!-- END OF CENTER SIDE --> |
|
111 |
</div> |
|
112 |
</div> |
|
113 |
</div> |
|
114 |
</div> |
|
115 |
</div> |
|
116 |
<!-- CONTENT ENDS HERE --> |
|
117 |
<!-- FOOTER STARTS HERE--> |
|
118 |
<div class="custom-footer" style="z-index: 200;"> |
|
119 |
<div class="uk-section-primary uk-section uk-section-small"> |
|
120 |
<div class="uk-container"> |
|
121 |
<div class="uk-grid-margin uk-grid uk-grid-stack" uk-grid=""> |
|
122 |
<div class="uk-width-1-1@m uk-first-column"> |
|
123 |
<div class="uk-margin uk-margin-remove-top uk-margin-remove-bottom uk-text-center"> |
|
124 |
<img alt="OpenAIRE" class="el-image" src="./images/Logo_Horizontal_white_small.png"> |
|
125 |
</div> |
|
126 |
<div class="footer-license uk-margin uk-margin-remove-bottom uk-text-center uk-text-lead"> |
|
127 |
<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> |
|
128 |
<div>OPENAIRE IS POWERED BY <a href="http://www.d-net.research-infrastructures.eu/">D-NET</a>.</div> |
|
129 |
</div> |
|
130 |
<div class="uk-margin uk-margin-remove-top uk-margin-remove-bottom uk-text-right"> |
|
131 |
<a class="uk-totop uk-icon" href="#" uk-scroll="" uk-totop=""> |
|
132 |
</a> |
|
133 |
</div> |
|
134 |
</div> |
|
135 |
</div> |
|
136 |
</div> |
|
137 |
</div> |
|
138 |
</div> |
|
139 |
</div> |
|
140 |
</body> |
|
141 |
</html> |
modules/dnet-openaire-users/trunk/src/main/webapp/personal.jsp | ||
---|---|---|
15 | 15 |
<link rel="icon" type="image/png" sizes="96x96" href="images/favicon//favicon-96x96.png"> |
16 | 16 |
<link rel="icon" type="image/png" sizes="16x16" href="images/favicon/favicon-16x16.png"> |
17 | 17 |
<link href="images/favicon/favicon.ico" rel="shortcut icon" type="image/vnd.microsoft.icon" /> |
18 |
<script src='https://www.google.com/recaptcha/api.js'></script> |
|
19 | 18 |
</head> |
20 | 19 |
<body class="" style=""> |
21 | 20 |
<div class="uk-offcanvas-content uk-height-viewport"> |
modules/dnet-openaire-users/branches/redis/src/main/webapp/WEB-INF/web.xml | ||
---|---|---|
84 | 84 |
</servlet-mapping> |
85 | 85 |
|
86 | 86 |
<servlet> |
87 |
<servlet-name>PersonalTokenServlet</servlet-name> |
|
88 |
<display-name>Activate</display-name> |
|
89 |
<servlet-class>eu.dnetlib.openaire.usermanagement.PersonalTokenServlet</servlet-class> |
|
90 |
<load-on-startup>1</load-on-startup> |
|
91 |
</servlet> |
|
92 |
|
|
93 |
<servlet-mapping> |
|
94 |
<servlet-name>PersonalTokenServlet</servlet-name> |
|
95 |
<url-pattern>/personalToken</url-pattern> |
|
96 |
</servlet-mapping> |
|
97 |
|
|
98 |
<servlet> |
|
87 | 99 |
<servlet-name>ActivationCodeServlet</servlet-name> |
88 | 100 |
<display-name>Activate</display-name> |
89 | 101 |
<servlet-class>eu.dnetlib.openaire.usermanagement.ActivationCodeServlet</servlet-class> |
Also available in: Unified diff
Changed getAccessTokenFromRefreshToken to expect the refresh token as parameter. Added service registration pages and methods.