Revision 46268014
b/jboss/conf/gss.properties | ||
---|---|---|
32 | 32 |
# The LDAP server where user accounts will be created. |
33 | 33 |
ldapHost=hal2.ebs.gr |
34 | 34 |
# The DN to use when connecting to the LDAP server. |
35 |
bindDn=cn=Manager,dc=ebs,dc=gr
|
|
35 |
bindDn=cn=Manager\,dc=ebs\,dc=gr
|
|
36 | 36 |
# The password to use when connecting to the LDAP server. |
37 | 37 |
bindPassword=secret |
38 | 38 |
# The base DN where user accounts will be created. |
39 |
baseDn=ou=people,dc=ebs,dc=gr
|
|
39 |
baseDn=ou=people\,dc=ebs\,dc=gr
|
|
40 | 40 |
# The LDAP objectClass to use for new accounts. |
41 | 41 |
objectClass=inetOrgPerson |
b/src/gr/ebs/gss/server/Invitations.java | ||
---|---|---|
96 | 96 |
response.sendRedirect(errorUrl); |
97 | 97 |
return; |
98 | 98 |
} |
99 |
String name = invite.getName() == null? "": invite.getName(); |
|
99 |
String firstname = invite.getFirstname() == null? "": invite.getFirstname(); |
|
100 |
String lastname = invite.getLastname() == null? "": invite.getLastname(); |
|
100 | 101 |
String email = invite.getEmail() == null? "": invite.getEmail(); |
101 |
response.sendRedirect("register.jsp?name=" + name + "&email=" + email); |
|
102 |
response.sendRedirect("register.jsp?firstname=" + firstname + |
|
103 |
"&lastname=" + lastname + "&email=" + email); |
|
102 | 104 |
} catch (RpcException e) { |
103 | 105 |
String error = "An error occurred while communicating with the service"; |
104 | 106 |
logger.error(error, e); |
b/src/gr/ebs/gss/server/Registration.java | ||
---|---|---|
54 | 54 |
private static final String ACCEPT_PARAM = "accept"; |
55 | 55 |
|
56 | 56 |
/** |
57 |
* The request parameter name for the name. |
|
57 |
* The request parameter name for the firstname.
|
|
58 | 58 |
*/ |
59 |
private static final String NAME_PARAM = "name"; |
|
59 |
private static final String FIRSTNAME_PARAM = "firstname"; |
|
60 |
|
|
61 |
/** |
|
62 |
* The request parameter name for the lastname. |
|
63 |
*/ |
|
64 |
private static final String LASTNAME_PARAM = "lastname"; |
|
60 | 65 |
|
61 | 66 |
/** |
62 | 67 |
* The request parameter name for the username. |
... | ... | |
116 | 121 |
|
117 | 122 |
@Override |
118 | 123 |
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException { |
119 |
final String name = request.getParameter(NAME_PARAM); |
|
124 |
final String firstname = request.getParameter(FIRSTNAME_PARAM); |
|
125 |
final String lastname = request.getParameter(LASTNAME_PARAM); |
|
120 | 126 |
final String email = request.getParameter(EMAIL_PARAM); |
121 | 127 |
final String username = request.getParameter(USERNAME_PARAM); |
122 | 128 |
String password = request.getParameter(PASSWORD_PARAM); |
... | ... | |
128 | 134 |
if (username == null || username.isEmpty()) { |
129 | 135 |
String error = URLEncoder.encode("No username was specified", "UTF-8"); |
130 | 136 |
String errorUrl = "register.jsp?username=&error=" + error; |
131 |
errorUrl += "&name=" + (name == null? "": name); |
|
137 |
errorUrl += "&firstname=" + (firstname == null? "": firstname); |
|
138 |
errorUrl += "&lastname=" + (lastname == null? "": lastname); |
|
139 |
errorUrl += "&email=" + (email == null? "": email); |
|
140 |
response.sendRedirect(errorUrl); |
|
141 |
return; |
|
142 |
} else if (firstname == null || firstname.isEmpty()) { |
|
143 |
String error = URLEncoder.encode("No firstname was specified", "UTF-8"); |
|
144 |
String errorUrl = "register.jsp?firstname=&error=" + error; |
|
145 |
errorUrl += "&username=" + username; |
|
146 |
errorUrl += "&lastname=" + (lastname == null? "": lastname); |
|
132 | 147 |
errorUrl += "&email=" + (email == null? "": email); |
133 | 148 |
response.sendRedirect(errorUrl); |
134 | 149 |
return; |
135 |
} else if (name == null || name.isEmpty()) {
|
|
136 |
String error = URLEncoder.encode("No name was specified", "UTF-8"); |
|
137 |
String errorUrl = "register.jsp?name=&error=" + error; |
|
150 |
} else if (lastname == null || lastname.isEmpty()) {
|
|
151 |
String error = URLEncoder.encode("No lastname was specified", "UTF-8");
|
|
152 |
String errorUrl = "register.jsp?lastname=&error=" + error;
|
|
138 | 153 |
errorUrl += "&username=" + username; |
154 |
errorUrl += "&firstname=" + firstname; |
|
139 | 155 |
errorUrl += "&email=" + (email == null? "": email); |
140 | 156 |
response.sendRedirect(errorUrl); |
141 | 157 |
return; |
... | ... | |
143 | 159 |
String error = URLEncoder.encode("No e-mail was specified", "UTF-8"); |
144 | 160 |
String errorUrl = "register.jsp?email=&error=" + error; |
145 | 161 |
errorUrl += "&username=" + username; |
146 |
errorUrl += "&name=" + name; |
|
162 |
errorUrl += "&firstname=" + firstname; |
|
163 |
errorUrl += "&lastname=" + lastname; |
|
147 | 164 |
response.sendRedirect(errorUrl); |
148 | 165 |
return; |
149 | 166 |
} else if (password == null || password.isEmpty()) { |
150 | 167 |
String error = URLEncoder.encode("No password was specified", "UTF-8"); |
151 | 168 |
String errorUrl = "register.jsp?error=" + error; |
152 | 169 |
errorUrl += "&username=" + username; |
153 |
errorUrl += "&name=" + name; |
|
170 |
errorUrl += "&firstname=" + firstname; |
|
171 |
errorUrl += "&lastname=" + lastname; |
|
154 | 172 |
errorUrl += "&email=" + email; |
155 | 173 |
response.sendRedirect(errorUrl); |
156 | 174 |
return; |
... | ... | |
158 | 176 |
String error = URLEncoder.encode("Passwords do not match", "UTF-8"); |
159 | 177 |
String errorUrl = "register.jsp?error=" + error; |
160 | 178 |
errorUrl += "&username=" + username; |
161 |
errorUrl += "&name=" + name; |
|
179 |
errorUrl += "&firstname=" + firstname; |
|
180 |
errorUrl += "&lastname=" + lastname; |
|
162 | 181 |
errorUrl += "&email=" + email; |
163 | 182 |
response.sendRedirect(errorUrl); |
164 | 183 |
return; |
... | ... | |
166 | 185 |
String error = URLEncoder.encode("You must accept the terms and conditions", "UTF-8"); |
167 | 186 |
String errorUrl = "register.jsp?error=" + error; |
168 | 187 |
errorUrl += "&username=" + username; |
169 |
errorUrl += "&name=" + name; |
|
188 |
errorUrl += "&firstname=" + firstname; |
|
189 |
errorUrl += "&lastname=" + lastname; |
|
170 | 190 |
errorUrl += "&email=" + email; |
171 | 191 |
response.sendRedirect(errorUrl); |
172 | 192 |
return; |
... | ... | |
178 | 198 |
if (user != null) { |
179 | 199 |
String error = URLEncoder.encode("The username already exists", "UTF-8"); |
180 | 200 |
String errorUrl = "register.jsp?username=&error=" + error; |
181 |
errorUrl += "&name=" + name; |
|
201 |
errorUrl += "&firstname=" + firstname; |
|
202 |
errorUrl += "&lastname=" + lastname; |
|
182 | 203 |
errorUrl += "&email=" + email; |
183 | 204 |
response.sendRedirect(errorUrl); |
184 | 205 |
return; |
185 | 206 |
} |
186 | 207 |
try { |
187 |
getService().createLdapUser(username, name, email, password); |
|
188 |
} catch (Exception exc) { |
|
189 |
String error = "An error occurred while communicating with the Shibboleth IdP"; |
|
190 |
logger.error(error, exc); |
|
191 |
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, error); |
|
208 |
getService().createLdapUser(username, firstname, lastname, email, password); |
|
209 |
} catch (Exception e) { |
|
210 |
logger.error(e); |
|
211 |
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); |
|
192 | 212 |
return; |
193 | 213 |
} |
194 | 214 |
final UserDTO userDto = new TransactionHelper<UserDTO>().tryExecute(new Callable<UserDTO>() { |
195 | 215 |
@Override |
196 | 216 |
public UserDTO call() throws Exception { |
197 |
return getService().createUser(username, name, email, "", "").getDTO(); |
|
217 |
return getService().createUser(username, firstname + " " + lastname, email, "", "").getDTO();
|
|
198 | 218 |
} |
199 | 219 |
|
200 | 220 |
}); |
... | ... | |
214 | 234 |
} catch (DuplicateNameException e) { |
215 | 235 |
// Can't happen, but this is more user-friendly than an assert. |
216 | 236 |
String error = URLEncoder.encode("The username already exists", "UTF-8"); |
217 |
String errorUrl = "register.jsp?username=&name=&email=&error=" + error; |
|
237 |
String errorUrl = "register.jsp?username=&firstname=&lastname=&email=&error=" + error;
|
|
218 | 238 |
response.sendRedirect(errorUrl); |
219 | 239 |
} catch (ObjectNotFoundException e) { |
220 | 240 |
// Can't happen, but this is more user-friendly than an assert. |
221 | 241 |
String error = URLEncoder.encode("No username or name was specified", "UTF-8"); |
222 |
String errorUrl = "register.jsp?username=&name=&email=&error=" + error; |
|
242 |
String errorUrl = "register.jsp?username=&firstname=&lastname=&email=&error=" + error;
|
|
223 | 243 |
response.sendRedirect(errorUrl); |
224 | 244 |
} catch (Exception e) { |
225 |
// TODO Auto-generated catch block
|
|
226 |
e.printStackTrace();
|
|
245 |
logger.error(e);
|
|
246 |
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
|
|
227 | 247 |
} |
228 | 248 |
} |
229 | 249 |
} |
b/src/gr/ebs/gss/server/ejb/ExternalAPI.java | ||
---|---|---|
829 | 829 |
* Create a new user with the specified name, username and e-mail address. |
830 | 830 |
* |
831 | 831 |
* @param username the username of the new user |
832 |
* @param name the full name of the new user
|
|
832 |
* @param name the name of the new user |
|
833 | 833 |
* @param mail the e-mail of the new user |
834 | 834 |
* @param idp the IdP of the new user |
835 | 835 |
* @param idpid the IdP identifier of the new user |
... | ... | |
1222 | 1222 |
* Create a new user in the connected IdP. |
1223 | 1223 |
* |
1224 | 1224 |
* @param username the username of the new user |
1225 |
* @param name the name of the new user |
|
1225 |
* @param firstname the first name of the new user |
|
1226 |
* @param lastname the last name of the new user |
|
1226 | 1227 |
* @param email the e-mail of the new user |
1227 | 1228 |
* @param password the password of the new user |
1228 | 1229 |
*/ |
1229 |
public void createLdapUser(String username, String name, String email, String password); |
|
1230 |
public void createLdapUser(String username, String firstname, String lastname, String email, String password);
|
|
1230 | 1231 |
|
1231 | 1232 |
} |
b/src/gr/ebs/gss/server/ejb/ExternalAPIBean.java | ||
---|---|---|
2641 | 2641 |
} |
2642 | 2642 |
|
2643 | 2643 |
@Override |
2644 |
public void createLdapUser(String username, String name, String email, String password) { |
|
2644 |
public void createLdapUser(String username, String firstname, String lastname, String email, String password) {
|
|
2645 | 2645 |
LDAPConnection lc = new LDAPConnection(); |
2646 | 2646 |
LDAPAttributeSet attributeSet = new LDAPAttributeSet(); |
2647 | 2647 |
attributeSet.add(new LDAPAttribute("objectClass", |
2648 | 2648 |
getConfiguration().getString("objectClass"))); |
2649 | 2649 |
attributeSet.add(new LDAPAttribute("uid", username)); |
2650 |
attributeSet.add(new LDAPAttribute("cn", new String[]{name})); |
|
2651 |
attributeSet.add(new LDAPAttribute("sn", name)); // XXX |
|
2650 |
attributeSet.add(new LDAPAttribute("cn", new String[]{firstname + " " + lastname})); |
|
2651 |
attributeSet.add(new LDAPAttribute("sn", lastname)); |
|
2652 |
attributeSet.add(new LDAPAttribute("givenName", firstname)); |
|
2652 | 2653 |
attributeSet.add(new LDAPAttribute("mail", email)); |
2653 | 2654 |
attributeSet.add(new LDAPAttribute("userPassword", password)); |
2654 | 2655 |
String dn = "uid=" + username + "," + getConfiguration().getString("baseDn"); |
b/war/register.jsp | ||
---|---|---|
38 | 38 |
<%= request.getParameter("error") != null? URLDecoder.decode(request.getParameter("error"), "UTF-8"): "" %> |
39 | 39 |
<table> |
40 | 40 |
<tr> |
41 |
<td>Name:</td> |
|
42 |
<td><input type="text" name="name" title="Enter a name" value="<%= request.getParameter("name") != null? request.getParameter("name"): "" %>"/></td> |
|
41 |
<td>Firstname:</td> |
|
42 |
<td><input type="text" name="firstname" title="Enter a firstname" value="<%= request.getParameter("firstname") != null? request.getParameter("firstname"): "" %>"/></td> |
|
43 |
</tr> |
|
44 |
<tr> |
|
45 |
<td>Lastname:</td> |
|
46 |
<td><input type="text" name="lastname" title="Enter a lastname" value="<%= request.getParameter("lastname") != null? request.getParameter("lastname"): "" %>"/></td> |
|
43 | 47 |
</tr> |
44 | 48 |
<tr> |
45 | 49 |
<td>E-Mail:</td> |
Also available in: Unified diff