1 23 24 package com.sun.enterprise.security.auth.realm; 25 26 import com.sun.enterprise.admin.event.AdminEventListenerException; 27 import com.sun.enterprise.admin.event.UserMgmtEvent; 28 import com.sun.enterprise.admin.event.UserMgmtEventListener; 29 import com.sun.enterprise.security.SecurityUtil; 30 import com.sun.enterprise.security.auth.realm.file.FileRealm; 31 import com.sun.enterprise.server.pluggable.SecuritySupport; 32 33 34 39 public class UserMgmtEventListenerImpl implements UserMgmtEventListener { 40 41 48 public void userAdded(UserMgmtEvent event) 49 throws AdminEventListenerException { 50 reloadRealm(event); 51 } 52 53 60 public void userRemoved(UserMgmtEvent event) 61 throws AdminEventListenerException { 62 reloadRealm(event); 63 } 64 65 72 public void userUpdated(UserMgmtEvent event) 73 throws AdminEventListenerException { 74 reloadRealm(event); 75 } 76 77 85 private void reloadRealm(UserMgmtEvent event) 86 throws AdminEventListenerException { 87 try { 88 String realmName = event.getAuthRealmName(); 89 Realm realm = Realm.getInstance(realmName); 90 91 if (realm instanceof FileRealm) { 93 SecuritySupport secSupp = SecurityUtil.getSecuritySupport(); 94 secSupp.synchronizeKeyFile(event.getConfigContext(), realmName); 95 } 96 97 realm.refresh(); 98 } catch(Exception ex) { 99 throw new AdminEventListenerException(ex); 100 } 101 } 102 } 103 | Popular Tags |