gvSIGAssociation / gvnix

gvNIX project
http://www.gvnix.org
GNU General Public License v3.0
41 stars 20 forks source link

Bootstrap addon hard references to petclinic, although different project #16

Open Forgev41 opened 9 years ago

Forgev41 commented 9 years ago

I think I have an issue with the combination of Typical security and bootstrap.

You can reproduce it with the supplied Roo script, see below.

I used Spring Roo spring-roo-2.0.0.M1 and installed gvNix 2.0 as explained in gvNIX install guide

The issue is that although in my sample roo script the project is named "pizzashop", after applying bootstrap the login.jspx and other pages of the (typical) security addon hard reference to the "petclinic".

Also the extra field in the user entity is missing in the bootstrap version. So although bootstrap is applied later than the addition of the extra field in the user entity, yet in the bootstrap version it is missing. Looks like a "petclinic typical security bootstrap" version is always added.

Did I miss something or is this the problem: https://github.com/gvSIGAssociation/gvnix/blob/master/addon-web-mvc-typicalsecurity/src/main/resources/org/gvnix/web/typicalsecurity/roo/addon/users/bootstrap/create.jspx, update.jspx, list.jspx, show,jspx. And that for user, roles and userroles. Further the login.jspx file and more files.

Should not these typical security files be treated with the bootstrap add-on, as the rest of the entities are and not have the typical security add-on add its bootstrap files itself? That is what I expected. Then the additional fields I added to the user entity are treated correctly?

Below the bootstrap version of create.jspx (...\webapp\WEB-INF\views\users\bootstrap\create.jspx)

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<div xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:field="urn:jsptagdir:/WEB-INF/tags/jquery/form/fields" xmlns:form="urn:jsptagdir:/WEB-INF/tags/jquery/form" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:spring="http://www.springframework.org/tags" version="2.0">
    <jsp:directive.page contentType="text/html;charset=UTF-8"/>
    <jsp:output omit-xml-declaration="yes"/>
    <form:create id="fc_com_springsource_petclinic_domain_User" modelAttribute="user" path="/users" render="${empty dependencies}" z="+jRyHVhBEV/cFVVqZ2X7gRpRUe0=">
        <field:input field="firstName" id="c_com_springsource_petclinic_domain_User_firstName" min="1" required="true" z="bAAIecfsT2Tj+ynw5Vxo4e8+sR8="/>
        <field:input field="lastName" id="c_com_springsource_petclinic_domain_User_lastName" min="1" required="true" z="GAATzTOHekLxr4ADfXY3uh20goY="/>
        <field:input field="emailAddress" id="c_com_springsource_petclinic_domain_User_emailAddress" min="1" required="true" validationMessageCode="field_invalid_email" z="bUVqTUxuRkokU/jdiVgSDUy3/dA="/>
        <field:input field="password" id="c_com_springsource_petclinic_domain_User_password" min="1" required="true" z="jmNd0Kcgh6RoKCu3alSc2oXGN+s="/>
        <field:datetime dateTimePattern="${user_activationdate_date_format}" field="activationDate" id="c_com_springsource_petclinic_domain_User_activationDate" z="pTcVF/RJ+Lpb1dwoywJ2c0Q7y7w="/>
        <field:input field="activationKey" id="c_com_springsource_petclinic_domain_User_activationKey" z="Xm6LQ9a7H1j/lBDlviWln8x3K70="/>
        <field:checkbox field="enabled" id="c_com_springsource_petclinic_domain_User_enabled" z="NTl2TEUvBaJOmNwKhXMFIsvKfOY="/>
        <field:checkbox field="locked" id="c_com_springsource_petclinic_domain_User_locked" z="bduPyb+CItpYAxBb2mYD6EPbDJs="/>
    </form:create>
    <form:dependency dependencies="${dependencies}" id="d_com_springsource_petclinic_domain_User" render="${not empty dependencies}" z="7AcW6vG3sj47sjz6gywuOAXxrkA="/>
</div>

While this is the "normal" create.jspx file (...\webapp\WEB-INF\views\users\create.jspx):

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<div xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:field="urn:jsptagdir:/WEB-INF/tags/jquery/form/fields" xmlns:form="urn:jsptagdir:/WEB-INF/tags/jquery/form" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:spring="http://www.springframework.org/tags" version="2.0">
    <jsp:directive.page contentType="text/html;charset=UTF-8"/>
    <jsp:output omit-xml-declaration="yes"/>
    <form:create id="fc_com_springsource_pizzashop_domain_User" modelAttribute="user" path="/users" render="${empty dependencies}" z="YAexdS/vfgPAYkfRVtmkytaujSI=">
        <field:input field="firstName" id="c_com_springsource_pizzashop_domain_User_firstName" min="1" required="true" z="bMheWodatrF4cijI5qLZWKg9L3c="/>
        <field:input field="lastName" id="c_com_springsource_pizzashop_domain_User_lastName" min="1" required="true" z="FXBh18v8jaeeU/7ziJkOhQez6gE="/>
        <field:input field="emailAddress" id="c_com_springsource_pizzashop_domain_User_emailAddress" min="1" required="true" validationMessageCode="field_invalid_email" z="t1Qs4WPk9i+PeXWHXOmWjwq8bt4="/>
        <field:input field="password" id="c_com_springsource_pizzashop_domain_User_password" min="1" required="true" z="p0he5hzUAktk+mQLqa/66q5taSg="/>
        <field:datetime dateTimePattern="${user_activationdate_date_format}" field="activationDate" id="c_com_springsource_pizzashop_domain_User_activationDate" z="aQTNhbuOYQRFAr8lj3MvnReMsrM="/>
        <field:input field="activationKey" id="c_com_springsource_pizzashop_domain_User_activationKey" z="DVJkmAi/D7W/9flVDObXbaL/Kg4="/>
        <field:checkbox field="enabled" id="c_com_springsource_pizzashop_domain_User_enabled" z="xpyagmIFKZoJMBFbFsarRbO4WfQ="/>
        <field:checkbox field="locked" id="c_com_springsource_pizzashop_domain_User_locked" z="hUyJlLOyu3fnMQsnT8ynn7iqrJM="/>
        <field:textarea field="lastnamePrefix" id="c_com_springsource_pizzashop_domain_User_lastnamePrefix" z="LCZgougUVrhsijqAPyM1dU+kZPo="/>
        <field:textarea field="address" id="c_com_springsource_pizzashop_domain_User_address" required="true" z="hgj2kD7wXgBhbpZ16F4foROd3Zg="/>
    </form:create>
    <form:dependency dependencies="${dependencies}" id="d_com_springsource_pizzashop_domain_User" render="${not empty dependencies}" z="kdyjS9yehruLzrkviAWXZyRTZjY="/>
