Source Code Cross Referenced for PopulatedDatabase.java in  » Security » acegi-security » org » acegisecurity » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Security » acegi security » org.acegisecurity 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
002:         *
003:         * Licensed under the Apache License, Version 2.0 (the "License");
004:         * you may not use this file except in compliance with the License.
005:         * You may obtain a copy of the License at
006:         *
007:         *     http://www.apache.org/licenses/LICENSE-2.0
008:         *
009:         * Unless required by applicable law or agreed to in writing, software
010:         * distributed under the License is distributed on an "AS IS" BASIS,
011:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012:         * See the License for the specific language governing permissions and
013:         * limitations under the License.
014:         */
015:
016:        package org.acegisecurity;
017:
018:        import org.springframework.jdbc.core.JdbcTemplate;
019:        import org.springframework.jdbc.datasource.DriverManagerDataSource;
020:
021:        import javax.sql.DataSource;
022:
023:        /**
024:         * Singleton which provides a populated database connection for all JDBC-related unit tests.
025:         *
026:         * @author Ben Alex
027:         * @version $Id: PopulatedDatabase.java 1496 2006-05-23 13:38:33Z benalex $
028:         */
029:        public class PopulatedDatabase {
030:            //~ Static fields/initializers =====================================================================================
031:
032:            private static DriverManagerDataSource dataSource = null;
033:
034:            //~ Constructors ===================================================================================================
035:
036:            private PopulatedDatabase() {
037:            }
038:
039:            //~ Methods ========================================================================================================
040:
041:            public static DataSource getDataSource() {
042:                if (dataSource == null) {
043:                    setupDataSource();
044:                }
045:
046:                return dataSource;
047:            }
048:
049:            private static void setupDataSource() {
050:                dataSource = new DriverManagerDataSource();
051:                dataSource.setDriverClassName("org.hsqldb.jdbcDriver");
052:                dataSource.setUrl("jdbc:hsqldb:mem:acegisecuritytest");
053:                dataSource.setUsername("sa");
054:                dataSource.setPassword("");
055:
056:                JdbcTemplate template = new JdbcTemplate(dataSource);
057:
058:                template
059:                        .execute("CREATE TABLE USERS(USERNAME VARCHAR_IGNORECASE(50) NOT NULL PRIMARY KEY,PASSWORD VARCHAR_IGNORECASE(50) NOT NULL,ENABLED BOOLEAN NOT NULL)");
060:                template
061:                        .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))");
062:                template
063:                        .execute("CREATE UNIQUE INDEX IX_AUTH_USERNAME ON AUTHORITIES(USERNAME,AUTHORITY)");
064:                template
065:                        .execute("CREATE TABLE ACL_OBJECT_IDENTITY(ID BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 0)  NOT NULL PRIMARY KEY,OBJECT_IDENTITY VARCHAR_IGNORECASE(250) NOT NULL,PARENT_OBJECT BIGINT,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))");
066:                template
067:                        .execute("CREATE TABLE ACL_PERMISSION(ID BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 0)  NOT NULL PRIMARY KEY,ACL_OBJECT_IDENTITY BIGINT 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))");
068:                template.execute("SET IGNORECASE TRUE");
069:                template
070:                        .execute("INSERT INTO USERS VALUES('dianne','emu',TRUE)");
071:                template
072:                        .execute("INSERT INTO USERS VALUES('marissa','koala',TRUE)");
073:                template
074:                        .execute("INSERT INTO USERS VALUES('peter','opal',FALSE)");
075:                template
076:                        .execute("INSERT INTO USERS VALUES('scott','wombat',TRUE)");
077:                template
078:                        .execute("INSERT INTO USERS VALUES('cooper','kookaburra',TRUE)");
079:                template
080:                        .execute("INSERT INTO AUTHORITIES VALUES('marissa','ROLE_TELLER')");
081:                template
082:                        .execute("INSERT INTO AUTHORITIES VALUES('marissa','ROLE_SUPERVISOR')");
083:                template
084:                        .execute("INSERT INTO AUTHORITIES VALUES('dianne','ROLE_TELLER')");
085:                template
086:                        .execute("INSERT INTO AUTHORITIES VALUES('scott','ROLE_TELLER')");
087:                template
088:                        .execute("INSERT INTO AUTHORITIES VALUES('peter','ROLE_TELLER')");
089:                template
090:                        .execute("INSERT INTO acl_object_identity VALUES (1, 'org.acegisecurity.acl.DomainObject:1', null, 'org.acegisecurity.acl.basic.SimpleAclEntry');");
091:                template
092:                        .execute("INSERT INTO acl_object_identity VALUES (2, 'org.acegisecurity.acl.DomainObject:2', 1, 'org.acegisecurity.acl.basic.SimpleAclEntry');");
093:                template
094:                        .execute("INSERT INTO acl_object_identity VALUES (3, 'org.acegisecurity.acl.DomainObject:3', 1, 'org.acegisecurity.acl.basic.SimpleAclEntry');");
095:                template
096:                        .execute("INSERT INTO acl_object_identity VALUES (4, 'org.acegisecurity.acl.DomainObject:4', 1, 'org.acegisecurity.acl.basic.SimpleAclEntry');");
097:                template
098:                        .execute("INSERT INTO acl_object_identity VALUES (5, 'org.acegisecurity.acl.DomainObject:5', 3, 'org.acegisecurity.acl.basic.SimpleAclEntry');");
099:                template
100:                        .execute("INSERT INTO acl_object_identity VALUES (6, 'org.acegisecurity.acl.DomainObject:6', 3, 'org.acegisecurity.acl.basic.SimpleAclEntry');");
101:
102:                // ----- BEGIN deviation from normal sample data load script -----
103:                template
104:                        .execute("INSERT INTO acl_object_identity VALUES (7, 'org.acegisecurity.acl.DomainObject:7', 3, 'some.invalid.acl.entry.class');");
105:
106:                // ----- FINISH deviation from normal sample data load script -----
107:                template
108:                        .execute("INSERT INTO acl_permission VALUES (null, 1, 'ROLE_SUPERVISOR', 1);");
109:                template
110:                        .execute("INSERT INTO acl_permission VALUES (null, 2, 'ROLE_SUPERVISOR', 0);");
111:                template
112:                        .execute("INSERT INTO acl_permission VALUES (null, 2, 'marissa', 2);");
113:                template
114:                        .execute("INSERT INTO acl_permission VALUES (null, 3, 'scott', 14);");
115:                template
116:                        .execute("INSERT INTO acl_permission VALUES (null, 6, 'scott', 1);");
117:            }
118:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.