File tree Expand file tree Collapse file tree 3 files changed +12
-6
lines changed
test/java/com/opentok/test Expand file tree Collapse file tree 3 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ archivesBaseName = 'opentok'
9
9
// TODO: how do we increment this before/after a release for deployment and development?
10
10
version = ' 2.2.0-pre'
11
11
12
- sourceCompatibility = 1.5
12
+ sourceCompatibility = 1.6
13
13
14
14
task javadocJar (type : Jar ) {
15
15
classifier = ' javadoc'
Original file line number Diff line number Diff line change @@ -124,8 +124,8 @@ public String generateToken(TokenOptions tokenOptions) throws OpenTokException {
124
124
throw new InvalidArgumentException (
125
125
"Expire time must be in the next 30 days. too large by " + (expireTime - (now + (60 *60 *24 *30 ))));
126
126
}
127
- dataStringBuilder . append ( "&expire_time=" );
128
- dataStringBuilder .append (expireTime );
127
+ // NOTE: Double.toString() would print the value with scientific notation
128
+ dataStringBuilder .append (String . format ( "&expire_time=%.0f" , expireTime ) );
129
129
130
130
if (data != null ) {
131
131
if (data .length () > 1000 ) {
@@ -156,7 +156,13 @@ public String generateToken(TokenOptions tokenOptions) throws OpenTokException {
156
156
innerBuilder .append (":" );
157
157
innerBuilder .append (dataStringBuilder .toString ());
158
158
159
- tokenStringBuilder .append (Base64 .encodeBase64URLSafeString (innerBuilder .toString ().getBytes ("UTF-8" )));
159
+ tokenStringBuilder .append (
160
+ Base64 .encodeBase64String (
161
+ innerBuilder .toString ().getBytes ("UTF-8" )
162
+ )
163
+ .replace ("+" , "-" )
164
+ .replace ("/" , "_" )
165
+ );
160
166
161
167
// if we only wanted Java 7 and above, we could DRY this into one catch clause
162
168
} catch (SignatureException e ) {
Original file line number Diff line number Diff line change @@ -243,9 +243,9 @@ public void testTokenExpireTime() throws
243
243
assertTrue (Helpers .verifyTokenSignature (oneHourToken , apiSecret ));
244
244
245
245
Map <String , String > defaultTokenData = Helpers .decodeToken (defaultToken );
246
- assertEquals (Double .toString (inOneDay ), defaultTokenData .get ("expire_time" ));
246
+ assertEquals (Long .toString (inOneDay ), defaultTokenData .get ("expire_time" ));
247
247
Map <String , String > oneHourTokenData = Helpers .decodeToken (oneHourToken );
248
- assertEquals (Double .toString (inOneHour ), oneHourTokenData .get ("expire_time" ));
248
+ assertEquals (Long .toString (inOneHour ), oneHourTokenData .get ("expire_time" ));
249
249
assertEquals (2 , exceptions .size ());
250
250
for (Exception e : exceptions ) {
251
251
assertEquals (InvalidArgumentException .class , e .getClass ());
You can’t perform that action at this time.
0 commit comments