1 17 package org.alfresco.filesys.server.auth.acl; 18 19 import java.util.StringTokenizer ; 20 21 import org.alfresco.filesys.server.SrvSession; 22 import org.alfresco.filesys.server.core.SharedDevice; 23 24 29 public class ProtocolAccessControl extends AccessControl 30 { 31 32 34 private static final String [] _protoTypes = { "SMB", "CIFS", "NFS", "FTP" }; 35 36 38 private String [] m_checkList; 39 40 47 protected ProtocolAccessControl(String protList, String type, int access) 48 { 49 super(protList, type, access); 50 51 53 m_checkList = listFromString(protList); 54 } 55 56 64 public int allowsAccess(SrvSession sess, SharedDevice share, AccessControlManager mgr) 65 { 66 67 69 String sessProto = null; 70 String sessName = sess.getClass().getName(); 71 72 if (sessName.endsWith(".SMBSrvSession")) 73 sessProto = "CIFS"; 74 else if (sessName.endsWith(".FTPSrvSession")) 75 sessProto = "FTP"; 76 else if (sessName.endsWith(".NFSSrvSession")) 77 sessProto = "NFS"; 78 79 81 if (sessProto != null && indexFromList(sessProto, m_checkList, false) != -1) 82 return getAccess(); 83 return Default; 84 } 85 86 92 public static final boolean validateProtocolList(String protList) 93 { 94 95 97 if (protList == null || protList.length() == 0) 98 return false; 99 100 102 StringTokenizer tokens = new StringTokenizer (protList, ","); 103 104 while (tokens.hasMoreTokens()) 105 { 106 107 109 String name = tokens.nextToken().toUpperCase(); 110 if (indexFromList(name, _protoTypes, false) == -1) 111 return false; 112 } 113 114 116 return true; 117 } 118 } 119 | Popular Tags |