01: /*
02: * JOSSO: Java Open Single Sign-On
03: *
04: * Copyright 2004-2008, Atricore, Inc.
05: *
06: * This is free software; you can redistribute it and/or modify it
07: * under the terms of the GNU Lesser General Public License as
08: * published by the Free Software Foundation; either version 2.1 of
09: * the License, or (at your option) any later version.
10: *
11: * This software is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: * You should have received a copy of the GNU Lesser General Public
17: * License along with this software; if not, write to the Free
18: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
20: */
21: package org.josso.gateway.event.security;
22:
23: import org.apache.commons.logging.Log;
24: import org.apache.commons.logging.LogFactory;
25: import org.josso.gateway.event.SSOEventListener;
26: import org.josso.util.mbeans.JOSSOBaseMBean;
27:
28: import javax.management.*;
29:
30: /**
31: * TODO : Add class description.
32: *
33: * @author <a href="mailto:sgonzalez@josso.org">Sebastian Gonzalez Oyuela</a>
34: * @version $Id: SSOEventManagerMBean.java 508 2008-02-18 13:32:29Z sgonzalez $
35: */
36: /**
37: * This class is
38: */
39: public class SSOEventManagerMBean extends JOSSOBaseMBean {
40:
41: private static final Log logger = LogFactory
42: .getLog(SSOEventManagerMBean.class);
43:
44: public SSOEventManagerMBean() throws MBeanException,
45: RuntimeOperationsException {
46: super ();
47: }
48:
49: public void addNotificationListener(SSOEventListener listener)
50: throws InstanceNotFoundException {
51:
52: MBeanServer server = this .registry.getMBeanServer();
53:
54: // Wrapp received listener with JMX listener.
55: // This hardly works ... because in different versions of common-modeler, oname is a String or a ObjectName instance !!!
56: server.addNotificationListener(oname,
57: new NotificationSSOEventListener(listener), null, null);
58: }
59:
60: public String getOName() {
61: // This hardly works ... because in different versions of common-modeler, oname is a String or a ObjectName instance !!!
62: return oname + "";
63: }
64:
65: /**
66: * This method will be invoked by the outer class when sending SSO Events.
67: * @param event
68: */
69: public void fireJMXSSOEvent(Notification event) {
70: try {
71:
72: sendNotification(event);
73:
74: if (logger.isDebugEnabled())
75: logger.debug("Sent notification : " + event);
76: } catch (MBeanException e) {
77: logger.error("Can't send JMX Notification : "
78: + e.getMessage(), e);
79: }
80: }
81:
82: }
|