File tree Expand file tree Collapse file tree
here-oauth-client/src/test/java/com/here/account/oauth2 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -490,13 +490,26 @@ public void test_clientAssertion_viaIniStream() throws IOException {
490490 String privateKeyValue = props .getProperty (JwtClientAssertionProvider .PRIVATE_KEY_PROPERTY );
491491 String keyId = props .getProperty (JwtClientAssertionProvider .KEY_ID_PROPERTY );
492492
493+ // INI format can't handle multi-line PEM values inline.
494+ // If the private key value is inline PEM content, write it to a temp file first.
495+ String privateKeyRef = privateKeyValue ;
496+ File tempKeyFile = null ;
497+ if (privateKeyValue .contains ("-----BEGIN" ) || privateKeyValue .contains ("MII" )) {
498+ tempKeyFile = File .createTempFile ("jwt-it-key" , ".pem" );
499+ tempKeyFile .deleteOnExit ();
500+ try (java .io .FileWriter fw = new java .io .FileWriter (tempKeyFile )) {
501+ fw .write (privateKeyValue );
502+ }
503+ privateKeyRef = tempKeyFile .getAbsolutePath ();
504+ }
505+
493506 // Build INI content
494507 StringBuilder ini = new StringBuilder ();
495508 ini .append ("[default]\n " );
496509 ini .append ("here.token.endpoint.url = " ).append (tokenUrl ).append ("\n " );
497510 ini .append ("here.auth.method = private_key_jwt\n " );
498511 ini .append ("here.client.id = " ).append (clientId ).append ("\n " );
499- ini .append ("here.private.key = " ).append (privateKeyValue ).append ("\n " );
512+ ini .append ("here.private.key = " ).append (privateKeyRef ).append ("\n " );
500513 if (keyId != null ) {
501514 ini .append ("here.key.id = " ).append (keyId ).append ("\n " );
502515 }
You can’t perform that action at this time.
0 commit comments