Source Code Cross Referenced for JetspeedSecurityService.java in  » Portal » jetspeed-2.1.3 » org » apache » jetspeed » appservers » security » jboss » 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 » Portal » jetspeed 2.1.3 » org.apache.jetspeed.appservers.security.jboss 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* 
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.apache.jetspeed.appservers.security.jboss;
018:
019:        import javax.naming.Context;
020:        import javax.naming.InitialContext;
021:        import javax.naming.NamingException;
022:        import javax.sql.DataSource;
023:
024:        import org.apache.jetspeed.security.UserManager;
025:        import org.apache.ojb.broker.PBKey;
026:        import org.apache.ojb.broker.accesslayer.ConnectionFactoryManagedImpl;
027:        import org.apache.ojb.broker.metadata.ConnectionPoolDescriptor;
028:        import org.apache.ojb.broker.metadata.ConnectionRepository;
029:        import org.apache.ojb.broker.metadata.JdbcConnectionDescriptor;
030:        import org.apache.ojb.broker.metadata.JdbcMetadataUtils;
031:        import org.apache.ojb.broker.metadata.MetadataManager;
032:        import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
033:        import org.springframework.context.support.GenericApplicationContext;
034:        import org.springframework.core.io.ClassPathResource;
035:
036:        public class JetspeedSecurityService implements 
037:                JetspeedSecurityServiceMBean {
038:
039:            private final String JCD_ALIAS = "JetspeedSecurityServiceDS";
040:
041:            private GenericApplicationContext ctx;
042:
043:            /**
044:             * Create a new security service. The service's implementation is based on a <a
045:             * href="www.springframework.org">Spring</a> application that is assembled from the configuration files in
046:             * <code>META-INF/jboss-secsvc</code>.
047:             */
048:            public JetspeedSecurityService() {
049:                // Prepare JCD so that it can be resolved
050:                JdbcConnectionDescriptor jcd = findJcd();
051:                if (jcd == null) {
052:                    // JCD not found, initialize
053:                    jcd = new JdbcConnectionDescriptor();
054:                    jcd.setJcdAlias(JCD_ALIAS);
055:                    ConnectionPoolDescriptor cpd = new ConnectionPoolDescriptor();
056:                    cpd
057:                            .setConnectionFactory(ConnectionFactoryManagedImpl.class);
058:                    jcd.setConnectionPoolDescriptor(cpd);
059:                    ConnectionRepository cr = MetadataManager.getInstance()
060:                            .connectionRepository();
061:                    cr.addDescriptor(jcd);
062:                }
063:                // Instatiating application
064:                ctx = new GenericApplicationContext();
065:                XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(
066:                        ctx);
067:                xmlReader.loadBeanDefinitions(new ClassPathResource(
068:                        "META-INF/jboss-secsvc/jboss-security-service.xml"));
069:                ctx.refresh();
070:            }
071:
072:            private JdbcConnectionDescriptor findJcd() {
073:                // Try to find JCD
074:                ConnectionRepository cr = MetadataManager.getInstance()
075:                        .connectionRepository();
076:                return cr.getDescriptor(new PBKey(JCD_ALIAS));
077:            }
078:
079:            /**
080:             * Set the JNDI name of the <code>DataSource</code> to be used to access the database.
081:             * 
082:             * @param jndiName
083:             */
084:            public void setDataSourceJndiName(String jndiName) {
085:                JdbcConnectionDescriptor jcd = findJcd();
086:                try {
087:                    Context initialContext = new InitialContext();
088:                    DataSource ds = (DataSource) initialContext
089:                            .lookup(jndiName);
090:                    (new JdbcMetadataUtils()).fillJCDFromDataSource(jcd, ds,
091:                            null, null);
092:                } catch (NamingException e) {
093:                    throw (IllegalArgumentException) (new IllegalArgumentException(
094:                            "Data source \"" + jndiName
095:                                    + "\" not found in JNDI: " + e.getMessage()))
096:                            .initCause(e);
097:                }
098:                jcd.setDatasourceName(jndiName);
099:            }
100:
101:            /**
102:             * Get the JNDI name of the <code>DataSource</code> used to access the database.
103:             * 
104:             * @return jndiName
105:             */
106:            public String getDataSourceJndiName() {
107:                JdbcConnectionDescriptor jcd = findJcd();
108:                if (jcd == null) {
109:                    return null;
110:                }
111:                return jcd.getDatasourceName();
112:            }
113:
114:            /**
115:             * @see JetspeedSecurityServiceMBean#getUserManager()
116:             */
117:            public UserManager getUserManager() {
118:                UserManager um = (UserManager) ctx
119:                        .getBean("org.apache.jetspeed.security.UserManager");
120:                return um;
121:            }
122:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.