Skip to content

Commit

Permalink
secureCodeBox#121 Give Method Better Name Since it is Not a Simple Ge…
Browse files Browse the repository at this point in the history
…tter

Signed-off-by: Sven Strittmatter <[email protected]>
  • Loading branch information
Weltraumschaf committed Jul 3, 2024
1 parent e00225a commit 9fb2b5e
Showing 1 changed file with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public GenericDefectDojoService(@NonNull ClientConfig clientConfig, @NonNull Pro
@Override
public final T get(long id) {
final var restTemplate = this.getRestTemplate();
final HttpEntity<String> payload = new HttpEntity<>(getDefectDojoAuthorizationHeaders());
final HttpEntity<String> payload = new HttpEntity<>(createAuthorizationHeaders());

final var url = createBaseUrl().resolve(String.valueOf(id));
log.debug("Requesting URL: {}", url);
Expand Down Expand Up @@ -150,7 +150,7 @@ public final Optional<T> searchUnique(@NonNull Map<String, Object> queryParams)
@Override
public final T create(@NonNull T object) {
final var restTemplate = this.getRestTemplate();
final HttpEntity<T> payload = new HttpEntity<>(object, getDefectDojoAuthorizationHeaders());
final HttpEntity<T> payload = new HttpEntity<>(object, createAuthorizationHeaders());
final ResponseEntity<T> response = restTemplate.exchange(createBaseUrl(), HttpMethod.POST, payload, getModelClass());

return response.getBody();
Expand All @@ -159,7 +159,7 @@ public final T create(@NonNull T object) {
@Override
public final void delete(long id) {
final var restTemplate = this.getRestTemplate();
final HttpEntity<String> payload = new HttpEntity<>(getDefectDojoAuthorizationHeaders());
final HttpEntity<String> payload = new HttpEntity<>(createAuthorizationHeaders());

final var url = createBaseUrl().resolve(id + "/");
restTemplate.exchange(url, HttpMethod.DELETE, payload, String.class);
Expand All @@ -168,7 +168,7 @@ public final void delete(long id) {
@Override
public final T update(@NonNull T object, long id) {
final var restTemplate = this.getRestTemplate();
final HttpEntity<T> payload = new HttpEntity<>(object, getDefectDojoAuthorizationHeaders());
final HttpEntity<T> payload = new HttpEntity<>(object, createAuthorizationHeaders());
final var url = createBaseUrl().resolve(id + "/");
final ResponseEntity<T> response = restTemplate.exchange(url, HttpMethod.PUT, payload, getModelClass());

Expand Down Expand Up @@ -206,10 +206,7 @@ final URI createBaseUrl() {
return URI.create(buffer).normalize();
}

/**
* @return The DefectDojo Authentication Header
*/
private HttpHeaders getDefectDojoAuthorizationHeaders() {
private HttpHeaders createAuthorizationHeaders() {
final var factory = new AuthHeaderFactory(clientConfig);
factory.setProxyConfig(proxyConfig);
return factory.generateAuthorizationHeaders();
Expand All @@ -230,7 +227,7 @@ private RestTemplate setupRestTemplate() {

protected PaginatedResult<T> internalSearch(Map<String, Object> queryParams, long limit, long offset) {
final var restTemplate = this.getRestTemplate();
final HttpEntity<String> payload = new HttpEntity<>(getDefectDojoAuthorizationHeaders());
final HttpEntity<String> payload = new HttpEntity<>(createAuthorizationHeaders());

final var mutableQueryParams = new HashMap<>(queryParams);
mutableQueryParams.put("limit", String.valueOf(limit));
Expand Down

0 comments on commit 9fb2b5e

Please sign in to comment.