1 17 18 19 package org.apache.naming; 20 21 import java.util.Hashtable ; 22 23 29 30 public class ContextAccessController { 31 32 33 35 36 39 private static Hashtable readOnlyContexts = new Hashtable (); 40 41 42 45 private static Hashtable securityTokens = new Hashtable (); 46 47 48 50 51 57 public static void setSecurityToken(Object name, Object token) { 58 if ((!securityTokens.containsKey(name)) && (token != null)) { 59 securityTokens.put(name, token); 60 } 61 } 62 63 64 70 public static void unsetSecurityToken(Object name, Object token) { 71 if (checkSecurityToken(name, token)) { 72 securityTokens.remove(name); 73 } 74 } 75 76 77 85 public static boolean checkSecurityToken 86 (Object name, Object token) { 87 Object refToken = securityTokens.get(name); 88 if (refToken == null) 89 return (true); 90 if ((refToken != null) && (refToken.equals(token))) 91 return (true); 92 return (false); 93 } 94 95 96 102 public static void setWritable(Object name, Object token) { 103 if (checkSecurityToken(name, token)) 104 readOnlyContexts.remove(name); 105 } 106 107 108 113 public static void setReadOnly(Object name) { 114 readOnlyContexts.put(name, name); 115 } 116 117 118 123 public static boolean isWritable(Object name) { 124 return !(readOnlyContexts.containsKey(name)); 125 } 126 127 128 } 129 130 | Popular Tags |