{
String username = data.getValue("username");
String opasswd = data.getValue("opasswd");
String npasswd = data.getValue("npasswd");
String cpasswd = data.getValue("cpasswd");
HtmlGenerator g = null;
if ((username == null)
|| (opasswd == null)
|| (npasswd == null)
|| (cpasswd == null)) {
// Check that all values are available:
if (username == null)
g = generateForm("Fill in <em>all</em> the fields.");
else
g = generateForm("Hey, "+username+", could you feel in "
+ "<em>all</em> the fields please.");
} else if ( ! npasswd.equals(cpasswd) ) {
// Check that new and confirmed password are the same:
g = generateForm("New and confirmed password don't "
+ " match, try again "
+ ((username == null) ? "." : (username+".")));
} else if ( changePassword(username, opasswd, npasswd) ) {
// Run the change:
g = new HtmlGenerator("Password now changed.");
// Add style link
addStyleSheet(g);
g.append("<h1>Your password has been changed</h1>");
g.append("<p>Operation succeeded, have fun !");
} else {
// Changing the password failed, don't provide explanations:
g = new HtmlGenerator("Password change failed");
// Add style link
addStyleSheet(g);
g.append("<h1>Changing the password failed</h1>");
g.append("You were not allowed to change the password for user \""
, username
, "\".");
}
// We always succeed, that's cool:
Reply reply = createDefaultReply(request, HTTP.OK);