@@ -180,28 +180,31 @@ private String escapeEarly(final String text) throws EdgeAuthException {
180180 * @throws EdgeAuthException EdgeAuthException
181181 */
182182 private String generateToken (String path , boolean isUrl ) throws EdgeAuthException {
183- if (this .startTime == EdgeAuth .NOW ) {
184- this .startTime = Calendar .getInstance (TimeZone .getTimeZone ("UTC" )).getTimeInMillis () / 1000L ;
185- } else if (this .startTime != null && this .startTime < 0 ) {
183+ Long startTime = this .startTime ;
184+ Long endTime = this .endTime ;
185+
186+ if (startTime == EdgeAuth .NOW ) {
187+ startTime = Calendar .getInstance (TimeZone .getTimeZone ("UTC" )).getTimeInMillis () / 1000L ;
188+ } else if (startTime != null && startTime < 0 ) {
186189 throw new EdgeAuthException ("startTime must be ( > 0 )" );
187190 }
188191
189- if (this . endTime == null ) {
192+ if (endTime == null ) {
190193 if (this .windowSeconds != null && this .windowSeconds > 0 ) {
191- if (this . startTime == null ) {
192- this . endTime = (Calendar .getInstance (TimeZone .getTimeZone ("UTC" )).getTimeInMillis () / 1000L ) +
194+ if (startTime == null ) {
195+ endTime = (Calendar .getInstance (TimeZone .getTimeZone ("UTC" )).getTimeInMillis () / 1000L ) +
193196 this .windowSeconds ;
194197 } else {
195- this . endTime = this . startTime + this .windowSeconds ;
198+ endTime = startTime + this .windowSeconds ;
196199 }
197200 } else {
198201 throw new EdgeAuthException ("You must provide an expiration time or a duration window ( > 0 )" );
199202 }
200- } else if (this . endTime <= 0 ) {
203+ } else if (endTime <= 0 ) {
201204 throw new EdgeAuthException ("endTime must be ( > 0 )" );
202205 }
203206
204- if (this . startTime != null && (this . endTime <= this . startTime )) {
207+ if (startTime != null && (endTime <= startTime )) {
205208 throw new EdgeAuthException ("Token will have already expired." );
206209 }
207210
@@ -236,11 +239,11 @@ private String generateToken(String path, boolean isUrl) throws EdgeAuthExceptio
236239 }
237240 if (this .startTime != null ) {
238241 newToken .append ("st=" );
239- newToken .append (Long .toString (this . startTime ));
242+ newToken .append (startTime .toString ());
240243 newToken .append (this .fieldDelimiter );
241244 }
242245 newToken .append ("exp=" );
243- newToken .append (Long .toString (this . endTime ));
246+ newToken .append (endTime .toString ());
244247 newToken .append (this .fieldDelimiter );
245248
246249 if (!isUrl ) {
@@ -513,21 +516,21 @@ public String getSessionId() {
513516 /**
514517 * @return startTime
515518 */
516- public long getStartTime () {
519+ public Long getStartTime () {
517520 return this .startTime ;
518521 }
519522
520523 /**
521524 * @return endTime
522525 */
523- public long getEndTime () {
526+ public Long getEndTime () {
524527 return this .endTime ;
525528 }
526529
527530 /**
528531 * @return windowSeconds
529532 */
530- public long getwindowSeconds () {
533+ public Long getwindowSeconds () {
531534 return this .windowSeconds ;
532535 }
533536
0 commit comments