14
14
import org .apache .commons .codec .binary .Hex ;
15
15
16
16
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
24
24
* milliseconds, defaulting to 5 minutes when not
25
25
* provided
26
26
* @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 ("," );
30
30
31
31
long time = 0 ;
32
32
List <String > v1 = new ArrayList <String >();
@@ -45,7 +45,7 @@ public static void verifyRequest(String requestBody, String signatureHeader, Str
45
45
if (key .equals ("v1" )) {
46
46
v1 .add (value );
47
47
}
48
- } catch (UnsupportedEncodingException e ) {
48
+ } catch (Exception e ) {
49
49
throw new FreeClimbException (e );
50
50
}
51
51
}
@@ -68,17 +68,17 @@ public static void verifyRequest(String requestBody, String signatureHeader, Str
68
68
} catch (Exception e ) {
69
69
throw new FreeClimbException ("Failed to calculate hmac using " , e );
70
70
}
71
- }
71
+ }
72
72
73
73
/**
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
78
78
* @param signingSecret A signing secret from the FreeClimb account
79
79
* @throws FreeClimbException upon failed verification
80
- */
80
+ */
81
81
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
+ }
84
84
}
0 commit comments