KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > slide > event > SecurityEvent


1 /*
2  * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/event/SecurityEvent.java,v 1.3 2004/07/28 09:36:21 ib Exp $
3  * $Revision: 1.3 $
4  * $Date: 2004/07/28 09:36:21 $
5  *
6  * ====================================================================
7  *
8  * Copyright 1999-2004 The Apache Software Foundation
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  */

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 JavaDoc;
32 import java.util.EventObject JavaDoc;
33
34 /**
35  * Security event class
36  *
37  * @version $Revision: 1.3 $
38  */

39 public class SecurityEvent extends EventObject JavaDoc {
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 JavaDoc 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 JavaDoc 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 JavaDoc toString() {
65         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc(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 JavaDoc listener, EventObject JavaDoc 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 JavaDoc listener, EventObject JavaDoc 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 JavaDoc listener, EventObject JavaDoc event) throws VetoException {
110             if ( listener instanceof SecurityListener ) ((SecurityListener)listener).revokePermission((SecurityEvent)event);
111         }
112     }
113 }
Popular Tags