KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > security > CachedPermissionImpl


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package com.sun.enterprise.security;
24
25 import java.security.Permission JavaDoc;
26 import com.sun.enterprise.security.CachedPermission;
27 import com.sun.enterprise.security.PermissionCache;
28 /**
29  * This class is
30  * @author Ron Monzillo
31  */

32
33 public class CachedPermissionImpl extends Object JavaDoc implements CachedPermission {
34
35     PermissionCache permissionCache;
36     Permission JavaDoc permission;
37     boolean granted;
38     Epoch epoch;
39
40     public CachedPermissionImpl(PermissionCache c, Permission JavaDoc p) {
41     this.permissionCache = c;
42     this.permission = p;
43     epoch = new Epoch();
44     }
45
46     public Permission JavaDoc getPermission() {
47     return this.permission;
48     }
49
50     public PermissionCache getPermissionCache() {
51     return this.permissionCache;
52     }
53
54     //synchronization done in PermissionCache
55
public boolean checkPermission() {
56     boolean granted = false;
57     if (permissionCache != null) {
58         granted = permissionCache.checkPermission(this.permission,this.epoch);
59     }
60     return granted;
61     }
62
63     // used to hold last result obtained from cache and cache epoch.
64
// epoch is used by PermissionCache to determine when result is out of date.
65
class Epoch {
66
67     int epoch;
68     boolean granted;
69
70     Epoch() {
71         this.epoch = 0;
72         this.granted = false;
73     }
74     }
75
76 }
77
78
79
80
Popular Tags