1 17 package org.alfresco.filesys.server.auth.acl; 18 19 import org.alfresco.config.ConfigElement; 20 import org.alfresco.filesys.util.IPAddress; 21 22 25 public class IpAddressAccessControlParser extends AccessControlParser 26 { 27 28 31 public IpAddressAccessControlParser() 32 { 33 } 34 35 40 public String getType() 41 { 42 return "address"; 43 } 44 45 52 public AccessControl createAccessControl(ConfigElement params) throws ACLParseException 53 { 54 55 57 int access = parseAccessType(params); 58 59 61 String ipAddr = params.getAttribute("ip"); 62 if (ipAddr != null) 63 { 64 65 67 if (ipAddr.length() == 0 || IPAddress.isNumericAddress(ipAddr) == false) 68 throw new ACLParseException("Invalid IP address, " + ipAddr); 69 70 if (params.getAttributeCount() != 2) 71 throw new ACLParseException("Invalid parameter(s) specified for address"); 72 73 75 return new IpAddressAccessControl(ipAddr, null, getType(), access); 76 } 77 78 80 String subnet = params.getAttribute("subnet"); 81 if (subnet != null) 82 { 83 84 86 String netmask = params.getAttribute("mask"); 87 88 90 if (subnet.length() == 0 || netmask == null || netmask.length() == 0) 91 throw new ACLParseException("Invalid subnet/mask parameter"); 92 93 if (IPAddress.isNumericAddress(subnet) == false) 94 throw new ACLParseException("Invalid subnet parameter, " + subnet); 95 96 if (IPAddress.isNumericAddress(netmask) == false) 97 throw new ACLParseException("Invalid mask parameter, " + netmask); 98 99 101 return new IpAddressAccessControl(subnet, netmask, getType(), access); 102 } 103 104 106 throw new ACLParseException("Unknown address parameter(s)"); 107 } 108 } 109 | Popular Tags |