@@ -61,35 +61,37 @@ public class JWTTokenProvider extends AbstractAuthProvider {
6161 private final String imsOrgId ;
6262 private final String technicalAccountKey ;
6363 private final String clientId ;
64+ private final String clientSecret ;
6465 private final String keyPath ;
6566 private String jwtToken ;
6667
67- JWTTokenProvider (String endpoint , String imsOrgId , String clientId , String technicalAccountKey ,
68+ JWTTokenProvider (String endpoint , String clientId , String clientSecret , String imsOrgId , String technicalAccountKey ,
6869 String keyPath ) {
69- this (imsOrgId , clientId , technicalAccountKey , keyPath );
70+ this (clientId , clientSecret , imsOrgId , technicalAccountKey , keyPath );
7071 this .endpoint = endpoint ;
7172 }
7273
73- JWTTokenProvider (String imsOrgId , String clientId , String technicalAccountKey , String keyPath ) {
74+ JWTTokenProvider (String clientId , String clientSecret , String imsOrgId , String technicalAccountKey , String keyPath ) {
7475 this .imsOrgId = imsOrgId ;
7576 this .clientId = clientId ;
77+ this .clientSecret = clientSecret ;
7678 this .technicalAccountKey = technicalAccountKey ;
7779 this .keyPath = keyPath ;
7880 }
7981
8082 @ Override
8183 protected TokenResponse getTokenResponse () throws AuthException {
8284 LOG .debug ("refreshing expired jwtToken: {}" , clientId );
83- StringBuffer params = new StringBuffer ()
85+ StringBuilder params = new StringBuilder ()
8486 .append ("&client_id=" ).append (clientId )
85- .append ("&client_secret=" ).append (technicalAccountKey )
87+ .append ("&client_secret=" ).append (clientSecret )
8688 .append ("&jwt_token=" ).append (getJWTToken ());
8789
8890 try {
8991 return HttpProducer .newBuilder (endpoint ).build ().post (
9092 IMS_ENDPOINT_PATH ,
9193 params .toString ().getBytes (),
92- ContentType .MULTIPART_FORM_DATA .getMimeType (),
94+ ContentType .APPLICATION_FORM_URLENCODED .getMimeType (),
9395 getContentHandler ()
9496 );
9597 } catch (HttpException httpException ) {
@@ -151,7 +153,7 @@ private boolean isJWTExpired() {
151153 StandardCharsets .UTF_8 .name ()
152154 );
153155 JSONObject tokenBodyJson = new JSONObject (tokenBody );
154- Long expiresIn = (Long )tokenBodyJson .get (JWT_EXPIRY_KEY );
156+ long expiresIn = (( Number )tokenBodyJson .get (JWT_EXPIRY_KEY )). longValue ( );
155157 return System .currentTimeMillis () <= (expiresIn - DEFAULT_JWT_TOKEN_UPDATE_THRESHOLD );
156158 } catch (UnsupportedEncodingException exception ) {
157159 LOG .error ("Exception while parsing JWT token" , exception );
0 commit comments