dbinit.txt 4.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. --- $Id$
  2. --- Sample Hypersonic SQL compatible schema and data
  3. ---
  4. --- All Acegi Security JDBC DAOs can be customised to use a different schema.
  5. --- In addition, the Acegi Security JDBC DAOs do not even need to be used
  6. --- with Acegi Security, and an entirely customised persistence strategy
  7. --- can be employed via standard interfaces (eg in-memory, Hibernate etc).
  8. SET IGNORECASE TRUE;
  9. CREATE TABLE users (
  10. username VARCHAR(50) NOT NULL PRIMARY KEY,
  11. password VARCHAR(50) NOT NULL,
  12. enabled BIT NOT NULL
  13. );
  14. CREATE TABLE authorities (
  15. username VARCHAR(50) NOT NULL,
  16. authority VARCHAR(50) NOT NULL
  17. );
  18. CREATE UNIQUE INDEX ix_auth_username ON authorities ( username, authority );
  19. ALTER TABLE authorities ADD CONSTRAINT fk_authorities_users foreign key (username) REFERENCES users(username);
  20. INSERT INTO users VALUES ('marissa', 'koala', true);
  21. INSERT INTO users VALUES ('dianne', 'emu', true);
  22. INSERT INTO users VALUES ('scott', 'wombat', true);
  23. INSERT INTO users VALUES ('peter', 'opal', false);
  24. INSERT INTO authorities VALUES ('marissa', 'ROLE_TELLER');
  25. INSERT INTO authorities VALUES ('marissa', 'ROLE_SUPERVISOR');
  26. INSERT INTO authorities VALUES ('dianne', 'ROLE_TELLER');
  27. INSERT INTO authorities VALUES ('scott', 'ROLE_TELLER');
  28. INSERT INTO authorities VALUES ('peter', 'ROLE_TELLER');
  29. --- Indexes auto created in HSQLDB for primary keys and unique columns
  30. CREATE TABLE acl_object_identity (
  31. id BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 0) NOT NULL PRIMARY KEY,
  32. object_identity VARCHAR_IGNORECASE(250) NOT NULL,
  33. parent_object BIGINT,
  34. acl_class VARCHAR_IGNORECASE(250) NOT NULL,
  35. CONSTRAINT unique_object_identity UNIQUE(object_identity),
  36. FOREIGN KEY (parent_object) REFERENCES acl_object_identity(id)
  37. );
  38. CREATE TABLE acl_permission (
  39. id BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 0) NOT NULL PRIMARY KEY,
  40. acl_object_identity BIGINT NOT NULL,
  41. recipient VARCHAR_IGNORECASE(100) NOT NULL,
  42. mask INTEGER NOT NULL,
  43. CONSTRAINT unique_recipient UNIQUE(acl_object_identity, recipient),
  44. FOREIGN KEY (acl_object_identity) REFERENCES acl_object_identity(id)
  45. );
  46. --- Mask integer 0 = no permissions
  47. --- Mask integer 1 = administer
  48. --- Mask integer 2 = read
  49. --- Mask integer 6 = read and write permissions
  50. --- Mask integer 14 = read and write and create permissions
  51. ---------------------------------------------------------------------
  52. --- *** INHERITED RIGHTS FOR DIFFERENT INSTANCES AND RECIPIENTS ***
  53. --- INSTANCE RECIPIENT PERMISSION(S) (COMMENT #INSTANCE)
  54. ---------------------------------------------------------------------
  55. --- 1 ROLE_SUPERVISOR Administer
  56. --- 2 ROLE_SUPERVISOR None (overrides parent #1)
  57. --- marissa Read
  58. --- 3 ROLE_SUPERVISOR Administer (from parent #1)
  59. --- scott Read, Write, Create
  60. --- 4 ROLE_SUPERVISOR Administer (from parent #1)
  61. --- 5 ROLE_SUPERVISOR Administer (from parent #3)
  62. --- scott Read, Write, Create (from parent #3)
  63. --- 6 ROLE_SUPERVISOR Administer (from parent #3)
  64. --- scott Administer (overrides parent #3)
  65. ---------------------------------------------------------------------
  66. INSERT INTO acl_object_identity VALUES (1, 'org.acegisecurity.acl.DomainObject:1', null, 'org.acegisecurity.acl.basic.SimpleAclEntry');
  67. INSERT INTO acl_object_identity VALUES (2, 'org.acegisecurity.acl.DomainObject:2', 1, 'org.acegisecurity.acl.basic.SimpleAclEntry');
  68. INSERT INTO acl_object_identity VALUES (3, 'org.acegisecurity.acl.DomainObject:3', 1, 'org.acegisecurity.acl.basic.SimpleAclEntry');
  69. INSERT INTO acl_object_identity VALUES (4, 'org.acegisecurity.acl.DomainObject:4', 1, 'org.acegisecurity.acl.basic.SimpleAclEntry');
  70. INSERT INTO acl_object_identity VALUES (5, 'org.acegisecurity.acl.DomainObject:5', 3, 'org.acegisecurity.acl.basic.SimpleAclEntry');
  71. INSERT INTO acl_object_identity VALUES (6, 'org.acegisecurity.acl.DomainObject:6', 3, 'org.acegisecurity.acl.basic.SimpleAclEntry');
  72. INSERT INTO acl_permission VALUES (null, 1, 'ROLE_SUPERVISOR', 1);
  73. INSERT INTO acl_permission VALUES (null, 2, 'ROLE_SUPERVISOR', 0);
  74. INSERT INTO acl_permission VALUES (null, 2, 'marissa', 2);
  75. INSERT INTO acl_permission VALUES (null, 3, 'scott', 14);
  76. INSERT INTO acl_permission VALUES (null, 6, 'scott', 1);