Skip to content

Commit db77297

Browse files
committed
update charset class
1 parent 1b8a00e commit db77297

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

httpclient/src/test/java/org/baeldung/httpclient/sec/HttpClientAuthLiveTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import java.io.IOException;
2626
import java.nio.charset.Charset;
27+
import java.nio.charset.StandardCharsets;
2728

2829
import static org.hamcrest.Matchers.equalTo;
2930
import static org.junit.Assert.assertThat;
@@ -89,7 +90,7 @@ public final void givenAuthorizationHeaderIsSetManually_whenExecutingGetRequest_
8990
public final void givenAuthorizationHeaderIsSetManually_whenExecutingGetRequest_thenSuccess2() throws IOException {
9091
final HttpGet request = new HttpGet(URL_SECURED_BY_BASIC_AUTHENTICATION);
9192
final String auth = DEFAULT_USER + ":" + DEFAULT_PASS;
92-
final byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(Charset.forName("ISO-8859-1")));
93+
final byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.ISO_8859_1));
9394
final String authHeader = "Basic " + new String(encodedAuth);
9495
request.setHeader(HttpHeaders.AUTHORIZATION, authHeader);
9596

@@ -129,7 +130,7 @@ private HttpContext context() {
129130

130131
private String authorizationHeader(final String username, final String password) {
131132
final String auth = username + ":" + password;
132-
final byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(Charset.forName("ISO-8859-1")));
133+
final byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.ISO_8859_1));
133134

134135
return "Basic " + new String(encodedAuth);
135136
}

0 commit comments

Comments
 (0)