JAVA-20555 use Java Base64 instead of deprecated Spring Base64Utils (#13941)
This commit is contained in:
committed by
GitHub
parent
2518992634
commit
de11e3cb6c
@@ -1,9 +1,9 @@
|
||||
package com.baeldung.petstore.client.invoker.auth;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Base64;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.util.Base64Utils;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2020-03-15T06:14:01.568992-05:00[America/Chicago]")
|
||||
@@ -33,6 +33,7 @@ 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)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package com.baeldung.petstore.client.invoker.auth;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Base64;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.util.Base64Utils;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
@javax.annotation.Generated(value = "io.swagger.codegen.languages.JavaClientCodegen", date = "2017-08-29T12:04:37.072+02:00")
|
||||
@@ -34,6 +33,7 @@ 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)));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user