Skip to content

Commit

Permalink
notes added and obsolete code removed
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwechner committed Apr 2, 2012
1 parent d539780 commit c457b57
Showing 1 changed file with 12 additions and 14 deletions.
Expand Up @@ -46,7 +46,7 @@ public class UserRegistrationResource extends BasicXMLResource {

private static Logger log = Logger.getLogger(UserRegistrationResource.class);

static String NAMESPACE = "http://www.wyona.org/yanel/user-registration/1.0";
private static String NAMESPACE = "http://www.wyona.org/yanel/user-registration/1.0";

private static String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ssZ";

Expand All @@ -63,11 +63,6 @@ protected InputStream getContentXML(String viewId) throws Exception {
log.debug("requested viewId: " + viewId);
}

/*
SharedResource shared = new SharedResource();
KKEngIf kkEngine = shared.getKonakartEngineImpl();
*/

// INFO: Build response document
Document doc = null;
try {
Expand Down Expand Up @@ -285,6 +280,7 @@ private void registerUser(Document doc, UserRegistrationBean userRegBean) throws
*/
protected User activateUser(UserRegistrationBean userRegBean) throws Exception {
long customerID = new java.util.Date().getTime();
// TODO: Use encrypted password
User user = getRealm().getIdentityManager().getUserManager().createUser("" + customerID, userRegBean.getFirstname() + " " + userRegBean.getLastname(), userRegBean.getEmail(), userRegBean.getPassword());
// TODO: user.setProperty("gender", gender);
user.setLanguage(getContentLanguage());
Expand Down Expand Up @@ -317,7 +313,7 @@ protected void saveRegistrationRequest(UserRegistrationBean urb) throws Exceptio
* Generate registration request as XML
* @param urb User registration bean containing E-Mail address of user, etc.
*/
private Document getRegistrationRequestAsXML(UserRegistrationBean urb) {
private Document getRegistrationRequestAsXML(UserRegistrationBean urb) { // TODO: What about custom fields?!
Document doc = XMLHelper.createDocument(NAMESPACE, "registration-request");
Element rootElem = doc.getDocumentElement();
rootElem.setAttribute("uuid", urb.getUUID());
Expand All @@ -327,7 +323,13 @@ private Document getRegistrationRequestAsXML(UserRegistrationBean urb) {

// IMPORTANT TODO: Password needs to be encrypted!
Element passwordElem = doc.createElementNS(NAMESPACE, "password");
passwordElem.setAttribute("algorithm", "plaintext");
passwordElem.setTextContent(urb.getPassword());
/*
passwordElem.setAttribute("algorithm", "SHA-256");
passwordElem.setTextContent(encrypt(urb.getPassword()));
// TODO: What about salt?!
*/
rootElem.appendChild(passwordElem);

Element genderElem = doc.createElementNS(NAMESPACE, "gender");
Expand Down Expand Up @@ -384,7 +386,7 @@ public String getActivationURL(String uuid) throws Exception {
}

/**
*
* @email E-Mail of user which will be used as username/alias
*/
private void processRegistrationRequest(Document doc, String email) throws Exception {
Element rootElement = doc.getDocumentElement();
Expand All @@ -399,12 +401,6 @@ private void processRegistrationRequest(Document doc, String email) throws Excep
Element exception = (Element) rootElement.appendChild(doc.createElementNS(NAMESPACE, "email-in-use"));
inputsValid = false;
}
/*
if(kkEngine.doesCustomerExistForEmail(email)) {
Element exception = (Element) rootElement.appendChild(doc.createElementNS(NAMESPACE, "email-in-use"));
inputsValid = false;
}
*/
Element emailE = (Element) rootElement.appendChild(doc.createElementNS(NAMESPACE, "email"));
emailE.appendChild(doc.createTextNode("" + email));
}
Expand All @@ -416,6 +412,7 @@ private void processRegistrationRequest(Document doc, String email) throws Excep
}
String confirmedPassword = getEnvironment().getRequest().getParameter("password2");
if (password != null && confirmedPassword != null && !password.equals(confirmedPassword)) {
log.warn("Passwords do not match!");
Element exception = (Element) rootElement.appendChild(doc.createElementNS(NAMESPACE, "passwords-do-not-match"));
inputsValid = false;
}
Expand Down Expand Up @@ -517,6 +514,7 @@ private void processRegistrationRequest(Document doc, String email) throws Excep
userRegBean.setUUID(uuid);
try {
saveRegistrationRequest(userRegBean);
// TODO: Already create user, because of password encryption, but disable via expire?!
sendConfirmationLinkEmail(doc, userRegBean);
} catch(Exception e) {
log.error(e, e);
Expand Down

0 comments on commit c457b57

Please sign in to comment.