Skip to content

Commit 0eed21d

Browse files
authored
Merge pull request #14 from FreeClimbAPI/VCSWP-14050-fix
Handle any Exception thrown within verifyRequest
2 parents 52cf193 + 6d10d25 commit 0eed21d

File tree

3 files changed

+25
-20
lines changed

3 files changed

+25
-20
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
77
## [Unreleased]
88
None
99

10+
<a name="4.0.1"></a>
11+
## [4.0.1] - 2021-05-03
12+
### Fixed
13+
- Fix exception handling within verifyRequest
14+
1015
<a name="4.0.0"></a>
1116
## [4.0.0] - 2021-05-03
1217
### Added

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ group = 'com.github.FreeClimbAPI'
99

1010
sourceCompatibility = 1.7 // java 7
1111
targetCompatibility = 1.7
12-
version = '4.0.0'
12+
version = '4.0.1'
1313

1414
repositories {
1515
mavenCentral()

src/main/java/com/vailsys/freeclimb/Utils.java

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@
1414
import org.apache.commons.codec.binary.Hex;
1515

1616
public class Utils {
17-
/**
18-
* Verify a request's signature
19-
*
20-
* @param requestBody The request's body
21-
* @param signatureHeader The request's `freeclimb-signature` header
22-
* @param signingSecret A signing secret from the FreeClimb account
23-
* @param tolerance Acceptable duration threshold represented in
17+
/**
18+
* Verify a request's signature
19+
*
20+
* @param requestBody The request's body
21+
* @param signatureHeader The request's `freeclimb-signature` header
22+
* @param signingSecret A signing secret from the FreeClimb account
23+
* @param tolerance Acceptable duration threshold represented in
2424
* milliseconds, defaulting to 5 minutes when not
2525
* provided
2626
* @throws FreeClimbException upon failed verification
27-
*/
28-
public static void verifyRequest(String requestBody, String signatureHeader, String signingSecret, int tolerance) throws FreeClimbException {
29-
String[] values = signatureHeader.split(",");
27+
*/
28+
public static void verifyRequest(String requestBody, String signatureHeader, String signingSecret, int tolerance) throws FreeClimbException {
29+
String[] values = signatureHeader.split(",");
3030

3131
long time = 0;
3232
List<String> v1 = new ArrayList<String>();
@@ -45,7 +45,7 @@ public static void verifyRequest(String requestBody, String signatureHeader, Str
4545
if (key.equals("v1")) {
4646
v1.add(value);
4747
}
48-
} catch (UnsupportedEncodingException e) {
48+
} catch (Exception e) {
4949
throw new FreeClimbException(e);
5050
}
5151
}
@@ -68,17 +68,17 @@ public static void verifyRequest(String requestBody, String signatureHeader, Str
6868
} catch (Exception e) {
6969
throw new FreeClimbException("Failed to calculate hmac using ", e);
7070
}
71-
}
71+
}
7272

7373
/**
74-
* Verify a request's signature
75-
*
76-
* @param requestBody The request's body
77-
* @param signatureHeader The request's `freeclimb-signature` header
74+
* Verify a request's signature
75+
*
76+
* @param requestBody The request's body
77+
* @param signatureHeader The request's `freeclimb-signature` header
7878
* @param signingSecret A signing secret from the FreeClimb account
7979
* @throws FreeClimbException upon failed verification
80-
*/
80+
*/
8181
public static void verifyRequest(String requestBody, String signatureHeader, String signingSecret) throws FreeClimbException {
82-
Utils.verifyRequest(requestBody, signatureHeader, signingSecret, 5*60*1000);
83-
}
82+
Utils.verifyRequest(requestBody, signatureHeader, signingSecret, 5*60*1000);
83+
}
8484
}

0 commit comments

Comments
 (0)