Package org.apache.lenya.ac

Examples of org.apache.lenya.ac.IPRange


    if (args.length == 0) {
      System.out.println(
        "Usage: network, netmask, ip (e.g. 192.168.0.64 255.255.255.240 192.168.0.70)");
      return;
    }
    IPRange ipr = new FileIPRange();
    try {
      ipr.setNetworkAddress(args[0]);
      ipr.setSubnetMask(args[1]);
      if (ipr.contains(new Machine(args[2]))) {
        System.out.println("true");
      } else {
        System.out.println("false");
      }
    } catch (Exception e) {
View Full Code Here


     * @see org.apache.lenya.cms.usecase.AbstractUsecase#doCheckExecutionConditions()
     */
    protected void doCheckExecutionConditions() throws Exception {
        String id = getParameterAsString(IPRangeProfile.ID);

        IPRange existingIPRange = getIpRangeManager().getIPRange(id);

        if (existingIPRange != null) {
            addErrorMessage("This IP range already exists.");
        }

View Full Code Here

        String id = getParameterAsString(IPRangeProfile.ID);
        String name = getParameterAsString(IPRangeProfile.NAME);
        String description = getParameterAsString(IPRangeProfile.DESCRIPTION);

        IPRange ipRange = new FileIPRange(configDir, id);
        ContainerUtil.enableLogging(ipRange, getLogger());

        ipRange.setName(name);
        ipRange.setDescription(description);

        String networkString = "";
        String subnetString = "";

        for (int i = 0; i < 4; i++) {
            if (i > 0) {
                networkString += ".";
                subnetString += ".";
            }
            Part netPart = (Part) getParameter(IPRangeProfile.NETWORK_ADDRESS + "-" + i);
            networkString += netPart.getValue();
            Part subPart = (Part) getParameter(IPRangeProfile.SUBNET_MASK + "-" + i);
            subnetString += subPart.getValue();
        }

        InetAddress networkAddress = InetAddress.getByName(networkString);
        ipRange.setNetworkAddress(networkAddress.getAddress());

        InetAddress subnetMask = InetAddress.getByName(subnetString);
        ipRange.setSubnetMask(subnetMask.getAddress());

        ipRange.save();
        getIpRangeManager().add(ipRange);
       
        setExitParameter(IPRangeProfile.ID, id);
    }
View Full Code Here

        super.doExecute();

        String name = getParameterAsString(NAME);
        String description = getParameterAsString(DESCRIPTION);
       
        IPRange ipRange = getIPRange();

        ipRange.setName(name);
        ipRange.setDescription(description);
       
        String networkString = "";
        String subnetString = "";
       
        for (int i = 0; i < 4; i++) {
            if (i > 0) {
                networkString += ".";
                subnetString += ".";
            }
            Part netPart = (Part) getParameter(IPRangeProfile.NETWORK_ADDRESS + "-" + i);
            networkString += netPart.getValue();
            Part subPart = (Part) getParameter(IPRangeProfile.SUBNET_MASK + "-" + i);
            subnetString += subPart.getValue();
        }

        InetAddress networkAddress = InetAddress.getByName(networkString);
        ipRange.setNetworkAddress(networkAddress.getAddress());

        InetAddress subnetMask = InetAddress.getByName(subnetString);
        ipRange.setSubnetMask(subnetMask.getAddress());

        ipRange.save();

    }
View Full Code Here

        }
        return ranges;
    }

    public IPRange add(String id) throws AccessControlException {
        IPRange range = new FileIPRange(this, getLogger(), id);
        super.add(range);
        return range;
    }
View Full Code Here

     * @see org.apache.lenya.cms.usecase.AbstractUsecase#doCheckExecutionConditions()
     */
    protected void doCheckExecutionConditions() throws Exception {
        String id = getParameterAsString(IPRangeProfile.ID);

        IPRange existingIPRange = getIpRangeManager().getIPRange(id);

        if (existingIPRange != null) {
            addErrorMessage("This IP range already exists.");
        }

View Full Code Here

        String id = getParameterAsString(IPRangeProfile.ID);
        String name = getParameterAsString(IPRangeProfile.NAME);
        String description = getParameterAsString(IPRangeProfile.DESCRIPTION);

        IPRange ipRange = getIpRangeManager().add(id);
        ContainerUtil.enableLogging(ipRange, getLogger());

        ipRange.setName(name);
        ipRange.setDescription(description);

        StringBuffer networkBuffer = new StringBuffer();
        StringBuffer subnetBuffer = new StringBuffer();

        for (int i = 0; i < 4; i++) {
            if (i > 0) {
                networkBuffer.append(".");
                subnetBuffer.append(".");
            }
            Part netPart = (Part) getParameter(IPRangeProfile.NETWORK_ADDRESS + "-" + i);
            networkBuffer.append(netPart.getValue());
            Part subPart = (Part) getParameter(IPRangeProfile.SUBNET_MASK + "-" + i);
            subnetBuffer.append(subPart.getValue());
        }

        InetAddress networkAddress = InetAddress.getByName(networkBuffer.toString());
        ipRange.setNetworkAddress(networkAddress.getAddress());

        InetAddress subnetMask = InetAddress.getByName(subnetBuffer.toString());
        ipRange.setSubnetMask(subnetMask.getAddress());

        ipRange.save();
       
        setExitParameter(IPRangeProfile.ID, id);
    }
View Full Code Here

        super.doExecute();

        String name = getParameterAsString(NAME);
        String description = getParameterAsString(DESCRIPTION);

        IPRange ipRange = getIPRange();

        ipRange.setName(name);
        ipRange.setDescription(description);

        StringBuffer networkBuffer = new StringBuffer();
        StringBuffer subnetBuffer = new StringBuffer();

        for (int i = 0; i < 4; i++) {
            if (i > 0) {
                networkBuffer.append(".");
                subnetBuffer.append(".");
            }
            Part netPart = (Part) getParameter(IPRangeProfile.NETWORK_ADDRESS + "-" + i);
            networkBuffer.append(netPart.getValue());
            Part subPart = (Part) getParameter(IPRangeProfile.SUBNET_MASK + "-" + i);
            subnetBuffer.append(subPart.getValue());
        }

        InetAddress networkAddress = InetAddress.getByName(networkBuffer.toString());
        ipRange.setNetworkAddress(networkAddress.getAddress());

        InetAddress subnetMask = InetAddress.getByName(subnetBuffer.toString());
        ipRange.setSubnetMask(subnetMask.getAddress());

        ipRange.save();

    }
View Full Code Here

     * @see org.apache.lenya.cms.usecase.AbstractUsecase#doExecute()
     */
    protected void doExecute() throws Exception {
        super.doExecute();
       
        IPRange ipRange = getIpRange();
        ipRange.removeFromAllGroups();
       
        List ipRangeGroups = (List) getParameter(IP_RANGE_GROUPS);
        for (Iterator i = ipRangeGroups.iterator(); i.hasNext(); ) {
            Group group = (Group) i.next();
            group.add(ipRange);
        }
        ipRange.save();
    }
View Full Code Here

        ipRange.save();
    }
   
    protected IPRange getIpRange() {
        String ipRangeId = getParameterAsString(IPRangeProfile.ID);
        IPRange ipRange = getIpRangeManager().getIPRange(ipRangeId);
        if (ipRange == null) {
            throw new RuntimeException("IP range [" + ipRangeId + "] not found.");
        }
        return ipRange;
    }
View Full Code Here

TOP

Related Classes of org.apache.lenya.ac.IPRange

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.