@@ -274,7 +274,9 @@ public AuthResponse createToken(final TokenRequest tokenRequest, final String to
274
274
275
275
// Validate restResponse
276
276
if (restResponse .getStatus () != 200 ) {
277
- throw new VaultException ("Vault responded with HTTP status code: " + restResponse .getStatus (), restResponse .getStatus ());
277
+ throw new VaultException ("Vault responded with HTTP status code: " + restResponse .getStatus ()
278
+ + "\n Response body: " + new String (restResponse .getBody (), StandardCharsets .UTF_8 ),
279
+ restResponse .getStatus ());
278
280
}
279
281
final String mimeType = restResponse .getMimeType () == null ? "null" : restResponse .getMimeType ();
280
282
if (!mimeType .equals ("application/json" )) {
@@ -340,7 +342,9 @@ public AuthResponse loginByAppID(final String path, final String appId, final St
340
342
341
343
// Validate restResponse
342
344
if (restResponse .getStatus () != 200 ) {
343
- throw new VaultException ("Vault responded with HTTP status code: " + restResponse .getStatus (), restResponse .getStatus ());
345
+ throw new VaultException ("Vault responded with HTTP status code: " + restResponse .getStatus ()
346
+ + "\n Response body: " + new String (restResponse .getBody (), StandardCharsets .UTF_8 ),
347
+ restResponse .getStatus ());
344
348
}
345
349
final String mimeType = restResponse .getMimeType () == null ? "null" : restResponse .getMimeType ();
346
350
if (!mimeType .equals ("application/json" )) {
@@ -434,7 +438,9 @@ public AuthResponse loginByAppRole(final String path, final String roleId, final
434
438
435
439
// Validate restResponse
436
440
if (restResponse .getStatus () != 200 ) {
437
- throw new VaultException ("Vault responded with HTTP status code: " + restResponse .getStatus (), restResponse .getStatus ());
441
+ throw new VaultException ("Vault responded with HTTP status code: " + restResponse .getStatus ()
442
+ + "\n Response body: " + new String (restResponse .getBody (), StandardCharsets .UTF_8 ),
443
+ restResponse .getStatus ());
438
444
}
439
445
final String mimeType = restResponse .getMimeType () == null ? "null" : restResponse .getMimeType ();
440
446
if (!mimeType .equals ("application/json" )) {
@@ -517,7 +523,9 @@ public AuthResponse loginByUserPass(final String username, final String password
517
523
518
524
// Validate restResponse
519
525
if (restResponse .getStatus () != 200 ) {
520
- throw new VaultException ("Vault responded with HTTP status code: " + restResponse .getStatus (), restResponse .getStatus ());
526
+ throw new VaultException ("Vault responded with HTTP status code: " + restResponse .getStatus ()
527
+ + "\n Response body: " + new String (restResponse .getBody (), StandardCharsets .UTF_8 ),
528
+ restResponse .getStatus ());
521
529
}
522
530
final String mimeType = restResponse .getMimeType () == null ? "null" : restResponse .getMimeType ();
523
531
if (!mimeType .equals ("application/json" )) {
@@ -639,7 +647,9 @@ public AuthResponse loginByAwsEc2(final String role, final String identity, fina
639
647
640
648
// Validate restResponse
641
649
if (restResponse .getStatus () != 200 ) {
642
- throw new VaultException ("Vault responded with HTTP status code: " + restResponse .getStatus (), restResponse .getStatus ());
650
+ throw new VaultException ("Vault responded with HTTP status code: " + restResponse .getStatus ()
651
+ + "\n Response body: " + new String (restResponse .getBody (), StandardCharsets .UTF_8 ),
652
+ restResponse .getStatus ());
643
653
}
644
654
final String mimeType = restResponse .getMimeType () == null ? "null" : restResponse .getMimeType ();
645
655
if (!mimeType .equals ("application/json" )) {
@@ -715,7 +725,9 @@ public AuthResponse loginByAwsEc2(final String role, final String pkcs7, final S
715
725
716
726
// Validate restResponse
717
727
if (restResponse .getStatus () != 200 ) {
718
- throw new VaultException ("Vault responded with HTTP status code: " + restResponse .getStatus (), restResponse .getStatus ());
728
+ throw new VaultException ("Vault responded with HTTP status code: " + restResponse .getStatus ()
729
+ + "\n Response body: " + new String (restResponse .getBody (), StandardCharsets .UTF_8 ),
730
+ restResponse .getStatus ());
719
731
}
720
732
final String mimeType = restResponse .getMimeType () == null ? "null" : restResponse .getMimeType ();
721
733
if (!mimeType .equals ("application/json" )) {
@@ -794,7 +806,9 @@ public AuthResponse loginByAwsIam(final String role, final String iamRequestUrl,
794
806
795
807
// Validate restResponse
796
808
if (restResponse .getStatus () != 200 ) {
797
- throw new VaultException ("Vault responded with HTTP status code: " + restResponse .getStatus (), restResponse .getStatus ());
809
+ throw new VaultException ("Vault responded with HTTP status code: " + restResponse .getStatus ()
810
+ + "\n Response body: " + new String (restResponse .getBody (), StandardCharsets .UTF_8 ),
811
+ restResponse .getStatus ());
798
812
}
799
813
final String mimeType = restResponse .getMimeType () == null ? "null" : restResponse .getMimeType ();
800
814
if (!mimeType .equals ("application/json" )) {
@@ -879,7 +893,9 @@ public AuthResponse loginByGithub(final String githubToken, final String githubA
879
893
880
894
// Validate restResponse
881
895
if (restResponse .getStatus () != 200 ) {
882
- throw new VaultException ("Vault responded with HTTP status code: " + restResponse .getStatus (), restResponse .getStatus ());
896
+ throw new VaultException ("Vault responded with HTTP status code: " + restResponse .getStatus ()
897
+ + "\n Response body: " + new String (restResponse .getBody (), StandardCharsets .UTF_8 ),
898
+ restResponse .getStatus ());
883
899
}
884
900
final String mimeType = restResponse .getMimeType () == null ? "null" : restResponse .getMimeType ();
885
901
if (!mimeType .equals ("application/json" )) {
@@ -943,7 +959,9 @@ public AuthResponse loginByJwt(final String provider, final String role, final S
943
959
944
960
// Validate restResponse
945
961
if (restResponse .getStatus () != 200 ) {
946
- throw new VaultException ("Vault responded with HTTP status code: " + restResponse .getStatus (), restResponse .getStatus ());
962
+ throw new VaultException ("Vault responded with HTTP status code: " + restResponse .getStatus ()
963
+ + "\n Response body: " + new String (restResponse .getBody (), StandardCharsets .UTF_8 ),
964
+ restResponse .getStatus ());
947
965
}
948
966
final String mimeType = restResponse .getMimeType () == null ? "null" : restResponse .getMimeType ();
949
967
if (!mimeType .equals ("application/json" )) {
@@ -1082,7 +1100,8 @@ public AuthResponse loginByCert(final String certAuthMount) throws VaultExceptio
1082
1100
1083
1101
// Validate restResponse
1084
1102
if (restResponse .getStatus () != 200 ) {
1085
- throw new VaultException ("Vault responded with HTTP status code: " + restResponse .getStatus (),
1103
+ throw new VaultException ("Vault responded with HTTP status code: " + restResponse .getStatus ()
1104
+ + "\n Response body: " + new String (restResponse .getBody (), StandardCharsets .UTF_8 ),
1086
1105
restResponse .getStatus ());
1087
1106
}
1088
1107
final String mimeType = restResponse .getMimeType () == null ? "null" : restResponse .getMimeType ();
@@ -1165,7 +1184,9 @@ public AuthResponse renewSelf(final long increment, final String tokenAuthMount)
1165
1184
1166
1185
// Validate restResponse
1167
1186
if (restResponse .getStatus () != 200 ) {
1168
- throw new VaultException ("Vault responded with HTTP status code: " + restResponse .getStatus (), restResponse .getStatus ());
1187
+ throw new VaultException ("Vault responded with HTTP status code: " + restResponse .getStatus ()
1188
+ + "\n Response body: " + new String (restResponse .getBody (), StandardCharsets .UTF_8 ),
1189
+ restResponse .getStatus ());
1169
1190
}
1170
1191
final String mimeType = restResponse .getMimeType () == null ? "null" : restResponse .getMimeType ();
1171
1192
if (!mimeType .equals ("application/json" )) {
@@ -1227,7 +1248,9 @@ public LookupResponse lookupSelf(final String tokenAuthMount) throws VaultExcept
1227
1248
1228
1249
// Validate restResponse
1229
1250
if (restResponse .getStatus () != 200 ) {
1230
- throw new VaultException ("Vault responded with HTTP status code: " + restResponse .getStatus (), restResponse .getStatus ());
1251
+ throw new VaultException ("Vault responded with HTTP status code: " + restResponse .getStatus ()
1252
+ + "\n Response body: " + new String (restResponse .getBody (), StandardCharsets .UTF_8 ),
1253
+ restResponse .getStatus ());
1231
1254
}
1232
1255
final String mimeType = restResponse .getMimeType ();
1233
1256
if (!"application/json" .equals (mimeType )) {
@@ -1351,7 +1374,9 @@ public void revokeSelf(final String tokenAuthMount) throws VaultException {
1351
1374
1352
1375
// Validate restResponse
1353
1376
if (restResponse .getStatus () != 204 ) {
1354
- throw new VaultException ("Vault responded with HTTP status code: " + restResponse .getStatus (), restResponse .getStatus ());
1377
+ throw new VaultException ("Vault responded with HTTP status code: " + restResponse .getStatus ()
1378
+ + "\n Response body: " + new String (restResponse .getBody (), StandardCharsets .UTF_8 ),
1379
+ restResponse .getStatus ());
1355
1380
}
1356
1381
return ;
1357
1382
} catch (Exception e ) {
@@ -1453,7 +1478,8 @@ public AuthResponse unwrap(final String wrappedToken) throws VaultException {
1453
1478
1454
1479
// Validate restResponse
1455
1480
if (restResponse .getStatus () != 200 ) {
1456
- throw new VaultException ("Vault responded with HTTP status code: " + restResponse .getStatus (),
1481
+ throw new VaultException ("Vault responded with HTTP status code: " + restResponse .getStatus ()
1482
+ + "\n Response body: " + new String (restResponse .getBody (), StandardCharsets .UTF_8 ),
1457
1483
restResponse .getStatus ());
1458
1484
}
1459
1485
final String mimeType = restResponse .getMimeType () == null ? "null" : restResponse .getMimeType ();
0 commit comments