KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > httpserver > GrantAccessEvent


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.httpserver;
21
22 import java.util.EventObject JavaDoc;
23 import java.net.InetAddress JavaDoc;
24
25 /** This event is sent to access listeners to
26 * ask them, whether the access to specified resource is
27 * allowed.
28 *
29 * @author Jaroslav Tulach
30 */

31 public class GrantAccessEvent extends EventObject JavaDoc {
32     /** is access granted */
33     private boolean granted = false;
34     private InetAddress JavaDoc clientAddress;
35     private String JavaDoc resource;
36
37     /** Creates new AccessEvent. Used only in this package by
38     * the HttpServer to create new access event when a resource
39     * is requested.
40     *
41     * @param httpServer the server
42     */

43     GrantAccessEvent(Object JavaDoc source, InetAddress JavaDoc clientAddress, String JavaDoc resource) {
44         super (source);
45         this.clientAddress = clientAddress;
46         this.resource = resource;
47     }
48
49     /** The Inet address that initiated the connection.
50     * @return the inet address
51     */

52     public InetAddress JavaDoc getClientAddress () {
53         return clientAddress;
54     }
55
56     /** The resource to which access is requested */
57     public String JavaDoc getResource() {
58         return resource;
59     }
60
61     /** Allows access. The listener can use this method to grant
62     * access the client and resource.
63     */

64     public void grantAccess () {
65         granted = true;
66     }
67
68     /** Getter to test whether the access has been granted.
69     * @return true if a listener granted the access
70     */

71     boolean isGranted () {
72         return granted;
73     }
74 }
75
Popular Tags