Changeset 3716 in main


Ignore:
Timestamp:
04/14/12 03:01:36 (10 years ago)
Author:
Garth Braithwaite
Message:

java and view - user profile account access UI polished a little more.

Location:
trunk/src/main
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/main/java/org/ibisph/user/modelmap/AbstractUserStatus.java

    r3715 r3716  
    33import java.util.Date;
    44
     5import org.dom4j.Document;
    56import org.dom4j.Element;
    67
     
    910import org.ibisph.web.servlet.AWTCaptchaServlet;
    1011
    11 
    1212/**
    13  * Processes a submitted user registration
     13 * Core definitions that the status type model maps extend from.
    1414 *
    1515 * @author Garth Braithwaite, STG
     
    1818  protected static org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(AbstractUserStatus.class);
    1919
     20  // user status values that the status view page keys off of.
    2021  public static final String NO_USER_ID_STATUS              = "INVALID_USER_ID";
    2122  public static final String USER_DOES_NOT_EXIST_STATUS     = "USER_DOES_NOT_EXIST";
     
    3536
    3637
     38  public void setCaptchaSessionName(String captchaSessionName) {
     39    this.captchaSessionName = captchaSessionName;
     40  }
    3741  public void setUserProfileModelMapKey(String userProfileModelMapKey) {
    3842    this.userProfileModelMapKey = userProfileModelMapKey;
     
    4549  /**
    4650   * Localizes setting of the user profile status.
    47    * @param userProfileElement
    48    * @param statusCode
     51   * @param userProfileDocument
     52   * @param status
    4953   */
    50   protected void setStatus(Element userProfileElement, String statusCode) {
    51     Element statusCodeElement = XMLLib.newElement("STATUS", statusCode);
    52     Element dateElement       = XMLLib.newElement("UPDATED_DTS", (new Date()).toString());
    53     XMLLib.replaceElement(userProfileElement, statusCodeElement);
    54     XMLLib.replaceElement(userProfileElement, dateElement);
     54  protected void setStatus(Document userProfileDocument, String status) {
     55    Element statusElement = XMLLib.newElement("STATUS", status);
     56    Element dateElement   = XMLLib.newElement("UPDATED_DTS", (new Date()).toString());
     57    XMLLib.replaceElement(userProfileDocument.getRootElement(), statusElement);
     58    XMLLib.replaceElement(userProfileDocument.getRootElement(), dateElement);
    5559  } //-------------------------- End of Method ------------------------------
    5660
  • trunk/src/main/java/org/ibisph/user/modelmap/ProcessUserRegistration.java

    r3715 r3716  
    1717
    1818/**
    19  * Processes a submitted user registration
     19 * Processes a submitted new user registration.  Various tests are performed
     20 * with a user XML model being returned.  The status page view uses the user's
     21 * status to determine which message to show the user.  If all goes well the
     22 * verification email is sent and the user's XML is saved.
    2023 *
    2124 * @author Garth Braithwaite, STG
     
    7073    Element userProfileElement = (Element)modelMap.get(this.userProfileModelMapKey);
    7174
    72     // the xslt parameter can't deal with Element objects - convert to document.
     75    // The status page uses the user XML as a model to determine which message
     76    // to show.  So, for the first set of status codes need to have a user doc.
     77    // as the XSLT only deals with documents - can't handle elements.
    7378    Document userProfileDocument = XMLLib.newDocument(userProfileElement);
    7479    modelMap.put(this.userProfileModelMapKey, userProfileDocument);
     
    7782    if(!StrLib.isSomething(id)) {
    7883      logger.warn(".processModelMap - NO USER ID.  User's IP: {}", request.getRemoteAddr());
    79       setStatus(userProfileElement, AbstractUserStatus.NO_USER_ID_STATUS);
     84      setStatus(userProfileDocument, AbstractUserStatus.NO_USER_ID_STATUS);
    8085      return;
    8186    }
     
    8590    if(null != userProfile) {
    8691      logger.warn(".processModelMap - USER ALREADY EXISTS.  User's ID: {}, User's IP: {}", id, request.getRemoteAddr());
    87       setStatus(userProfileElement, AbstractUserStatus.USER_PROFILE_EXISTS_STATUS);
     92      setStatus(userProfileDocument, AbstractUserStatus.USER_PROFILE_EXISTS_STATUS);
    8893      return;
    8994    }
     
    9499    if((null == userSessionCaptcha) || (null == userProfileCaptcha) || !userProfileCaptcha.equals(userSessionCaptcha)) {
    95100      logger.info(".processModelMap - INVALID CAPTCHA.  User's ID: {}, User's IP: {}", id, request.getRemoteAddr());
    96       setStatus(userProfileElement, AbstractUserStatus.INVALID_CAPTCHA_STATUS);
     101      setStatus(userProfileDocument, AbstractUserStatus.INVALID_CAPTCHA_STATUS);
    97102      return;
    98103    }
    99104
    100     // send the verification email message and set status accordingly.
    101105    String emailAddress = XMLLib.getText(userProfileElement, "EMAIL_ADDRESS");
    102106    if(!StrLib.isSomething(emailAddress)) {
    103107      logger.warn(".processModelMap - MISSING EMAIL ADDRESS, User's IP: {}", request.getRemoteAddr());
    104       setStatus(userProfileElement, AbstractUserStatus.INVALID_EMAIL_ADDRESS_STATUS);
     108      setStatus(userProfileDocument, AbstractUserStatus.INVALID_EMAIL_ADDRESS_STATUS);
    105109      return;
    106110    }
    107111
     112    // If here then so far so good - send the verification email message and
     113    // set status accordingly.
    108114    String verificationValue = request.getSession().getId();
    109     if(sendVerificationEmail(request, userProfileElement, id, emailAddress, verificationValue)) {
     115    if(sendVerificationEmail(request, userProfileDocument, id, emailAddress, verificationValue)) {
    110116      // if here then all was normal.  set the status code.
    111117      Element verificationElement = XMLLib.newElement("VERIFICATION", verificationValue);
    112       XMLLib.replaceElement(userProfileElement, verificationElement);
    113       setStatus(userProfileElement, AbstractUserStatus.VERIFICATION_EMAIL_SENT_STATUS);
     118      XMLLib.replaceElement(userProfileDocument.getRootElement(), verificationElement);
    114119      this.userProfileService.saveUser(userProfileDocument);
    115120    }
     
    121126   * Localized code for sending the verification email.
    122127   * @param request
    123    * @param userProfileElement
     128   * @param userProfileDocument
    124129   * @param id
    125130   * @param emailAddress
     
    129134  protected boolean sendVerificationEmail(
    130135    HttpServletRequest request,
    131     Element userProfileElement,
     136    Document userProfileDocument,
    132137    String id,
    133138    String emailAddress,
     
    157162    catch(AddressException ae) {
    158163      logger.warn(".processModelMap - Email Address error, Address: {}", emailAddress);
    159       setStatus(userProfileElement, AbstractUserStatus.INVALID_EMAIL_ADDRESS_STATUS);
     164      setStatus(userProfileDocument, AbstractUserStatus.INVALID_EMAIL_ADDRESS_STATUS);
    160165      return(false);
    161166    }
    162167    catch(Exception e) {
    163168      logger.error(".processModelMap - General Email Error. Address: {}", emailAddress, e);
    164       setStatus(userProfileElement, AbstractUserStatus.EMAIL_ERROR_STATUS);
     169      setStatus(userProfileDocument, AbstractUserStatus.EMAIL_ERROR_STATUS);
    165170      return(false);
    166171    }
    167172
     173    setStatus(userProfileDocument, AbstractUserStatus.VERIFICATION_EMAIL_SENT_STATUS);
    168174    return(true);
    169 } //-------------------------- End of Method ------------------------------
    170 
     175  } //-------------------------- End of Method ------------------------------
    171176
    172177} //============================ END OF CLASS =================================
  • trunk/src/main/java/org/ibisph/user/modelmap/SendAccess.java

    r3715 r3716  
    1616
    1717/**
    18  * Processes the send password or verification email.
     18 * Processes the send password or send verification email.
    1919 *
    2020 * @author Garth Braithwaite, STG
     
    3333
    3434  /**
    35    * returns a user profile document with an appropriate message string.
     35   * Modify's the user profile document with an appropriate message string.
     36   * Note that this code does NOT save any user XML - it simply reads the
     37   * content and sets an internal memory model for the status page.
    3638   *
    3739   * @param request HttpServletRequest .
     
    4143    Element userProfileElement = (Element)modelMap.get(this.userProfileModelMapKey);
    4244
    43     // the xslt parameter can't deal with Element objects - convert to document.
     45    // The status page uses the user XML as a model to determine which message
     46    // to show.  So, for the first set of status codes need to have a user doc.
     47    // as the XSLT only deals with documents - can't handle elements.
    4448    Document userProfileDocument = XMLLib.newDocument(userProfileElement);
    4549    modelMap.put(this.userProfileModelMapKey, userProfileDocument);
     
    4751    String id = XMLLib.getText(userProfileElement, "ID");
    4852    if(!StrLib.isSomething(id)) {
    49       setStatus(userProfileElement, AbstractUserStatus.NO_USER_ID_STATUS);
     53      setStatus(userProfileDocument, AbstractUserStatus.NO_USER_ID_STATUS);
    5054      return;
    5155    }
     
    5660    if((null == userSessionCaptcha) || (null == userProfileCaptcha) || !userProfileCaptcha.equals(userSessionCaptcha)) {
    5761      logger.info(".processModelMap - INVALID CAPTCHA.  User's ID: {}, User's IP: {}", id, request.getRemoteAddr());
    58       setStatus(userProfileElement, AbstractUserStatus.INVALID_CAPTCHA_STATUS);
     62      setStatus(userProfileDocument, AbstractUserStatus.INVALID_CAPTCHA_STATUS);
    5963      return;
    6064    }
    6165
    6266    // check to see if user profile exists.  If not return message.
    63     Document userProfile = this.userProfileService.getUser(id);
    64     if(null == userProfile) {
     67    userProfileDocument = this.userProfileService.getUser(id);
     68    modelMap.put(this.userProfileModelMapKey, userProfileDocument);
     69    if(null == userProfileDocument) {
     70      userProfileDocument = XMLLib.newDocument(userProfileElement);
     71      modelMap.put(this.userProfileModelMapKey, userProfileDocument);
    6572      logger.warn(".processModelMap - USER DOES NOT EXIST.  User's ID: {}, User's IP: {}", id, request.getRemoteAddr());
    66       setStatus(userProfileElement, AbstractUserStatus.USER_DOES_NOT_EXIST_STATUS);
     73      setStatus(userProfileDocument, AbstractUserStatus.USER_DOES_NOT_EXIST_STATUS);
    6774      return;
    6875    }
     
    7077    // if here then check the status.  If verified then send the password else
    7178    // send the verify email.
    72     userProfileElement  = userProfile.getRootElement();
    73     String userStatus   = XMLLib.getText(userProfileElement, "STATUS");
    74     String emailAddress = XMLLib.getText(userProfileElement, "EMAIL_ADDRESS");
     79    String userStatus   = XMLLib.getText(userProfileDocument, "/USER/STATUS");
     80    String emailAddress = XMLLib.getText(userProfileDocument, "/USER/EMAIL_ADDRESS");
    7581    if(AbstractUserStatus.REGISTRATION_VERIFIED_STATUS.equals(userStatus)) {
    76       String password = XMLLib.getText(userProfileElement, "PASSWORD");
     82      String password = XMLLib.getText(userProfileDocument, "/USER/PASSWORD");
    7783      try {
    7884        emailPasswordService.sendMergedEmailMessage(
     
    8389      catch(AddressException ae) {
    8490        logger.warn(".processModelMap - Email Address error, Address: {}", emailAddress);
    85         setStatus(userProfileElement, AbstractUserStatus.INVALID_EMAIL_ADDRESS_STATUS);
     91        setStatus(userProfileDocument, AbstractUserStatus.INVALID_EMAIL_ADDRESS_STATUS);
    8692        return;
    8793      }
    8894      catch(Exception e) {
    8995        logger.error(".processModelMap - General Email Error. Address: {}", emailAddress, e);
    90         setStatus(userProfileElement, AbstractUserStatus.EMAIL_ERROR_STATUS);
     96        setStatus(userProfileDocument, AbstractUserStatus.EMAIL_ERROR_STATUS);
    9197        return;
    9298      }
    93      
     99
    94100      logger.info(".processModelMap - PASSWORD EMAILED.  Email Address: {}, User's IP: {}", emailAddress, request.getRemoteAddr());
    95       setStatus(userProfileElement, AbstractUserStatus.PASSWORD_EMAIL_SENT_STATUS);
     101      setStatus(userProfileDocument, AbstractUserStatus.PASSWORD_EMAIL_SENT_STATUS);
    96102    }
    97103
    98104    // else send the verification
    99105    else {
    100       String verificationValue = XMLLib.getText(userProfileElement, "VERIFICATION");
    101       sendVerificationEmail(request, userProfileElement, id, emailAddress, verificationValue);
    102       setStatus(userProfileElement, AbstractUserStatus.VERIFICATION_EMAIL_SENT_STATUS);
     106      String verificationValue = XMLLib.getText(userProfileDocument, "/USER/VERIFICATION");
     107      sendVerificationEmail(request, userProfileDocument, id, emailAddress, verificationValue);
    103108    }
    104109   
  • trunk/src/main/java/org/ibisph/user/modelmap/VerifyUserRegistration.java

    r3715 r3716  
    77
    88import org.dom4j.Document;
    9 import org.dom4j.Element;
    109
    1110import org.ibisph.modelmap.GetModelMapFromHTTPRequest;
     
    1615
    1716/**
    18  * Checks the verification email and sets the user's status to VERIFIED if matches.
     17 * Verification email response handler.  Sets the user's XML status to VERIFIED
     18 * if matches and to appropriate value if an issue exists.  The model is the
     19 * user XML that the status page keys off of.
    1920 *
    2021 * @author Garth Braithwaite, STG
     
    2425  //------------------------ M A I N   R E Q U E S T   M O D E L   M E T H O D
    2526  /**
    26    * returns appropriate message string for the new registration.
     27   * Checks the user's verification value against the value from the request
     28   * URL.  Returns a user XML document which has an appropriate status value
     29   * that the status page will key off of.  The request URL is of the form:
     30   *  verify/user/registration/braithwaitegarth%40msn.com/C162EB04DFF67A5850B32DFC104865BB
    2731   *
    2832   * @param request HttpServletRequest .
     
    3034   */
    3135  public Map<String, Object> getModelMap(HttpServletRequest request) throws Exception {
    32 // verify/user/registration/braithwaitegarth%40msn.com/C162EB04DFF67A5850B32DFC104865BB
    3336    String requestVerificationValue = IOPath.getFilename(request.getPathInfo());
    3437    String path = IOPath.getPath(request.getPathInfo());
    3538    String userID = IOPath.getFilename(path);
    3639    Document userProfileDocument = this.userProfileService.getUser(userID);
    37     Element  userElement = userProfileDocument.getRootElement();
    38     String userVerificationValue = XMLLib.getText(userElement, "VERIFICATION");
     40    String userVerificationValue = XMLLib.getText(userProfileDocument, "/USER/VERIFICATION");
    3941
    4042    if(!StrLib.isSomething(userID)) {
    4143      logger.error(".processModelMap - INVALID USER ID.  User's IP: {}", request.getRemoteAddr());
    42       userElement = XMLLib.newElement("USER");
    43       userProfileDocument = XMLLib.newDocument(userElement);
    44       setStatus(userElement, AbstractUserStatus.NO_USER_ID_STATUS);
     44      userProfileDocument = XMLLib.newDocument(XMLLib.newElement("USER"));
     45      setStatus(userProfileDocument, AbstractUserStatus.NO_USER_ID_STATUS);
    4546    }
    4647
    4748    else if((null == requestVerificationValue) || (null == userVerificationValue) || !requestVerificationValue.equals(userVerificationValue)) {
    4849      logger.error(".processModelMap - INVALID VERFICATION.  Email Address: {}, User's IP: {}", userID, request.getRemoteAddr());
    49       setStatus(userElement, AbstractUserStatus.INVALID_VERIFICATION_STATUS);
     50      setStatus(userProfileDocument, AbstractUserStatus.INVALID_VERIFICATION_STATUS);
    5051    }
    5152
    5253    else {
    5354      // if here then verified.  set the status, save the user, and return.
    54       setStatus(userElement, AbstractUserStatus.REGISTRATION_VERIFIED_STATUS);
     55      setStatus(userProfileDocument, AbstractUserStatus.REGISTRATION_VERIFIED_STATUS);
    5556      this.userProfileService.saveUser(userProfileDocument);
    5657    }
  • trunk/src/main/java/org/ibisph/user/service/EmailAccountAccess.java

    r3715 r3716  
    1212
    1313/**
    14  * Sends a simple merged value Email message to an address.
     14 * Sends a HTML or merged value HTEML Email message to an address.
    1515 *
    1616 * @author Garth Braithwaite, STG
  • trunk/src/main/webapps/ibisph-view/WEB-INF/config/spring/user.xml

    r3715 r3716  
    227227
    228228                                                <h2>Password: [Password_SearchReplaceSignature]</h2>
    229                                                 <br/><br/>
    230 
    231                                                 If you did NOT register for an account or is you did not
    232                                                 request your password to be emailed to you please report
    233                                                 this to the system administrator.
     229                                                <br/>
     230
     231                                                If you did NOT register for an account or if you did not
     232                                                request this password reminder email please report this
     233                                                potential security issue to the system administrator.
    234234                                        </body>
    235235                                </html>
  • trunk/src/main/webapps/ibisph-view/WEB-INF/jsp/access_denied.jsp

    r3715 r3716  
    6060                                        A problem was encountered while trying to access the application.
    6161                                        Possible Reasons:
    62                                         <hr/>
    6362                                        <ul>
    6463                                                <li>Invalid login credentials (username and/or password)</li>
  • trunk/src/main/webapps/ibisph-view/xml/user/html_content/Status.xml

    r3715 r3716  
    9292                        be shown a "Verified" message.  You will then be able to login to
    9393                        your account using your email and the password you specified.  Once
    94                         logged in you can then create saved query definitions and query
    95                         criteria. 
     94                        logged in you can create saved query definitions and query criteria. 
    9695                        <br/><br/>
    9796
     
    9998                        check you junk email folder.  If you still do not get a message
    10099                        you should check with your email provider to make sure that they
    101                         are not screening the email as junk.  If you would like your
     100                        are not filtering the email as junk.  If you would like your
    102101                        verification email sent again please visit the <a ibis:href="user/AccountAccess.html">Account
    103102                        Access</a> page. 
     
    139138                <ibis:ContiditionalSection id="VERIFIED">
    140139                        <h2>Account Verified and Active</h2>
     140                        You have successfully verified and activated your IBIS-PH user account.
     141                        You can now save query dataset definitions and criteria definitions. 
     142                        You can login to your account at the time of saving your definition
     143                        or you can login now via the <a ibis:href="user/Login.html">User Login</a>
     144                        page.
     145                        <br/><br/>
     146
     147                        If you have forgotten your password please visit the <a ibis:href="user/AccountAccess.html">Account
     148                        Access</a> page.  If you have concerns about your account please
     149                        contact this application's system administrator.
    141150                </ibis:ContiditionalSection>
    142151
     
    145154                        An email has been sent to your email address that contains your
    146155                        password.  Please wait a few seconds then check your inbox.  If
    147                         you do NOT receive a password email message please check you junk
     156                        you do NOT receive a password email message, please check you junk
    148157                        email folder.  If you still do not get a message you should check
    149                         with your email provider to make sure that they are not screening
    150                         the email as junk
     158                        with your email provider to make sure that they are not filtering
     159                        out email messages from us
    151160                        <br/><br/>
    152161
Note: See TracChangeset for help on using the changeset viewer.