1 23 24 package org.apache.slide.event; 25 26 import org.apache.slide.common.SlideToken; 27 import org.apache.slide.common.Uri; 28 import org.apache.slide.common.Namespace; 29 import org.apache.slide.security.NodePermission; 30 31 import java.util.EventListener ; 32 import java.util.EventObject ; 33 34 39 public class SecurityEvent extends EventObject { 40 public final static GrantPermission GRANT_PERMISSION = new GrantPermission(); 41 public final static RevokePermission REVOKE_PERMISSION = new RevokePermission(); 42 public final static DenyPermission DENY_PERMISSION = new DenyPermission(); 43 44 public final static String GROUP = "security"; 45 public final static AbstractEventMethod[] methods = new AbstractEventMethod[] { GRANT_PERMISSION, REVOKE_PERMISSION, DENY_PERMISSION }; 46 47 private Uri objectUri; 48 private SlideToken token; 49 private NodePermission permission; 50 private Namespace namespace; 51 52 public SecurityEvent(Object source, SlideToken token, Namespace namespace, Uri objectUri, NodePermission permission) { 53 super(source); 54 this.objectUri = objectUri; 55 this.token = token; 56 this.permission = permission; 57 this.namespace = namespace; 58 } 59 60 public Namespace getNamespace() { 61 return namespace; 62 } 63 64 public String toString() { 65 StringBuffer buffer = new StringBuffer (256); 66 buffer.append(getClass().getName()).append("[object-uri=").append(objectUri); 67 buffer.append(", permission=").append(permission); 68 buffer.append("]"); 69 return buffer.toString(); 70 } 71 72 public Uri getObjectUri() { 73 return objectUri; 74 } 75 76 public SlideToken getToken() { 77 return token; 78 } 79 80 public NodePermission getPermission() { 81 return permission; 82 } 83 84 public final static class GrantPermission extends VetoableEventMethod { 85 public GrantPermission() { 86 super(GROUP, "grant-permission"); 87 } 88 89 public void fireVetaoableEvent(EventListener listener, EventObject event) throws VetoException { 90 if ( listener instanceof SecurityListener ) ((SecurityListener)listener).grantPermission((SecurityEvent)event); 91 } 92 } 93 94 public final static class DenyPermission extends VetoableEventMethod { 95 public DenyPermission() { 96 super(GROUP, "deny-permission"); 97 } 98 99 public void fireVetaoableEvent(EventListener listener, EventObject event) throws VetoException { 100 if ( listener instanceof SecurityListener ) ((SecurityListener)listener).denyPermission((SecurityEvent)event); 101 } 102 } 103 104 public final static class RevokePermission extends VetoableEventMethod { 105 public RevokePermission() { 106 super(GROUP, "revoke-permission"); 107 } 108 109 public void fireVetaoableEvent(EventListener listener, EventObject event) throws VetoException { 110 if ( listener instanceof SecurityListener ) ((SecurityListener)listener).revokePermission((SecurityEvent)event); 111 } 112 } 113 } | Popular Tags |