Package com.adito.security

Examples of com.adito.security.IpRestriction


        SystemDatabase database = SystemDatabaseFactory.getInstance();
        IpRestriction[] restrictions = database.getIpRestrictions();
       
        Collection<IpRestriction> differences = new HashSet<IpRestriction>(Arrays.asList(restrictions));
        for (String restrictionId : restrictionIds) {
            IpRestriction ipRestriction = findIpRestriction(restrictions, Integer.valueOf(restrictionId));
            if (ipRestriction !=null) {
                differences.remove(ipRestriction);
            }
        }
        return differences.toArray(new IpRestriction[differences.size()]);
View Full Code Here


     */
    public ActionForward moveDown(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
        PolicyUtil.checkPermission(PolicyConstants.IP_RESTRICTIONS_RESOURCE_TYPE, PolicyConstants.PERM_EDIT, request);
        int id = Integer.parseInt(request.getParameter("id"));
        SystemDatabase database = SystemDatabaseFactory.getInstance();
        IpRestriction restriction1 = database.getIpRestriction(id);
        String ipAddress = restriction1.getAddress();
        String ipPermission = restriction1.getAllowed() ? "Allowed" : "Denied";
        try {
            List<IpRestriction> restrictions = Arrays.asList(database.getIpRestrictions());
            database.swapIpRestrictions(restriction1, restrictions.get(restrictions.indexOf(restriction1) + 1));
            fireCoreEvent(request, CoreEventConstants.IP_RESTRICTION_MOVE_DOWN, ipAddress, ipPermission, CoreEvent.STATE_SUCCESSFUL);
        } catch (Exception e) {
View Full Code Here

     */
    public ActionForward moveUp(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
        PolicyUtil.checkPermission(PolicyConstants.IP_RESTRICTIONS_RESOURCE_TYPE, PolicyConstants.PERM_EDIT, request);
        int id = Integer.parseInt(request.getParameter("id"));
        SystemDatabase database = SystemDatabaseFactory.getInstance();
        IpRestriction restriction1 = database.getIpRestriction(id);
        String ipAddress = restriction1.getAddress();
        String ipPermission = restriction1.getAllowed() ? "Allowed" : "Denied";
        try {
            List<IpRestriction> restrictions = Arrays.asList(database.getIpRestrictions());
            database.swapIpRestrictions(restriction1, restrictions.get(restrictions.indexOf(restriction1) - 1));
            fireCoreEvent(request, CoreEventConstants.IP_RESTRICTION_MOVE_UP, ipAddress, ipPermission, CoreEvent.STATE_SUCCESSFUL);
        } catch (Exception e) {
View Full Code Here

    private void deleteIpRestrictions(HttpServletRequest request, String[] restrictionIds) throws Exception {
        SystemDatabase database = SystemDatabaseFactory.getInstance();
        IpRestriction[] restrictions = database.getIpRestrictions();
       
        for (String restrictionId : restrictionIds) {
            IpRestriction ipRestriction = findIpRestriction(restrictions, Integer.valueOf(restrictionId));
            if (ipRestriction != null) {
                deleteIpRestriction(request, ipRestriction);
            }
        }
    }
View Full Code Here

     * @throws Exception on any error
     */
    public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
                    throws Exception {
        int id = Integer.parseInt(request.getParameter("id"));
        IpRestriction restriction = SystemDatabaseFactory.getInstance().getIpRestriction(id);
        request.setAttribute(Constants.EDITING_ITEM, restriction);
        return mapping.findForward("edit");
    }
View Full Code Here

    public ActionForward create(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
                    throws Exception {
        PolicyUtil.checkPermission(PolicyConstants.IP_RESTRICTIONS_RESOURCE_TYPE, PolicyConstants.PERM_CREATE, request);
        IpRestriction[] ipRestriction = SystemDatabaseFactory.getInstance().getIpRestrictions();
        IpRestrictionForm ipRestrictionForm = (IpRestrictionForm) form;
        ipRestrictionForm.initialize(new IpRestriction(ipRestriction.length > 0 && ipRestriction[0].getDenied()), false);
        ipRestrictionForm.setReferer(CoreUtil.getReferer(request));
        CoreUtil.addRequiredFieldMessage(this, request);
        return mapping.findForward("display");
    }
View Full Code Here

        SystemDatabase database = SystemDatabaseFactory.getInstance();
        IpRestriction[] restrictions = database.getIpRestrictions();
        int i = 0;
        for(; i < restrictions.length; i++) {
          if(restrictions[i].getAddress().equals(restriction)) {
            restrictions[i] = new IpRestriction(restrictions[i].getAddress(), isAllow, restrictions[i].getPriority());
            break;
          }
        }
        if(i == restrictions.length) {
          List<IpRestriction> newRestrictions = new ArrayList<IpRestriction>(Arrays.asList(restrictions));
          newRestrictions.add(new IpRestriction(restriction, isAllow, Integer.MAX_VALUE));
            return newRestrictions.toArray(new IpRestriction[newRestrictions.size()]);
        }
        return restrictions;
    }
View Full Code Here

        }
        return restrictions;
    }
   
    private void fireCoreEvent(HttpServletRequest request, IpRestrictionForm ipRestrictionForm, int state) {
        IpRestriction restriction = ipRestrictionForm.getRestriction();
        int eventType = ipRestrictionForm.isEditing() ? CoreEventConstants.EDIT_IP_RESTRICTION : CoreEventConstants.CREATE_IP_RESTRICTION;
        CoreEvent coreEvent = new CoreEvent(this, eventType, null, getSessionInfo(request), state);
        coreEvent.addAttribute(CoreAttributeConstants.EVENT_ATTR_IP_RESTRICTION_ADDRESS, restriction.getAddress());
        coreEvent.addAttribute(CoreAttributeConstants.EVENT_ATTR_IP_RESTRICTION_IS_AUTHORIZED, String.valueOf(restriction.getAllowed()));
        CoreServlet.getServlet().fireCoreEvent(coreEvent);

    }
View Full Code Here

     * @param resultSet
     * @return IpRestriction
     * @throws SQLException
     */
    private static IpRestriction buildIpRestriction(ResultSet resultSet) throws SQLException {
        return new IpRestriction(resultSet.getInt("restriction_id"), resultSet.getString("address"), resultSet.getInt("type"),
            resultSet.getInt("priority"));
    }
View Full Code Here

TOP

Related Classes of com.adito.security.IpRestriction

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.