Source Code Cross Referenced for LoginModule.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 java.util.Map;
020:
021:        import javax.management.InstanceNotFoundException;
022:        import javax.management.MBeanException;
023:        import javax.management.MBeanServer;
024:        import javax.management.MBeanServerFactory;
025:        import javax.management.MalformedObjectNameException;
026:        import javax.management.ObjectName;
027:        import javax.management.ReflectionException;
028:        import javax.security.auth.Subject;
029:        import javax.security.auth.callback.CallbackHandler;
030:        import javax.security.auth.login.LoginException;
031:
032:        import org.apache.jetspeed.security.UserManager;
033:        import org.apache.jetspeed.security.impl.ext.JBossLoginModule;
034:
035:        /**
036:         * A login module that uses the JetspeedSecurityService MBean for authentication and role assignment.
037:         */
038:        public class LoginModule implements  javax.security.auth.spi.LoginModule {
039:
040:            private String securityService = null;
041:
042:            private JBossLoginModule delegee = null;
043:
044:            /**
045:             * Helper for delaying the creation of the JBossLoginModule. We cannot access the security service MBean before
046:             * <code>initialize</code> has been called, but need the user manager in the constructor of JBossLoginModule. The
047:             * constructor that takes the user manager as argument is protected (and right so), so we need this helper.
048:             */
049:            private class LoginModuleDelegee extends JBossLoginModule {
050:                public LoginModuleDelegee(UserManager userManager) {
051:                    super (userManager);
052:                }
053:            }
054:
055:            /**
056:             * Create a new login module. The module looks up the JetspeedSecurityService MBean and uses it to actually perform
057:             * authentication and role lookup.
058:             * <P>
059:             * Note that the MBean must be available when this login module is instantiated. Therefore, if the MBean (the SAR)
060:             * is deployed after JBoss has been started, this login module must be created lazily by using the JBoss login
061:             * module proxy in login-config.xml.
062:             * 
063:             * <pre>
064:             *  &lt;application-policy name = &quot;sample&quot;&gt;
065:             *    &lt;authentication&gt;
066:             *      &lt;login-module code = &quot;org.jboss.security.auth.spi.ProxyLoginModule&quot;
067:             *        flag = &quot;required&quot;&gt;
068:             *        &lt;module-option name = &quot;moduleName&quot;&gt;
069:             *          org.apache.jetspeed.appservers.security.jboss.LoginModule
070:             *        &lt;/module-option&gt;
071:             *        &lt;!-- The name of the security service MBean. Must match
072:             *             the name in jboss-service.xml --&gt;
073:             *        &lt;module-option name = &quot;securityService&quot;&gt;
074:             *          org.apache.jetspeed:service=JetspeedSecurityService         
075:             *        &lt;/module-option&gt;
076:             *      &lt;/login-module&gt;
077:             *    &lt;/authentication&gt;
078:             *  &lt;/application-policy&gt;
079:             * </pre>
080:             */
081:            public LoginModule() {
082:            }
083:
084:            private UserManager getUserManager() {
085:                try {
086:                    MBeanServer server = (MBeanServer) MBeanServerFactory
087:                            .findMBeanServer(null).get(0);
088:                    ObjectName serviceName = new ObjectName(securityService);
089:                    return (UserManager) server.invoke(serviceName,
090:                            "getUserManager", null, null);
091:                } catch (MalformedObjectNameException e) {
092:                    throw (IllegalStateException) ((new IllegalStateException(e
093:                            .getMessage())).initCause(e));
094:                } catch (InstanceNotFoundException e) {
095:                    throw (IllegalStateException) ((new IllegalStateException(e
096:                            .getMessage())).initCause(e));
097:                } catch (ReflectionException e) {
098:                    throw (IllegalStateException) ((new IllegalStateException(e
099:                            .getMessage())).initCause(e));
100:                } catch (MBeanException e) {
101:                    throw (IllegalStateException) ((new IllegalStateException(e
102:                            .getMessage())).initCause(e));
103:                }
104:            }
105:
106:            /**
107:             * @see javax.security.auth.spi.LoginModule#initialize()
108:             */
109:            public void initialize(Subject subject,
110:                    CallbackHandler callbackHandler, Map sharedState,
111:                    Map options) {
112:                securityService = (String) options.get("securityService");
113:                delegee = new LoginModuleDelegee(getUserManager());
114:                delegee.initialize(subject, callbackHandler, sharedState,
115:                        options);
116:
117:            }
118:
119:            /** 
120:             * @see javax.security.auth.spi.LoginModule#abort()
121:             */
122:            public boolean abort() throws LoginException {
123:                return delegee.abort();
124:            }
125:
126:            /** 
127:             * @see javax.security.auth.spi.LoginModule#commit()
128:             */
129:            public boolean commit() throws LoginException {
130:                return delegee.commit();
131:            }
132:
133:            /** 
134:             * @see javax.security.auth.spi.LoginModule#login()
135:             */
136:            public boolean login() throws LoginException {
137:                return delegee.login();
138:            }
139:
140:            /** 
141:             * @see javax.security.auth.spi.LoginModule#logout()
142:             */
143:            public boolean logout() throws LoginException {
144:                return delegee.logout();
145:            }
146:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.