diff --git a/modules/swagger-codegen/src/main/resources/Java/libraries/resttemplate/auth/HttpBasicAuth.mustache b/modules/swagger-codegen/src/main/resources/Java/libraries/resttemplate/auth/HttpBasicAuth.mustache index 5f535b3698a..b0bde6fff65 100644 --- a/modules/swagger-codegen/src/main/resources/Java/libraries/resttemplate/auth/HttpBasicAuth.mustache +++ b/modules/swagger-codegen/src/main/resources/Java/libraries/resttemplate/auth/HttpBasicAuth.mustache @@ -4,7 +4,7 @@ import java.io.UnsupportedEncodingException; import java.nio.charset.StandardCharsets; import org.springframework.http.HttpHeaders; -import org.springframework.util.Base64Utils; +import java.util.Base64; import org.springframework.util.MultiValueMap; {{>generatedAnnotation}} @@ -34,6 +34,6 @@ public class HttpBasicAuth implements Authentication { return; } String str = (username == null ? "" : username) + ":" + (password == null ? "" : password); - headerParams.add(HttpHeaders.AUTHORIZATION, "Basic " + Base64Utils.encodeToString(str.getBytes(StandardCharsets.UTF_8))); + headerParams.add(HttpHeaders.AUTHORIZATION, "Basic " + Base64.getEncoder().encodeToString(str.getBytes(StandardCharsets.UTF_8))); } }