ip-validator

A simple library for validating IP address ranges against a blacklist/whitelist

License

License

Categories

Categories

Ant Build Tools
GroupId

GroupId

com.github.philanthropix
ArtifactId

ArtifactId

ip-validator
Last Version

Last Version

0.0.3
Release Date

Release Date

Type

Type

jar
Description

Description

ip-validator
A simple library for validating IP address ranges against a blacklist/whitelist
Project URL

Project URL

https://github.com/philanthropix/ip-validator
Source Code Management

Source Code Management

https://github.com/philanthropix/ip-validator

Download ip-validator

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.philanthropix/ip-validator/ -->
<dependency>
    <groupId>com.github.philanthropix</groupId>
    <artifactId>ip-validator</artifactId>
    <version>0.0.3</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.philanthropix/ip-validator/
implementation 'com.github.philanthropix:ip-validator:0.0.3'
// https://jarcasting.com/artifacts/com.github.philanthropix/ip-validator/
implementation ("com.github.philanthropix:ip-validator:0.0.3")
'com.github.philanthropix:ip-validator:jar:0.0.3'
<dependency org="com.github.philanthropix" name="ip-validator" rev="0.0.3">
  <artifact name="ip-validator" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.philanthropix', module='ip-validator', version='0.0.3')
)
libraryDependencies += "com.github.philanthropix" % "ip-validator" % "0.0.3"
[com.github.philanthropix/ip-validator "0.0.3"]

Dependencies

compile (2)

Group / Artifact Type Version
com.fasterxml.jackson.core : jackson-core jar 2.2.2
com.fasterxml.jackson.core : jackson-databind jar 2.2.2

test (1)

Group / Artifact Type Version
junit : junit jar 4.8.1

Project Modules

There are no modules declared in this project.

ip-validator

A simple java library for Blacklisting / Whiltelisting IP addresses based upon a hierarchical JSON configuration

Getting ip-validator

The latest release of ip-validator is in maven central

Adding to your pom.xml

<dependency>
    <groupId>com.github.philanthropix</groupId>
    <artifactId>ip-validator</artifactId>
    <version>0.0.3</version>
</dependency>

Building ip-validator

This project should build with JDK 6 and above, and Maven 3

No special processes required, just standard a Maven build command:

mvn clean package

Dependencies

ip-validator uses jackson to parse the JSON configuration file

To use

This library is very simple to use.

  1. First create a JSON file with the CIDR addresses you want to whitelist or blacklist
  2. Create an instance of the RuleTree class using the RuleTreeFactory class like so:
InputStream is; //get an input stream for the JSON config file you created 

RuleTree ruleTree = RuleTreeFactory.createRuleTree(is);
  1. Validate IP addresses against the whitelist/blacklist
if (ruleTree.validateIp("10.1.1.33")) {
	//do some cool stuff
}

JSON config file

The config file uses the followng format

{
 "entries" : [
   {
     "network" : "10.1.1.55",
     "cidr" : "24",
     "allowed" : true
   }
 ]
}

Versions

Version
0.0.3