Changeset 32702 in osm for applications/editors/josm/plugins/sds/src/org
- Timestamp:
- 2016-07-23T23:24:19+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/sds/src/org/openstreetmap/hot/sds/SdsConnection.java
r30738 r32702 4 4 import java.net.Authenticator.RequestorType; 5 5 import java.net.HttpURLConnection; 6 import java.nio.ByteBuffer; 7 import java.nio.CharBuffer; 8 import java.nio.charset.CharacterCodingException; 9 import java.nio.charset.Charset; 10 import java.nio.charset.CharsetEncoder; 6 import java.nio.charset.StandardCharsets; 7 import java.util.Base64; 11 8 12 9 import org.openstreetmap.josm.io.auth.CredentialsAgentException; 13 10 import org.openstreetmap.josm.io.auth.CredentialsAgentResponse; 14 import org.openstreetmap.josm.tools.Base64;15 11 16 12 /** … … 64 60 */ 65 61 protected void addBasicAuthorizationHeader(HttpURLConnection con) throws SdsTransferException { 66 CharsetEncoder encoder = Charset.forName("UTF-8").newEncoder();67 62 CredentialsAgentResponse response; 68 63 String token; 69 64 try { 70 65 response = credAgent.getCredentials(RequestorType.SERVER, con.getURL().getHost(), false /* don't know yet whether the credentials will succeed */); 71 66 } catch (CredentialsAgentException e) { 72 67 throw new SdsTransferException(e); … … 81 76 String password = response.getPassword() == null ? "" : String.valueOf(response.getPassword()); 82 77 token = username + ":" + password; 83 try { 84 ByteBuffer bytes = encoder.encode(CharBuffer.wrap(token)); 85 con.addRequestProperty("Authorization", "Basic "+Base64.encode(bytes)); 86 } catch(CharacterCodingException e) { 87 throw new SdsTransferException(e); 88 } 78 con.addRequestProperty("Authorization", "Basic "+Base64.getEncoder().encodeToString(token.getBytes(StandardCharsets.UTF_8))); 89 79 } 90 80 }
Note:
See TracChangeset
for help on using the changeset viewer.