1 23 package org.apache.slide.store.mem; 24 25 import java.util.ArrayList ; 26 import java.util.Enumeration ; 27 import java.util.List ; 28 29 import org.apache.slide.common.ServiceAccessException; 30 import org.apache.slide.common.Uri; 31 import org.apache.slide.security.NodePermission; 32 import org.apache.slide.store.SecurityStore; 33 34 35 37 public class TransientSecurityStore extends AbstractTransientStore implements 38 SecurityStore 39 { 40 42 public void grantPermission(Uri uri, NodePermission permission) 43 throws ServiceAccessException 44 { 45 debug("grantPermission {0} {1}", uri, permission); 46 List list = (List )get(uri.toString()); 47 if (list != null) { 48 list = new ArrayList (list); 49 } else { 50 list = new ArrayList (); 51 } 52 list.add(permission); 53 put(uri.toString(), list); 54 } 55 56 public void revokePermission(Uri uri, NodePermission permission) 57 throws ServiceAccessException 58 { 59 debug("revokePermission {0} {1}", uri, permission); 60 List list = (List )get(uri.toString()); 61 if (list != null) { 62 list = new ArrayList (list); 63 if (list.remove(permission)) { 64 if (list.size() > 0) { 65 put(uri.toString(), list); 66 } else { 67 remove(uri.toString()); 68 } 69 } 70 } 71 } 72 73 public void revokePermissions(Uri uri) throws ServiceAccessException 74 { 75 debug("revokePermissions {0}", uri); 76 List list = (List )get(uri.toString()); 77 if (list != null) { 78 remove(uri.toString()); 79 } 80 } 81 82 public Enumeration enumeratePermissions(Uri uri) 83 throws ServiceAccessException 84 { 85 debug("enumeratePermissions {0}", uri); 86 List list = (List )get(uri.toString()); 87 if (list != null) { 88 return new IteratorEnum(list.iterator()); 89 } else { 90 return EMPTY_ENUM; 91 } 92 } 93 } 94 | Popular Tags |