|
@@ -18,6 +18,7 @@ package sample.contact;
|
|
|
import org.springframework.beans.factory.InitializingBean;
|
|
|
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
+import org.springframework.util.Assert;
|
|
|
|
|
|
import javax.sql.DataSource;
|
|
|
|
|
@@ -44,86 +45,47 @@ public class DataSourcePopulator implements InitializingBean {
|
|
|
}
|
|
|
|
|
|
public void afterPropertiesSet() throws Exception {
|
|
|
- if (dataSource == null) {
|
|
|
- throw new IllegalArgumentException("dataSource required");
|
|
|
- }
|
|
|
+ Assert.notNull(dataSource, "dataSource required");
|
|
|
|
|
|
JdbcTemplate template = new JdbcTemplate(dataSource);
|
|
|
|
|
|
- template.execute(
|
|
|
- "CREATE TABLE CONTACTS(ID INTEGER NOT NULL PRIMARY KEY, CONTACT_NAME VARCHAR_IGNORECASE(50) NOT NULL, EMAIL VARCHAR_IGNORECASE(50) NOT NULL)");
|
|
|
- template.execute(
|
|
|
- "INSERT INTO contacts VALUES (1, 'John Smith', 'john@somewhere.com');"); // marissa
|
|
|
- template.execute(
|
|
|
- "INSERT INTO contacts VALUES (2, 'Michael Citizen', 'michael@xyz.com');"); // marissa
|
|
|
- template.execute(
|
|
|
- "INSERT INTO contacts VALUES (3, 'Joe Bloggs', 'joe@demo.com');"); // marissa
|
|
|
- template.execute(
|
|
|
- "INSERT INTO contacts VALUES (4, 'Karen Sutherland', 'karen@sutherland.com');"); // marissa + dianne + scott
|
|
|
- template.execute(
|
|
|
- "INSERT INTO contacts VALUES (5, 'Mitchell Howard', 'mitchell@abcdef.com');"); // dianne
|
|
|
- template.execute(
|
|
|
- "INSERT INTO contacts VALUES (6, 'Rose Costas', 'rose@xyz.com');"); // dianne + scott
|
|
|
- template.execute(
|
|
|
- "INSERT INTO contacts VALUES (7, 'Amanda Smith', 'amanda@abcdef.com');"); // scott
|
|
|
- template.execute(
|
|
|
- "INSERT INTO contacts VALUES (8, 'Cindy Smith', 'cindy@smith.com');"); // dianne + scott
|
|
|
- template.execute(
|
|
|
- "INSERT INTO contacts VALUES (9, 'Jonathan Citizen', 'jonathan@xyz.com');"); // scott
|
|
|
- template.execute(
|
|
|
- "CREATE TABLE ACL_OBJECT_IDENTITY(ID INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 100) NOT NULL PRIMARY KEY,OBJECT_IDENTITY VARCHAR_IGNORECASE(250) NOT NULL,PARENT_OBJECT INTEGER,ACL_CLASS VARCHAR_IGNORECASE(250) NOT NULL,CONSTRAINT UNIQUE_OBJECT_IDENTITY UNIQUE(OBJECT_IDENTITY),CONSTRAINT SYS_FK_3 FOREIGN KEY(PARENT_OBJECT) REFERENCES ACL_OBJECT_IDENTITY(ID))");
|
|
|
- template.execute(
|
|
|
- "INSERT INTO acl_object_identity VALUES (1, 'sample.contact.Contact:1', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');");
|
|
|
- template.execute(
|
|
|
- "INSERT INTO acl_object_identity VALUES (2, 'sample.contact.Contact:2', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');");
|
|
|
- template.execute(
|
|
|
- "INSERT INTO acl_object_identity VALUES (3, 'sample.contact.Contact:3', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');");
|
|
|
- template.execute(
|
|
|
- "INSERT INTO acl_object_identity VALUES (4, 'sample.contact.Contact:4', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');");
|
|
|
- template.execute(
|
|
|
- "INSERT INTO acl_object_identity VALUES (5, 'sample.contact.Contact:5', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');");
|
|
|
- template.execute(
|
|
|
- "INSERT INTO acl_object_identity VALUES (6, 'sample.contact.Contact:6', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');");
|
|
|
- template.execute(
|
|
|
- "INSERT INTO acl_object_identity VALUES (7, 'sample.contact.Contact:7', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');");
|
|
|
- template.execute(
|
|
|
- "INSERT INTO acl_object_identity VALUES (8, 'sample.contact.Contact:8', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');");
|
|
|
- template.execute(
|
|
|
- "INSERT INTO acl_object_identity VALUES (9, 'sample.contact.Contact:9', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');");
|
|
|
- template.execute(
|
|
|
- "CREATE TABLE ACL_PERMISSION(ID INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 100) NOT NULL PRIMARY KEY,ACL_OBJECT_IDENTITY INTEGER NOT NULL,RECIPIENT VARCHAR_IGNORECASE(100) NOT NULL,MASK INTEGER NOT NULL,CONSTRAINT UNIQUE_RECIPIENT UNIQUE(ACL_OBJECT_IDENTITY,RECIPIENT),CONSTRAINT SYS_FK_7 FOREIGN KEY(ACL_OBJECT_IDENTITY) REFERENCES ACL_OBJECT_IDENTITY(ID))");
|
|
|
- template.execute(
|
|
|
- "INSERT INTO acl_permission VALUES (null, 1, 'marissa', 1);"); // administer
|
|
|
- template.execute(
|
|
|
- "INSERT INTO acl_permission VALUES (null, 2, 'marissa', 2);"); // read
|
|
|
- template.execute(
|
|
|
- "INSERT INTO acl_permission VALUES (null, 3, 'marissa', 22);"); // read+write+delete
|
|
|
- template.execute(
|
|
|
- "INSERT INTO acl_permission VALUES (null, 4, 'marissa', 1);"); // administer
|
|
|
- template.execute(
|
|
|
- "INSERT INTO acl_permission VALUES (null, 4, 'dianne', 1);"); // administer
|
|
|
- template.execute(
|
|
|
- "INSERT INTO acl_permission VALUES (null, 4, 'scott', 2);"); // read
|
|
|
- template.execute(
|
|
|
- "INSERT INTO acl_permission VALUES (null, 5, 'dianne', 2);"); // read
|
|
|
- template.execute(
|
|
|
- "INSERT INTO acl_permission VALUES (null, 6, 'dianne', 22);"); // read+write+delete
|
|
|
- template.execute(
|
|
|
- "INSERT INTO acl_permission VALUES (null, 6, 'scott', 2);"); // read
|
|
|
- template.execute(
|
|
|
- "INSERT INTO acl_permission VALUES (null, 7, 'scott', 1);"); // administer
|
|
|
- template.execute(
|
|
|
- "INSERT INTO acl_permission VALUES (null, 8, 'dianne', 2);"); // read
|
|
|
- template.execute(
|
|
|
- "INSERT INTO acl_permission VALUES (null, 8, 'scott', 2);"); // read
|
|
|
- template.execute(
|
|
|
- "INSERT INTO acl_permission VALUES (null, 9, 'scott', 22);"); // read+write+delete
|
|
|
- template.execute(
|
|
|
- "CREATE TABLE USERS(USERNAME VARCHAR_IGNORECASE(50) NOT NULL PRIMARY KEY,PASSWORD VARCHAR_IGNORECASE(50) NOT NULL,ENABLED BOOLEAN NOT NULL);");
|
|
|
- template.execute(
|
|
|
- "CREATE TABLE AUTHORITIES(USERNAME VARCHAR_IGNORECASE(50) NOT NULL,AUTHORITY VARCHAR_IGNORECASE(50) NOT NULL,CONSTRAINT FK_AUTHORITIES_USERS FOREIGN KEY(USERNAME) REFERENCES USERS(USERNAME));");
|
|
|
- template.execute(
|
|
|
- "CREATE UNIQUE INDEX IX_AUTH_USERNAME ON AUTHORITIES(USERNAME,AUTHORITY);");
|
|
|
+ template.execute("CREATE TABLE CONTACTS(ID INTEGER NOT NULL PRIMARY KEY, CONTACT_NAME VARCHAR_IGNORECASE(50) NOT NULL, EMAIL VARCHAR_IGNORECASE(50) NOT NULL)");
|
|
|
+ template.execute("INSERT INTO contacts VALUES (1, 'John Smith', 'john@somewhere.com');"); // marissa
|
|
|
+ template.execute("INSERT INTO contacts VALUES (2, 'Michael Citizen', 'michael@xyz.com');"); // marissa
|
|
|
+ template.execute("INSERT INTO contacts VALUES (3, 'Joe Bloggs', 'joe@demo.com');"); // marissa
|
|
|
+ template.execute("INSERT INTO contacts VALUES (4, 'Karen Sutherland', 'karen@sutherland.com');"); // marissa + dianne + scott
|
|
|
+ template.execute("INSERT INTO contacts VALUES (5, 'Mitchell Howard', 'mitchell@abcdef.com');"); // dianne
|
|
|
+ template.execute("INSERT INTO contacts VALUES (6, 'Rose Costas', 'rose@xyz.com');"); // dianne + scott
|
|
|
+ template.execute("INSERT INTO contacts VALUES (7, 'Amanda Smith', 'amanda@abcdef.com');"); // scott
|
|
|
+ template.execute("INSERT INTO contacts VALUES (8, 'Cindy Smith', 'cindy@smith.com');"); // dianne + scott
|
|
|
+ template.execute("INSERT INTO contacts VALUES (9, 'Jonathan Citizen', 'jonathan@xyz.com');"); // scott
|
|
|
+ template.execute("CREATE TABLE ACL_OBJECT_IDENTITY(ID INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 100) NOT NULL PRIMARY KEY,OBJECT_IDENTITY VARCHAR_IGNORECASE(250) NOT NULL,PARENT_OBJECT INTEGER,ACL_CLASS VARCHAR_IGNORECASE(250) NOT NULL,CONSTRAINT UNIQUE_OBJECT_IDENTITY UNIQUE(OBJECT_IDENTITY),CONSTRAINT SYS_FK_3 FOREIGN KEY(PARENT_OBJECT) REFERENCES ACL_OBJECT_IDENTITY(ID))");
|
|
|
+ template.execute("INSERT INTO acl_object_identity VALUES (1, 'sample.contact.Contact:1', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');");
|
|
|
+ template.execute("INSERT INTO acl_object_identity VALUES (2, 'sample.contact.Contact:2', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');");
|
|
|
+ template.execute("INSERT INTO acl_object_identity VALUES (3, 'sample.contact.Contact:3', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');");
|
|
|
+ template.execute("INSERT INTO acl_object_identity VALUES (4, 'sample.contact.Contact:4', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');");
|
|
|
+ template.execute("INSERT INTO acl_object_identity VALUES (5, 'sample.contact.Contact:5', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');");
|
|
|
+ template.execute("INSERT INTO acl_object_identity VALUES (6, 'sample.contact.Contact:6', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');");
|
|
|
+ template.execute("INSERT INTO acl_object_identity VALUES (7, 'sample.contact.Contact:7', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');");
|
|
|
+ template.execute("INSERT INTO acl_object_identity VALUES (8, 'sample.contact.Contact:8', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');");
|
|
|
+ template.execute("INSERT INTO acl_object_identity VALUES (9, 'sample.contact.Contact:9', null, 'net.sf.acegisecurity.acl.basic.SimpleAclEntry');");
|
|
|
+ template.execute("CREATE TABLE ACL_PERMISSION(ID INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 100) NOT NULL PRIMARY KEY,ACL_OBJECT_IDENTITY INTEGER NOT NULL,RECIPIENT VARCHAR_IGNORECASE(100) NOT NULL,MASK INTEGER NOT NULL,CONSTRAINT UNIQUE_RECIPIENT UNIQUE(ACL_OBJECT_IDENTITY,RECIPIENT),CONSTRAINT SYS_FK_7 FOREIGN KEY(ACL_OBJECT_IDENTITY) REFERENCES ACL_OBJECT_IDENTITY(ID))");
|
|
|
+ template.execute("INSERT INTO acl_permission VALUES (null, 1, 'marissa', 1);"); // administer
|
|
|
+ template.execute("INSERT INTO acl_permission VALUES (null, 2, 'marissa', 2);"); // read
|
|
|
+ template.execute("INSERT INTO acl_permission VALUES (null, 3, 'marissa', 22);"); // read+write+delete
|
|
|
+ template.execute("INSERT INTO acl_permission VALUES (null, 4, 'marissa', 1);"); // administer
|
|
|
+ template.execute("INSERT INTO acl_permission VALUES (null, 4, 'dianne', 1);"); // administer
|
|
|
+ template.execute("INSERT INTO acl_permission VALUES (null, 4, 'scott', 2);"); // read
|
|
|
+ template.execute("INSERT INTO acl_permission VALUES (null, 5, 'dianne', 2);"); // read
|
|
|
+ template.execute("INSERT INTO acl_permission VALUES (null, 6, 'dianne', 22);"); // read+write+delete
|
|
|
+ template.execute("INSERT INTO acl_permission VALUES (null, 6, 'scott', 2);"); // read
|
|
|
+ template.execute("INSERT INTO acl_permission VALUES (null, 7, 'scott', 1);"); // administer
|
|
|
+ template.execute("INSERT INTO acl_permission VALUES (null, 8, 'dianne', 2);"); // read
|
|
|
+ template.execute("INSERT INTO acl_permission VALUES (null, 8, 'scott', 2);"); // read
|
|
|
+ template.execute("INSERT INTO acl_permission VALUES (null, 9, 'scott', 22);"); // read+write+delete
|
|
|
+ template.execute("CREATE TABLE USERS(USERNAME VARCHAR_IGNORECASE(50) NOT NULL PRIMARY KEY,PASSWORD VARCHAR_IGNORECASE(50) NOT NULL,ENABLED BOOLEAN NOT NULL);");
|
|
|
+ template.execute("CREATE TABLE AUTHORITIES(USERNAME VARCHAR_IGNORECASE(50) NOT NULL,AUTHORITY VARCHAR_IGNORECASE(50) NOT NULL,CONSTRAINT FK_AUTHORITIES_USERS FOREIGN KEY(USERNAME) REFERENCES USERS(USERNAME));");
|
|
|
+ template.execute("CREATE UNIQUE INDEX IX_AUTH_USERNAME ON AUTHORITIES(USERNAME,AUTHORITY);");
|
|
|
|
|
|
/*
|
|
|
Passwords encoded using MD5, NOT in Base64 format, with null as salt
|
|
@@ -133,20 +95,13 @@ public class DataSourcePopulator implements InitializingBean {
|
|
|
Encoded password for peter is "opal" (but user is disabled)
|
|
|
|
|
|
*/
|
|
|
- template.execute(
|
|
|
- "INSERT INTO USERS VALUES('marissa','a564de63c2d0da68cf47586ee05984d7',TRUE);");
|
|
|
- template.execute(
|
|
|
- "INSERT INTO USERS VALUES('dianne','65d15fe9156f9c4bbffd98085992a44e',TRUE);");
|
|
|
- template.execute(
|
|
|
- "INSERT INTO USERS VALUES('scott','2b58af6dddbd072ed27ffc86725d7d3a',TRUE);");
|
|
|
- template.execute(
|
|
|
- "INSERT INTO USERS VALUES('peter','22b5c9accc6e1ba628cedc63a72d57f8',FALSE);");
|
|
|
- template.execute(
|
|
|
- "INSERT INTO AUTHORITIES VALUES('marissa','ROLE_USER');");
|
|
|
- template.execute(
|
|
|
- "INSERT INTO AUTHORITIES VALUES('marissa','ROLE_SUPERVISOR');");
|
|
|
- template.execute(
|
|
|
- "INSERT INTO AUTHORITIES VALUES('dianne','ROLE_USER');");
|
|
|
+ template.execute("INSERT INTO USERS VALUES('marissa','a564de63c2d0da68cf47586ee05984d7',TRUE);");
|
|
|
+ template.execute("INSERT INTO USERS VALUES('dianne','65d15fe9156f9c4bbffd98085992a44e',TRUE);");
|
|
|
+ template.execute("INSERT INTO USERS VALUES('scott','2b58af6dddbd072ed27ffc86725d7d3a',TRUE);");
|
|
|
+ template.execute("INSERT INTO USERS VALUES('peter','22b5c9accc6e1ba628cedc63a72d57f8',FALSE);");
|
|
|
+ template.execute("INSERT INTO AUTHORITIES VALUES('marissa','ROLE_USER');");
|
|
|
+ template.execute("INSERT INTO AUTHORITIES VALUES('marissa','ROLE_SUPERVISOR');");
|
|
|
+ template.execute("INSERT INTO AUTHORITIES VALUES('dianne','ROLE_USER');");
|
|
|
template.execute("INSERT INTO AUTHORITIES VALUES('scott','ROLE_USER');");
|
|
|
template.execute("INSERT INTO AUTHORITIES VALUES('peter','ROLE_USER');");
|
|
|
}
|