</div>

Watch for the difference: fc_com_springsource_pizzashop_domain_User vs fc_com_springsource_petclinic_domain_User

Worse, in the login.jspx the petclinic has hard reference, although my sample project is pizzshop, see Roo script below. Roo script:

    // Create a new project
project setup --topLevelPackage com.springsource.pizzashop --projectName pizzashop

// Setup JPA persistence using EclipseLink and H2
jpa setup --provider HIBERNATE --database HYPERSONIC_IN_MEMORY

// Create domain entities
entity jpa --class ~.domain.Base
field string --fieldName name --sizeMin 2 --notNull

// Adding web layers
web mvc setup
web mvc all --package ~.web
web mvc finder all

// Adding Spring security
typicalsecurity setup

focus --class ~.domain.User
field string --fieldName lastnamePrefix --sizeMax 50
field string --fieldName address --notNull --sizeMax 500

// Adding JQuery, Datatables and Bootstrap
web mvc jquery setup
web mvc jquery all
web mvc datatables setup
web mvc bootstrap setup

//  Setup menu
menu setup

// Adding Spring security
//  security setup
web mvc bootstrap update

Login.jspx:

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<div  class="well" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:fn="http://java.sun.com/jsp/jstl/functions" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:spring="http://www.springframework.org/tags" xmlns:util="urn:jsptagdir:/WEB-INF/tags/jquery/util" xmlns:field="urn:jsptagdir:/WEB-INF/tags/jquery/form/fields" version="2.0">
  <jsp:directive.page contentType="text/html;charset=UTF-8"/>
  <jsp:output omit-xml-declaration="yes"/>

    <c:if test="${not empty param.login_error}">
      <div class="alert alert-danger">
        <p>
          <spring:message code="security_login_unsuccessful"/>
          <c:out value="${SPRING_SECURITY_LAST_EXCEPTION.message}"/>
          .
        </p>
      </div>
    </c:if>

    <c:if test="${empty param.login_error}">
      <div class="alert alert-info">
          <p><spring:message code="security_login_message"/></p>
      </div>
    </c:if>

    <spring:url value="/resources/j_spring_security_check" var="form_url"/>

    <form action="${fn:escapeXml(form_url)}" method="POST" name="f" class="form-signin">

        <h2 class="form-signin-heading"><spring:message code="security_login_title"/></h2>

        <spring:message code="security_login_form_name" var="name" />
        <spring:message code="security_login_form_name_message" htmlEscape="false" var="name_msg"/>
        <input class="form-control" type="text" placeholder="${name}" autofocus="autofocus" id="j_username" name="j_username" data-required="true" data-minlength="3" data-maxlength="30" data-original-title="${name_msg}" />
            <!-- <script type="text/javascript">
              <c:set var="sec_name_msg">
                <spring:escapeBody javaScriptEscape="true">${name_msg}</spring:escapeBody>
              </c:set>
              Spring.addDecoration(new Spring.ElementDecoration({elementId : "j_username", widgetType : "dijit.form.ValidationTextBox", widgetAttrs : {promptMessage: "${sec_name_msg}", required : true}}));
            </script> -->

        <spring:message code="security_login_form_password" var="pass"/>
        <spring:message code="security_login_form_password_message" htmlEscape="false" var="pwd_msg"/>
        <input type="password" class="form-control" placeholder="${pass}" id="j_password" name="j_password" data-required="true" data-minlength="3" data-maxlength="30" data-original-title="${pwd_msg}" />
            <!-- <script type="text/javascript">
              <c:set var="sec_pwd_msg">
                <spring:escapeBody javaScriptEscape="true">${pwd_msg}</spring:escapeBody>
              </c:set>
              Spring.addDecoration(new Spring.ElementDecoration({elementId : "j_password", widgetType : "dijit.form.ValidationTextBox", widgetAttrs : {promptMessage: "${sec_pwd_msg}", required : true}}));
            </script> -->

        <div class="submit">
            <script type="text/javascript">Spring.addDecoration(new Spring.ValidateAllDecoration({elementId:'proceed', event:'onclick'}));</script>
            <button type="submit" class="btn btn-primary btn-lg btn-block" id="proceed"><spring:message code="button_submit"/></button>
            <button type="reset" class="btn btn-default btn-sm btn-block" id="reset"><spring:message code="button_reset"/></button>

        </div>

      <div class="text-center">
      &lt;a href ="/petclinic/forgotpassword/index"&gt;Forgot Password&lt;/a&gt; | Not a User Yet? &lt;a href ="/petclinic/signup?form"&gt;Sign Up&lt;/a&gt;
      </div>

      </form>

</div>
jcagarcia commented 9 years ago

Hi @Forgev41 and thanks for your report!

I will check this issue and we will take in mind for next version of gvNIX!

Regards,