|
52 | 52 | import java.net.URI; |
53 | 53 | import java.net.URISyntaxException; |
54 | 54 | import java.net.URL; |
| 55 | +import java.nio.charset.StandardCharsets; |
55 | 56 | import java.nio.file.Files; |
56 | 57 | import java.nio.file.Paths; |
57 | 58 | import java.security.GeneralSecurityException; |
@@ -467,9 +468,7 @@ static UserCredentials getCredentialsFromCode( |
467 | 468 | LOG.finer("++enter++\t" + callerClassName); |
468 | 469 | UserCredentials credentials = userAuthorizer.getCredentialsFromCode(code, URI.create("")); |
469 | 470 | if (httpTransportFactory != null) { |
470 | | - credentials = |
471 | | - (UserCredentials) |
472 | | - credentials.toBuilder().setHttpTransportFactory(httpTransportFactory).build(); |
| 471 | + credentials = credentials.toBuilder().setHttpTransportFactory(httpTransportFactory).build(); |
473 | 472 | } |
474 | 473 | return credentials; |
475 | 474 | } |
@@ -665,16 +664,13 @@ private static GoogleCredentials getExternalAccountAuthCredentials( |
665 | 664 | ExternalAccountCredentials credentials; |
666 | 665 | if (credentialsPath != null) { |
667 | 666 | try (InputStream stream = Files.newInputStream(Paths.get(credentialsPath))) { |
668 | | - credentials = |
669 | | - (ExternalAccountCredentials) |
670 | | - ExternalAccountCredentials.fromStream(stream, httpTransportFactory); |
| 667 | + credentials = ExternalAccountCredentials.fromStream(stream, httpTransportFactory); |
671 | 668 | } |
672 | 669 | } else if (jsonObject != null) { |
673 | 670 | credentials = |
674 | | - (ExternalAccountCredentials) |
675 | | - ExternalAccountCredentials.fromStream( |
676 | | - new ByteArrayInputStream(jsonObject.toString().getBytes()), |
677 | | - httpTransportFactory); |
| 671 | + ExternalAccountCredentials.fromStream( |
| 672 | + new ByteArrayInputStream(jsonObject.toString().getBytes(StandardCharsets.UTF_8)), |
| 673 | + httpTransportFactory); |
678 | 674 | } else { |
679 | 675 | IllegalArgumentException ex = |
680 | 676 | new IllegalArgumentException("Insufficient info provided for external authentication"); |
|
0 commit comments