1 19 20 package com.sslexplorer.security.forms; 21 22 import javax.servlet.http.HttpSession ; 23 24 import org.apache.struts.action.ActionMapping; 25 26 import com.sslexplorer.security.IpRestriction; 27 import com.sslexplorer.security.IpRestrictionItem; 28 import com.sslexplorer.security.IpRestrictionItemModel; 29 import com.sslexplorer.table.forms.AbstractPagerForm; 30 31 39 public class ShowAvailableIpRestrictionsForm extends AbstractPagerForm { 40 41 43 private IpRestriction[] ipRestrictions; 44 private String action; 45 46 49 public ShowAvailableIpRestrictionsForm() { 50 super(new IpRestrictionItemModel()); 51 getPager().setSorts(false); 52 } 53 54 60 public void initialize(IpRestriction[] ipRestrictions, HttpSession session) { 61 super.initialize(session, ""); 62 for (int i = 0; ipRestrictions != null && i < ipRestrictions.length; i++) { 63 getModel().addItem(new IpRestrictionItem(ipRestrictions[i], i > 1, i > 0 && i < ( ipRestrictions.length - 1 ), 64 !ipRestrictions[i].isDefault())); 65 } 66 getPager().rebuild(getFilterText()); 67 } 68 69 74 public IpRestriction[] getIpRestrictions() { 75 return ipRestrictions; 76 } 77 78 83 public boolean isAuthorized() { 84 return action != null && action.equals("allow"); 85 } 86 87 92 public boolean isDisplayable() { 93 return ipRestrictions.length > 0; 94 } 95 96 99 public void reset(ActionMapping mapping, javax.servlet.http.HttpServletRequest request) { 100 ipRestrictions = null; 101 action = ""; 102 } 103 } | Popular Tags |