Source Code Cross Referenced for JMXSSOEventManagerImpl.java in  » Authentication-Authorization » josso-1.7 » org » josso » gateway » event » security » 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 » Authentication Authorization » josso 1.7 » org.josso.gateway.event.security 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * JOSSO: Java Open Single Sign-On
003:         *
004:         * Copyright 2004-2008, Atricore, Inc.
005:         *
006:         * This is free software; you can redistribute it and/or modify it
007:         * under the terms of the GNU Lesser General Public License as
008:         * published by the Free Software Foundation; either version 2.1 of
009:         * the License, or (at your option) any later version.
010:         *
011:         * This software is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014:         * Lesser General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU Lesser General Public
017:         * License along with this software; if not, write to the Free
018:         * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
019:         * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
020:         */
021:        package org.josso.gateway.event.security;
022:
023:        import org.apache.commons.modeler.Registry;
024:        import org.apache.commons.logging.Log;
025:        import org.apache.commons.logging.LogFactory;
026:        import org.josso.gateway.event.SSOEvent;
027:        import org.josso.gateway.event.SSOEventListener;
028:
029:        import javax.management.MBeanServer;
030:        import javax.management.Notification;
031:        import javax.management.ObjectName;
032:        import java.util.ArrayList;
033:        import java.util.List;
034:
035:        /**
036:         * JMX Based event manager. This manager is a SSOSecurityEventManager and a MBean.
037:         * It uses JMX Notification scheme to deliver SSO Events.
038:         *
039:         * @author <a href="mailto:sgonzalez@josso.org">Sebastian Gonzalez Oyuela</a>
040:         * @version $Id: JMXSSOEventManagerImpl.java 508 2008-02-18 13:32:29Z sgonzalez $
041:         */
042:        public class JMXSSOEventManagerImpl extends SSOSecurityEventManagerImpl {
043:
044:            public static final Log logger = LogFactory
045:                    .getLog(JMXSSOEventManagerImpl.class);
046:
047:            // Event sequence number ...
048:            private static long sequnece;
049:
050:            // This is the MBean used to fire notifications and to attach listeners..
051:            private ObjectName mbeanOname;
052:            private String oname;
053:            private boolean initialized = false;
054:
055:            private List preRegistered;
056:
057:            /**
058:             * Common Modelere MBean registry
059:             */
060:            private Registry registry;
061:
062:            public JMXSSOEventManagerImpl() {
063:                super ();
064:                this .registry = Registry.getRegistry(null, null);
065:                this .preRegistered = new ArrayList();
066:            }
067:
068:            public void initialize() {
069:                super .initialize();
070:
071:                if (initialized)
072:                    return;
073:
074:                try {
075:
076:                    mbeanOname = new ObjectName(oname);
077:                    // this.registry.registerComponent(this, oname, null);
078:
079:                    if (logger.isDebugEnabled())
080:                        logger.debug("Using MBean for notifications : "
081:                                + mbeanOname);
082:
083:                    // Mark this manager as initialized.
084:                    initialized = true;
085:
086:                    for (int i = 0; i < preRegistered.size(); i++) {
087:                        SSOEventListener listener = (SSOEventListener) preRegistered
088:                                .get(i);
089:                        this .registerListener(listener);
090:                    }
091:                } catch (Exception e) {
092:                    logger.error("Can't create MBean Objectname : "
093:                            + e.getMessage(), e);
094:                }
095:            }
096:
097:            public void destroy() {
098:                super .destroy();
099:            }
100:
101:            /**
102:             * This method invokes the fireSSOEvent of the MBean registered under the "oname" name.
103:             * @param event
104:             */
105:            public void fireSSOEvent(SSOEvent event) {
106:                try {
107:                    // Invoke fireSSOEvent on MBean ...
108:                    MBeanServer server = getMBeanServer();
109:
110:                    // Build a JMX Notification based on the SSOEvent.
111:                    Notification notification = buildNotification(event);
112:
113:                    server.invoke(mbeanOname, "fireJMXSSOEvent",
114:                            new Object[] { notification },
115:                            new String[] { "javax.management.Notification" });
116:
117:                } catch (Exception e) {
118:                    logger.error("Can't send SSO Event : " + e.getMessage(), e);
119:                }
120:            }
121:
122:            /**
123:             * Registers a new event listener.
124:             * This implementation creates a NotificationSSOEventListener instance to wrapp the recieved listener.
125:             * It registers the NotificationSSOEventListener as a JMX listener of the configured MBean.
126:             */
127:            public void registerListener(SSOEventListener listener) {
128:
129:                // If this component has not been initialized, store the listener so we can register it on initialization.
130:                if (!initialized) {
131:                    preRegistered.add(listener);
132:                    return;
133:                }
134:
135:                try {
136:                    // TODO : Keep track of all listeners !?
137:                    logger.info("Adding listener : " + listener + " for : "
138:                            + mbeanOname);
139:                    getMBeanServer().addNotificationListener(mbeanOname,
140:                            new NotificationSSOEventListener(listener), null,
141:                            null);
142:
143:                } catch (Exception e) {
144:                    logger.error("Can't add listener : " + listener
145:                            + " to mbean : " + mbeanOname + "\n"
146:                            + e.getMessage(), e);
147:                }
148:            }
149:
150:            /**
151:             * Configuration parameter containing the MBean object name that this manager uses to send JMX notifications.
152:             */
153:            public String getOname() {
154:                return oname;
155:            }
156:
157:            /**
158:             * Configuration parameter containing the MBean object name that this manager uses to send JMX notifications.
159:             */
160:            public void setOname(String oname) {
161:                this .oname = oname;
162:            }
163:
164:            /**
165:             * Finds the propper MBeanServer instance.
166:             */
167:            protected MBeanServer getMBeanServer() {
168:                return registry.getMBeanServer();
169:            }
170:
171:            /**
172:             * This implementation builds a NotifiactionSSOEvent using received event information.
173:             */
174:            protected Notification buildNotification(SSOEvent event) {
175:                return new SSOEventNotification(event, sequnece++);
176:            }
177:
178:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.