Announcement Announcement Module
No announcement yet.
Spring Roo - Spring Security - Sql Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Roo - Spring Security - Sql

    Hello everybody,

    I'm trying to use Roo with Spring Security and a mysql database.
    Moreover I want to use scaffolding so as to manage my users.
    Following instructions in

    I've tried a lot of things like:

    entity --class ~.domain.Users --identifierField username --identifierColumn username --permitReservedWords 
    field string --fieldName username --notNull --sizeMin 3 --sizeMax 50
    field string --fieldName password --notNull
    field boolean --fieldName enabled --notNull true
    But I'm not able to get Roo to generate my tables like I'll do manually

    CREATE TABLE users(
    username varchar(50) NOT NULL PRIMARY KEY,
    password varchar(50) NOT NULL,
    enabled BOOLEAN NOT NULL);
    CREATE TABLE authorities(
    username varchar( 50 ) NOT NULL ,
    authority varchar( 50 ) NOT NULL ,
    CONSTRAINT fk_authorities_users FOREIGN KEY ( username ) REFERENCES users( username )
    CREATE UNIQUE INDEX ix_auth_username ON authorities(username,authority);
    btw as 'user' and 'member' are sql reserved keywords nothing work.

    How could I use Spring Roo / Spring Security / a mysql database?
    Has someone already done it?

    Many thanks.

  • #2
    In order to 'tweak' JPA in a way that it generates the exact tables you want you may need to adjust some of the annotations in your domain entities manually. As for the use of reserved words a workaround would be to change the table names so there is no clash. In the Spring Security application context you can then configure the custom table names.

    Generally, this is certainly something that could be useful for the Spring Security addon in Roo itself (automatic scaffolding of user/role management, signup forms, etc) so if you want you can open a ticket as a feature request for this.


    • #3
      feature request for a better spring security addon opened

      At first, thank you for your explanation Stephan.

      I've just open a feature request for a better spring security addon created in Jira:


      • #4
        I've tried with this script

        entity --class com.crmizer.domain.crmo.rbac.Users --testAutomatically 
        field string --fieldName username --notNull --sizeMax 50
        field string --fieldName password --notNull --sizeMax 50
        field boolean --fieldName enabled --notNull 
        field string --fieldName shortname --notNull --sizeMax 20
        finder add --finderName findUsersesByShortnameLike --class *
        finder add --finderName findUsersesByEnabled --class * 
        finder add --finderName findUsersesByShortnameLikeAndEnabled --class *
        entity --class com.crmizer.domain.crmo.rbac.Authorities --testAutomatically 
        field string --fieldName username --notNull --sizeMax 50
        field string --fieldName authority --notNull --sizeMax 50
        finder add --finderName findAuthoritiesesByAuthorityLike --class *
        finder add --finderName findAuthoritiesesByAuthorityLikeAndUsernameLike --class *
        finder add --finderName findAuthoritiesesByUsernameLike --class *
        entity --class com.crmizer.domain.crmo.rbac.Persistent_logins
        field string --fieldName username --notNull --sizeMax 64
        field string --fieldName series --notNull --sizeMax 64
        field string --fieldName token --notNull --sizeMax 64
        field date --fieldName last_used --type java.util.Calendar --persistenceType JPA_TIMESTAMP --notNull 
        finder add --finderName findPersistent_loginsesByUsernameLike --class *
        And then added the constraints manually using the sql maven plugin with

        				<!-- specify the dependent jdbc driver here -->
        				<!-- common configuration shared by all executions -->
        And this run every time I make "mvn test" so my initial data is inserted, you can add here the sql constraints and indexes there.
        -Be careful with ""
        -Take into accout that "remembeme" is not working with spring-security-3.0.1.RELEASE right now.


        • #5
          I want to know of using PostgreSQL with this entities...