Skip to content

Commit

Permalink
Merge pull request #1 from Adscore/feature/ADS-276_check_expiry_for_r…
Browse files Browse the repository at this point in the history
…equest_time

[ADS-276] Check expiry for request time - Version 1.0.4

Main changes:

    Check expiry against requestTime and signatureTime
    Set default expiration time to 60s

Other changes:

    Refactor SignatureVerifier, encapsulate code and leave only public API methods in SignatureVerifier.java
    Add samples as a git submodule
  • Loading branch information
DonCziken authored Feb 26, 2021
2 parents 95dee58 + 674dc3b commit 346bf67
Show file tree
Hide file tree
Showing 10 changed files with 668 additions and 461 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "submodules/client-libs-java-samples"]
path = submodules/client-libs-java-samples
url = https://github.com/Adscore/client-libs-java-samples
37 changes: 26 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Various Java client libraries for utilization of APIs in <a href="https://adscore.com">AdScore.com</a>

<h5> Latest version: 1.0.3 - currently available features: </h5>
<h5> Latest version: 1.0.4 - currently available features: </h5>
1. SignatureVerifier

<h5> other languages: <h5>
Expand All @@ -11,11 +11,26 @@ Various Java client libraries for utilization of APIs in <a href="https://adscor
<li> JS: https://github.com/variably/adscore-node </li>
</ul>

<h3>How to use</h3>
<h4>How to use</h3>

In order to use library:
- JRE 1.8 or higher is required

<h5>Samples</h5>
Following are few quick examples of how to use a verifier,
first import the entry point for the library.

To get the client-libs-java-sample project as submodule execute e.g.
```
git submodule init && git pull --recurse-submodules && git submodule update --remote
```
or clone it as a separate repository:
```
git clone https://github.com/Adscore/client-libs-java-samples
```

Then check `submodules/client-libs-java-samples/README.md`, there is info on how to execute samples.

<h5>Maven/Gradle central repository</h5>

The easiest way to utilize the library is to attach it as a Maven dependency:
Expand All @@ -24,14 +39,14 @@ The easiest way to utilize the library is to attach it as a Maven dependency:
<dependency>
<groupId>com.adscore</groupId>
<artifactId>adscore-client-libraries</artifactId>
<version>1.0.3</version>
<version>1.0.4</version>
</dependency>
```

or as a Gradle dependency:

```gradle
compile 'com.adscore:adscore-client-libraries:1.0.3'
compile 'com.adscore:adscore-client-libraries:1.0.4'
```

<h5>Maven/Gradle static file</h5>
Expand All @@ -42,19 +57,17 @@ Download the latest release from <a href="https://github.com/Adscore/client-libs
<dependency>
<groupId>com.adscore</groupId>
<artifactId>client-libraries</artifactId>
<version>1.0.3</version>
<version>1.0.4</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/adscore-client-libraries-1.0.3.jar</systemPath>
<systemPath>${project.basedir}/libs/adscore-client-libraries-1.0.4.jar</systemPath>
</dependency>
```
or as a Gradle:

```gradle
compile files('libs/adscore-client-libraries-1.0.3.jar')
compile files('libs/adscore-client-libraries-1.0.4.jar')
```

Note that this is a thin jar, so in case of manual referencing (i.e. not via mvn central) you need to ensure yourself that dependencies are satisifed - for list of those please look at build.gradle.

<h3>How to build library manually</h3>

If you want you can also build the library yourself. in order to do that you need to ensure:
Expand Down Expand Up @@ -123,7 +136,8 @@ than you have at least few options of how to verify signatures:

```java

// Verify with base64 encoded key and without expiry checking
// Verify with base64 encoded key.
// (No expiry parameter, the default expiry time for requestTime and signatureTime is 60s)
SignatureVerificationResult result =
SignatureVerifier.verify(
"BAYAXlNKGQFeU0oggAGBAcAAIAUdn1gbCBmA-u-kF--oUSuFw4B93piWC1Dn-D_1_6gywQAgEXCqgk2zPD6hWI1Y2rlrtV-21eIYBsms0odUEXNbRbA",
Expand All @@ -145,11 +159,12 @@ than you have at least few options of how to verify signatures:
"customer",
"key_non_base64_encoded",
false, // notify that we use non encoded key
60, // signature cant be older than 1 min
60, // signature cant be older than 1 min
"73.109.57.137");
[..]

// Verify against number of ip4 and ip6 addresses
//(No expiry parameter, the default expiry time for requestTime and signatureTime is 60s)
result =
SignatureVerifier.verify(
"BAYAXlNKGQFeU0oggAGBAcAAIAUdn1gbCBmA-u-kF--oUSuFw4B93piWC1Dn-D_1_6gywQAgEXCqgk2zPD6hWI1Y2rlrtV-21eIYBsms0odUEXNbRbA",
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
}

group 'com.adscore'
version '1.0.3'
version '1.0.4'

sourceCompatibility = 1.8

Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1 @@
rootProject.name = 'adscore-client-libraries'
rootProject.name = 'client-libs-java'
Loading

0 comments on commit 346bf67

Please sign in to comment.