KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > core > DefaultCoreListener


1 /*
2  * SSL-Explorer
3  *
4  * Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */

19             
20 package com.sslexplorer.core;
21
22 import com.sslexplorer.boot.PropertyDefinition;
23 import com.sslexplorer.properties.PropertyChangeEvent;
24
25
26 /**
27  * Default listener of {@link CoreEvent}s.
28  *
29  * @author Brett Smith <a HREF="mailto: brett@3sp.com">&lt;brett@3sp.com&gt;</a>
30  */

31 public class DefaultCoreListener implements CoreListener {
32
33     public void coreEvent(CoreEvent evt) {
34         if (evt instanceof PropertyChangeEvent) {
35             PropertyChangeEvent pce = (PropertyChangeEvent) evt;
36             StringBuffer JavaDoc buf = new StringBuffer JavaDoc("Property ");
37             buf.append(pce.getDefinition().getName());
38             if (pce.getDefinition().getType() == PropertyDefinition.TYPE_PASSWORD) {
39                 buf.append(" changed");
40             } else {
41                 buf.append(" from ");
42                 buf.append(pce.getOldValue());
43                 buf.append(" to ");
44                 buf.append(pce.getNewValue());
45             }
46             if (pce.getSessionInfo() != null) {
47                 buf.append(" (by user ");
48                 buf.append(pce.getSessionInfo().getUser().getPrincipalName());
49                 buf.append(" )");
50             }
51             if (CoreServlet.log.isInfoEnabled())
52                 CoreServlet.log.info(buf.toString());
53             if(pce.getDefinition().isRestartRequired()) {
54                 CoreUtil.addMultipleGlobalWarning(GlobalWarning.MANAGEMENT_USERS,
55                     new BundleActionMessage("properties", "event.configurationChangeRestartRequired.warning"));
56             }
57         } else if (evt.getId() >= CoreEventConstants.KEYSTORE_CREATED && evt.getId() <= CoreEventConstants.KEYSTORE_PKCS12_KEY_KEY_IMPORTED
58                         && evt.getSessionInfo() != null) {
59             CoreUtil.addMultipleGlobalWarning(GlobalWarning.MANAGEMENT_USERS,
60                 new BundleActionMessage("properties", "event.configurationChangeRestartRequired.warning"));
61         }
62     }
63 }
Popular Tags