1 16 17 package org.apache.naming.core; 18 19 import java.util.Hashtable ; 20 21 27 public class ContextAccessController { 28 29 30 32 33 36 private static Hashtable readOnlyContexts = new Hashtable (); 37 38 39 42 private static Hashtable securityTokens = new Hashtable (); 43 44 45 47 48 54 public static void setSecurityToken(Object name, Object token) { 55 if ((!securityTokens.containsKey(name)) && (token != null)) { 56 securityTokens.put(name, token); 57 } 58 } 59 60 61 67 public static void unsetSecurityToken(Object name, Object token) { 68 if (checkSecurityToken(name, token)) { 69 securityTokens.remove(name); 70 } 71 } 72 73 74 82 public static boolean checkSecurityToken 83 (Object name, Object token) { 84 Object refToken = securityTokens.get(name); 85 if (refToken == null) 86 return (true); 87 if ((refToken != null) && (refToken.equals(token))) 88 return (true); 89 return (false); 90 } 91 92 93 99 public static void setWritable(Object name, Object token) { 100 if (checkSecurityToken(name, token)) 101 readOnlyContexts.remove(name); 102 } 103 104 105 110 public static void setReadOnly(Object name) { 111 readOnlyContexts.put(name, name); 112 } 113 114 115 120 public static boolean isWritable(Object name) { 121 return !(readOnlyContexts.containsKey(name)); 122 } 123 } 124 125 | Popular Tags |