|
11 | 11 | import io.github.jopenlibs.vault.response.LookupResponse; |
12 | 12 | import io.github.jopenlibs.vault.response.UnwrapResponse; |
13 | 13 | import io.github.jopenlibs.vault.response.WrapResponse; |
14 | | -import io.github.jopenlibs.vault.rest.Rest; |
15 | 14 | import io.github.jopenlibs.vault.rest.RestResponse; |
16 | 15 | import java.io.Serializable; |
17 | 16 | import java.nio.charset.StandardCharsets; |
@@ -376,7 +375,7 @@ public AuthResponse createToken(final TokenRequest tokenRequest, final String to |
376 | 375 | final String url = urlBuilder.toString(); |
377 | 376 |
|
378 | 377 | // HTTP request to Vault |
379 | | - final RestResponse restResponse = new Rest()//NOPMD |
| 378 | + final RestResponse restResponse = getRest()//NOPMD |
380 | 379 | .url(url) |
381 | 380 | .header("X-Vault-Token", config.getToken()) |
382 | 381 | .header("X-Vault-Namespace", this.nameSpace) |
@@ -437,7 +436,7 @@ public AuthResponse loginByAppID(final String path, final String appId, final St |
437 | 436 | // HTTP request to Vault |
438 | 437 | final String requestJson = Json.object().add("app_id", appId).add("user_id", userId) |
439 | 438 | .toString(); |
440 | | - final RestResponse restResponse = new Rest()//NOPMD |
| 439 | + final RestResponse restResponse = getRest()//NOPMD |
441 | 440 | .url(config.getAddress() + "/v1/auth/" + path) |
442 | 441 | .header("X-Vault-Namespace", this.nameSpace) |
443 | 442 | .body(requestJson.getBytes(StandardCharsets.UTF_8)) |
@@ -525,7 +524,7 @@ public AuthResponse loginByAppRole(final String path, final String roleId, |
525 | 524 | // HTTP request to Vault |
526 | 525 | final String requestJson = Json.object().add("role_id", roleId) |
527 | 526 | .add("secret_id", secretId).toString(); |
528 | | - final RestResponse restResponse = new Rest()//NOPMD |
| 527 | + final RestResponse restResponse = getRest()//NOPMD |
529 | 528 | .url(config.getAddress() + "/v1/auth/" + path + "/login") |
530 | 529 | .header("X-Vault-Namespace", this.nameSpace) |
531 | 530 | .header("X-Vault-Request", "true") |
@@ -602,7 +601,7 @@ public AuthResponse loginByUserPass(final String username, final String password |
602 | 601 | return retry(attempt -> { |
603 | 602 | // HTTP request to Vault |
604 | 603 | final String requestJson = Json.object().add("password", password).toString(); |
605 | | - final RestResponse restResponse = new Rest()//NOPMD |
| 604 | + final RestResponse restResponse = getRest()//NOPMD |
606 | 605 | .url(config.getAddress() + "/v1/auth/" + mount + "/login/" + username) |
607 | 606 | .header("X-Vault-Namespace", this.nameSpace) |
608 | 607 | .header("X-Vault-Request", "true") |
@@ -721,7 +720,7 @@ public AuthResponse loginByAwsEc2(final String role, final String identity, |
721 | 720 | } |
722 | 721 | final String requestJson = request.toString(); |
723 | 722 |
|
724 | | - final RestResponse restResponse = new Rest()//NOPMD |
| 723 | + final RestResponse restResponse = getRest()//NOPMD |
725 | 724 | .url(config.getAddress() + "/v1/auth/" + mount + "/login") |
726 | 725 | .body(requestJson.getBytes(StandardCharsets.UTF_8)) |
727 | 726 | .header("X-Vault-Namespace", this.nameSpace) |
@@ -789,7 +788,7 @@ public AuthResponse loginByAwsEc2(final String role, final String pkcs7, final S |
789 | 788 | request.add("nonce", nonce); |
790 | 789 | } |
791 | 790 | final String requestJson = request.toString(); |
792 | | - final RestResponse restResponse = new Rest()//NOPMD |
| 791 | + final RestResponse restResponse = getRest()//NOPMD |
793 | 792 | .url(config.getAddress() + "/v1/auth/" + mount + "/login") |
794 | 793 | .header("X-Vault-Namespace", this.nameSpace) |
795 | 794 | .header("X-Vault-Request", "true") |
@@ -866,7 +865,7 @@ public AuthResponse loginByAwsIam(final String role, final String iamRequestUrl, |
866 | 865 | request.add("role", role); |
867 | 866 | } |
868 | 867 | final String requestJson = request.toString(); |
869 | | - final RestResponse restResponse = new Rest()//NOPMD |
| 868 | + final RestResponse restResponse = getRest()//NOPMD |
870 | 869 | .url(config.getAddress() + "/v1/auth/" + mount + "/login") |
871 | 870 | .header("X-Vault-Namespace", this.nameSpace) |
872 | 871 | .header("X-Vault-Request", "true") |
@@ -939,7 +938,7 @@ public AuthResponse loginByGithub(final String githubToken, final String githubA |
939 | 938 | return retry(attempt -> { |
940 | 939 | // HTTP request to Vault |
941 | 940 | final String requestJson = Json.object().add("token", githubToken).toString(); |
942 | | - final RestResponse restResponse = new Rest()//NOPMD |
| 941 | + final RestResponse restResponse = getRest()//NOPMD |
943 | 942 | .url(config.getAddress() + "/v1/auth/" + mount + "/login") |
944 | 943 | .header("X-Vault-Namespace", this.nameSpace) |
945 | 944 | .header("X-Vault-Request", "true") |
@@ -1020,7 +1019,7 @@ public AuthResponse loginByJwt(final String provider, final String role, final S |
1020 | 1019 | // HTTP request to Vault |
1021 | 1020 | final String requestJson = Json.object().add("role", role).add("jwt", jwt) |
1022 | 1021 | .toString(); |
1023 | | - final RestResponse restResponse = new Rest() |
| 1022 | + final RestResponse restResponse = getRest() |
1024 | 1023 | .url(config.getAddress() + "/v1/" + authPath + "/login") |
1025 | 1024 | .header("X-Vault-Namespace", this.nameSpace) |
1026 | 1025 | .header("X-Vault-Request", "true") |
@@ -1179,7 +1178,7 @@ public AuthResponse loginByCert(final String certAuthMount) throws VaultExceptio |
1179 | 1178 | final String mount = certAuthMount != null ? certAuthMount : "cert"; |
1180 | 1179 |
|
1181 | 1180 | return retry(attempt -> { |
1182 | | - final RestResponse restResponse = new Rest()//NOPMD |
| 1181 | + final RestResponse restResponse = getRest()//NOPMD |
1183 | 1182 | .url(config.getAddress() + "/v1/auth/" + mount + "/login") |
1184 | 1183 | .header("X-Vault-Namespace", this.nameSpace) |
1185 | 1184 | .header("X-Vault-Request", "true") |
@@ -1251,7 +1250,7 @@ public AuthResponse renewSelf(final long increment, final String tokenAuthMount) |
1251 | 1250 | return retry(attempt -> { |
1252 | 1251 | // HTTP request to Vault |
1253 | 1252 | final String requestJson = Json.object().add("increment", increment).toString(); |
1254 | | - final RestResponse restResponse = new Rest()//NOPMD |
| 1253 | + final RestResponse restResponse = getRest()//NOPMD |
1255 | 1254 | .url(config.getAddress() + "/v1/auth/" + mount + "/renew-self") |
1256 | 1255 | .header("X-Vault-Token", config.getToken()) |
1257 | 1256 | .header("X-Vault-Namespace", this.nameSpace) |
@@ -1307,7 +1306,7 @@ public LookupResponse lookupSelf(final String tokenAuthMount) throws VaultExcept |
1307 | 1306 |
|
1308 | 1307 | return retry(attempt -> { |
1309 | 1308 | // HTTP request to Vault |
1310 | | - final RestResponse restResponse = new Rest()//NOPMD |
| 1309 | + final RestResponse restResponse = getRest()//NOPMD |
1311 | 1310 | .url(config.getAddress() + "/v1/auth/" + mount + "/lookup-self") |
1312 | 1311 | .header("X-Vault-Token", config.getToken()) |
1313 | 1312 | .header("X-Vault-Namespace", this.nameSpace) |
@@ -1384,7 +1383,7 @@ public void revokeSelf(final String tokenAuthMount) throws VaultException { |
1384 | 1383 |
|
1385 | 1384 | retry(attempt -> { |
1386 | 1385 | // HTTP request to Vault |
1387 | | - final RestResponse restResponse = new Rest()//NOPMD |
| 1386 | + final RestResponse restResponse = getRest()//NOPMD |
1388 | 1387 | .url(config.getAddress() + "/v1/auth/" + mount + "/revoke-self") |
1389 | 1388 | .header("X-Vault-Token", config.getToken()) |
1390 | 1389 | .header("X-Vault-Namespace", this.nameSpace) |
|
0 commit comments