Source Code Cross Referenced for LoginConfigBuilderTest.java in  » EJB-Server-geronimo » plugins » org » apache » geronimo » security » deployment » 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 » EJB Server geronimo » plugins » org.apache.geronimo.security.deployment 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one
003:         * or more contributor license agreements.  See the NOTICE file
004:         * distributed with this work for additional information
005:         * regarding copyright ownership.  The ASF licenses this file
006:         * to you under the Apache License, Version 2.0 (the
007:         * "License"); you may not use this file except in compliance
008:         * with the License.  You may obtain a copy of the License at
009:         *
010:         *  http://www.apache.org/licenses/LICENSE-2.0
011:         *
012:         * Unless required by applicable law or agreed to in writing,
013:         * software distributed under the License is distributed on an
014:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015:         * KIND, either express or implied.  See the License for the
016:         * specific language governing permissions and limitations
017:         * under the License.
018:         */
019:
020:        package org.apache.geronimo.security.deployment;
021:
022:        import java.io.File;
023:        import java.net.URI;
024:        import java.util.Collections;
025:
026:        import junit.framework.TestCase;
027:        import org.apache.geronimo.common.DeploymentException;
028:        import org.apache.geronimo.deployment.DeploymentContext;
029:        import org.apache.geronimo.deployment.xmlbeans.XmlBeansUtil;
030:        import org.apache.geronimo.gbean.AbstractName;
031:        import org.apache.geronimo.kernel.Jsr77Naming;
032:        import org.apache.geronimo.kernel.config.ConfigurationModuleType;
033:        import org.apache.geronimo.kernel.mock.MockConfigurationManager;
034:        import org.apache.geronimo.kernel.repository.Artifact;
035:        import org.apache.geronimo.kernel.repository.Environment;
036:        import org.apache.xmlbeans.XmlCursor;
037:        import org.apache.xmlbeans.XmlException;
038:        import org.apache.xmlbeans.XmlObject;
039:
040:        /**
041:         * @version $Rev: 620870 $ $Date: 2008-02-12 09:24:48 -0800 (Tue, 12 Feb 2008) $
042:         */
043:        public class LoginConfigBuilderTest extends TestCase {
044:            //2.0 namespace, with server-side
045:            private static final String SAMPLE1 = "            <lc:login-config xmlns:lc=\"http://geronimo.apache.org/xml/ns/loginconfig-2.0\">\n"
046:                    + "                <lc:login-module control-flag=\"REQUIRED\" server-side=\"true\" wrap-principals=\"true\">\n"
047:                    + "                    <lc:login-domain-name>client-properties-realm</lc:login-domain-name>\n"
048:                    + "                    <lc:login-module-class>org.apache.geronimo.security.realm.providers.PropertiesFileLoginModule</lc:login-module-class>\n"
049:                    + "                    <lc:option name=\"usersURI\">var/security/users.properties</lc:option>\n"
050:                    + "                    <lc:option name=\"groupsURI\">var/security/groups.properties</lc:option>\n"
051:                    + "                </lc:login-module>\n"
052:                    + "                <lc:login-module control-flag=\"REQUIRED\" server-side=\"true\" wrap-principals=\"true\">\n"
053:                    + "                    <lc:login-domain-name>default</lc:login-domain-name>\n"
054:                    + "                    <lc:login-module-class>org.apache.geronimo.security.realm.providers.NamedUsernamePasswordCredentialLoginModule</lc:login-module-class>\n"
055:                    + "                    <lc:option name=\"org.apache.geronimo.jaas.NamedUsernamePasswordCredential.Name\">default</lc:option>\n"
056:                    + "                </lc:login-module>\n"
057:                    + "            </lc:login-config>";
058:            //1.2 namespace, with server-side
059:            private static final String SAMPLE2 = "            <lc:login-config xmlns:lc=\"http://geronimo.apache.org/xml/ns/loginconfig-1.2\">\n"
060:                    + "                <lc:login-module control-flag=\"REQUIRED\" server-side=\"true\" wrap-principals=\"true\">\n"
061:                    + "                    <lc:login-domain-name>client-properties-realm</lc:login-domain-name>\n"
062:                    + "                    <lc:login-module-class>org.apache.geronimo.security.realm.providers.PropertiesFileLoginModule</lc:login-module-class>\n"
063:                    + "                    <lc:option name=\"usersURI\">var/security/users.properties</lc:option>\n"
064:                    + "                    <lc:option name=\"groupsURI\">var/security/groups.properties</lc:option>\n"
065:                    + "                </lc:login-module>\n"
066:                    + "                <lc:login-module control-flag=\"REQUIRED\" server-side=\"true\" wrap-principals=\"true\">\n"
067:                    + "                    <lc:login-domain-name>default</lc:login-domain-name>\n"
068:                    + "                    <lc:login-module-class>org.apache.geronimo.security.realm.providers.NamedUsernamePasswordCredentialLoginModule</lc:login-module-class>\n"
069:                    + "                    <lc:option name=\"org.apache.geronimo.jaas.NamedUsernamePasswordCredential.Name\">default</lc:option>\n"
070:                    + "                </lc:login-module>\n"
071:                    + "            </lc:login-config>";
072:            //2.0 namespace, without server-side
073:            private static final String SAMPLE3 = "            <lc:login-config xmlns:lc=\"http://geronimo.apache.org/xml/ns/loginconfig-2.0\">\n"
074:                    + "                <lc:login-module control-flag=\"REQUIRED\" wrap-principals=\"true\">\n"
075:                    + "                    <lc:login-domain-name>client-properties-realm</lc:login-domain-name>\n"
076:                    + "                    <lc:login-module-class>org.apache.geronimo.security.realm.providers.PropertiesFileLoginModule</lc:login-module-class>\n"
077:                    + "                    <lc:option name=\"usersURI\">var/security/users.properties</lc:option>\n"
078:                    + "                    <lc:option name=\"groupsURI\">var/security/groups.properties</lc:option>\n"
079:                    + "                </lc:login-module>\n"
080:                    + "                <lc:login-module control-flag=\"REQUIRED\" wrap-principals=\"true\">\n"
081:                    + "                    <lc:login-domain-name>default</lc:login-domain-name>\n"
082:                    + "                    <lc:login-module-class>org.apache.geronimo.security.realm.providers.NamedUsernamePasswordCredentialLoginModule</lc:login-module-class>\n"
083:                    + "                    <lc:option name=\"org.apache.geronimo.jaas.NamedUsernamePasswordCredential.Name\">default</lc:option>\n"
084:                    + "                </lc:login-module>\n"
085:                    + "            </lc:login-config>";
086:            //2.0 namespace, without server-side, with login-module-ref
087:            private static final String SAMPLE4 = "            <lc:login-config xmlns:lc=\"http://geronimo.apache.org/xml/ns/loginconfig-2.0\">\n"
088:                    + "                <lc:login-module-ref control-flag=\"REQUIRED\" wrap-principals=\"true\">\n"
089:                    + "                    <lc:pattern><name xmlns='http://geronimo.apache.org/xml/ns/deployment-1.2'>client-properties-lm</name></lc:pattern>\n"
090:                    + "                </lc:login-module-ref>\n"
091:                    + "                <lc:login-module control-flag=\"REQUIRED\" wrap-principals=\"true\">\n"
092:                    + "                    <lc:login-domain-name>default</lc:login-domain-name>\n"
093:                    + "                    <lc:login-module-class>org.apache.geronimo.security.realm.providers.NamedUsernamePasswordCredentialLoginModule</lc:login-module-class>\n"
094:                    + "                    <lc:option name=\"org.apache.geronimo.jaas.NamedUsernamePasswordCredential.Name\">default</lc:option>\n"
095:                    + "                </lc:login-module>\n"
096:                    + "            </lc:login-config>";
097:
098:            public void test1() throws Exception {
099:                doTest(SAMPLE1);
100:            }
101:
102:            public void test2() throws Exception {
103:                doTest(SAMPLE2);
104:            }
105:
106:            public void test3() throws Exception {
107:                doTest(SAMPLE3);
108:            }
109:
110:            public void test() throws Exception {
111:                doTest(SAMPLE4);
112:            }
113:
114:            private void doTest(String text) throws XmlException,
115:                    DeploymentException {
116:                GeronimoSecurityBuilderImpl secBuilder = new GeronimoSecurityBuilderImpl(
117:                        null);
118:                secBuilder.doStart();
119:                LoginConfigBuilder builder = new LoginConfigBuilder(
120:                        new Jsr77Naming(), null);
121:                XmlObject xmlObject = XmlBeansUtil.parse(text);
122:                XmlCursor cursor = xmlObject.newCursor();
123:                cursor.toFirstContentToken();
124:                xmlObject = cursor.getObject();
125:                DeploymentContext context = new DeploymentContext(
126:                        new File("."), null, new Environment(Artifact
127:                                .create("test/foo/1.0/car")), null,
128:                        ConfigurationModuleType.SERVICE, new Jsr77Naming(),
129:                        new MockConfigurationManager(), Collections.emptySet());
130:                AbstractName parentName = new AbstractName(URI
131:                        .create("test/foo/1.0/car?name=parent,j2eeType=foo"));
132:                builder.getReferences(xmlObject, context, parentName,
133:                        getClass().getClassLoader());
134:                secBuilder.doStop();
135:            }
136:
137:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.