1 17 package org.alfresco.filesys.server.auth.acl; 18 19 import java.net.InetAddress ; 20 21 import org.alfresco.filesys.server.SrvSession; 22 import org.alfresco.filesys.server.core.SharedDevice; 23 import org.alfresco.filesys.util.IPAddress; 24 25 31 public class IpAddressAccessControl extends AccessControl 32 { 33 34 36 private String m_subnet; 37 private String m_netMask; 38 39 47 protected IpAddressAccessControl(String address, String mask, String type, int access) 48 { 49 super(address, type, access); 50 51 53 m_subnet = address; 54 m_netMask = mask; 55 56 58 if (m_netMask != null) 59 setName(m_subnet + "/" + m_netMask); 60 } 61 62 70 public int allowsAccess(SrvSession sess, SharedDevice share, AccessControlManager mgr) 71 { 72 73 75 InetAddress remoteAddr = sess.getRemoteAddress(); 76 77 if (remoteAddr == null) 78 return Default; 79 80 82 String ipAddr = remoteAddr.getHostAddress(); 83 84 86 int sts = Default; 87 88 if (m_netMask == null) 89 { 90 91 93 if (IPAddress.parseNumericAddress(ipAddr) == IPAddress.parseNumericAddress(getName())) 94 sts = getAccess(); 95 } 96 else 97 { 98 99 101 if (IPAddress.isInSubnet(ipAddr, m_subnet, m_netMask) == true) 102 sts = getAccess(); 103 } 104 105 107 return sts; 108 } 109 } 110 | Popular Tags |