net.floodlightcontroller.firewall
Class FirewallRulesResource

java.lang.Object
  extended by org.restlet.resource.Resource
      extended by org.restlet.resource.ServerResource
          extended by net.floodlightcontroller.firewall.FirewallRulesResource

public class FirewallRulesResource
extends org.restlet.resource.ServerResource


Field Summary
protected static org.slf4j.Logger log
           
 
Constructor Summary
FirewallRulesResource()
           
 
Method Summary
static boolean checkRuleExists(FirewallRule rule, java.util.List<FirewallRule> rules)
           
static int[] IPCIDRToPrefixBits(java.lang.String cidr)
           
static FirewallRule jsonToFirewallRule(java.lang.String fmJson)
          Turns a JSON formatted Firewall Rule string into a FirewallRule instance
 java.lang.String remove(java.lang.String fmJson)
          Takes a Firewall Rule string in JSON format and parses it into our firewall rule data structure, then deletes it from the firewall.
 java.util.List<FirewallRule> retrieve()
           
 java.lang.String store(java.lang.String fmJson)
          Takes a Firewall Rule string in JSON format and parses it into our firewall rule data structure, then adds it to the firewall.
 
Methods inherited from class org.restlet.resource.ServerResource
abort, commit, delete, delete, describeVariants, doCatch, doConditionalHandle, doError, doHandle, doHandle, doNegotiatedHandle, get, get, getAttribute, getInfo, getInfo, getOnSent, getPreferredVariant, getRole, getVariants, getVariants, handle, hasAnnotations, head, head, isAnnotated, isAutoCommitting, isCommitted, isConditional, isExisting, isInRole, isNegotiated, options, options, patch, patch, post, post, put, put, redirectPermanent, redirectPermanent, redirectSeeOther, redirectSeeOther, redirectTemporary, redirectTemporary, setAllowedMethods, setAnnotated, setAttribute, setAutoCommitting, setChallengeRequests, setCommitted, setConditional, setCookieSettings, setDimensions, setExisting, setLocationRef, setLocationRef, setNegotiated, setOnSent, setProxyChallengeRequests, setServerInfo, setStatus, setStatus, setStatus, setStatus, updateAllowedMethods, updateDimensions
 
Methods inherited from class org.restlet.resource.Resource
doError, doInit, doRelease, getAllowedMethods, getApplication, getChallengeRequests, getChallengeResponse, getClientInfo, getConditions, getConnegService, getContext, getConverterService, getCookies, getCookieSettings, getDimensions, getHostRef, getLocationRef, getLogger, getMatrix, getMatrixValue, getMaxForwards, getMetadataService, getMethod, getOriginalRef, getProtocol, getProxyChallengeRequests, getProxyChallengeResponse, getQuery, getQueryValue, getRanges, getReference, getReferrerRef, getRequest, getRequestAttributes, getRequestCacheDirectives, getRequestEntity, getResponse, getResponseAttributes, getResponseCacheDirectives, getResponseEntity, getRootRef, getServerInfo, getStatus, getStatusService, init, isConfidential, isLoggable, release, setApplication, setQueryValue, setRequest, setResponse, toObject, toRepresentation, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

protected static org.slf4j.Logger log
Constructor Detail

FirewallRulesResource

public FirewallRulesResource()
Method Detail

retrieve

@Get(value="json")
public java.util.List<FirewallRule> retrieve()

store

@Post
public java.lang.String store(java.lang.String fmJson)
Takes a Firewall Rule string in JSON format and parses it into our firewall rule data structure, then adds it to the firewall.

Parameters:
fmJson - The Firewall rule entry in JSON format.
Returns:
A string status message

remove

@Delete
public java.lang.String remove(java.lang.String fmJson)
Takes a Firewall Rule string in JSON format and parses it into our firewall rule data structure, then deletes it from the firewall.

Parameters:
fmJson - The Firewall rule entry in JSON format.
Returns:
A string status message

jsonToFirewallRule

public static FirewallRule jsonToFirewallRule(java.lang.String fmJson)
                                       throws java.io.IOException
Turns a JSON formatted Firewall Rule string into a FirewallRule instance

Parameters:
fmJson - The JSON formatted static firewall rule
Returns:
The FirewallRule instance
Throws:
java.io.IOException - If there was an error parsing the JSON

IPCIDRToPrefixBits

public static int[] IPCIDRToPrefixBits(java.lang.String cidr)

checkRuleExists

public static boolean checkRuleExists(FirewallRule rule,
                                      java.util.List<FirewallRule> rules)