Changeset 10618 in josm for trunk


Ignore:
Timestamp:
2016-07-23T23:54:27+02:00 (8 years ago)
Author:
Don-vip
Message:

see #11390 - Java 8: use java.util.Base64

Location:
trunk/src/org/openstreetmap/josm
Files:
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/OsmConnection.java

    r10615 r10618  
    88import java.net.MalformedURLException;
    99import java.net.URL;
    10 import java.nio.ByteBuffer;
    11 import java.nio.CharBuffer;
    12 import java.nio.charset.CharacterCodingException;
    1310import java.nio.charset.StandardCharsets;
     11import java.util.Base64;
    1412import java.util.Objects;
    1513import java.util.concurrent.FutureTask;
     
    2422import org.openstreetmap.josm.io.auth.CredentialsAgentResponse;
    2523import org.openstreetmap.josm.io.auth.CredentialsManager;
    26 import org.openstreetmap.josm.tools.Base64;
    2724import org.openstreetmap.josm.tools.HttpClient;
    2825import org.openstreetmap.josm.tools.Utils;
     
    8077            String password = response.getPassword() == null ? "" : String.valueOf(response.getPassword());
    8178            token = username + ':' + password;
    82             try {
    83                 ByteBuffer bytes = StandardCharsets.UTF_8.newEncoder().encode(CharBuffer.wrap(token));
    84                 con.setHeader("Authorization", "Basic "+Base64.encode(bytes));
    85             } catch (CharacterCodingException e) {
    86                 throw new OsmTransferException(e);
    87             }
     79            con.setHeader("Authorization", "Basic "+Base64.getEncoder().encodeToString(token.getBytes(StandardCharsets.UTF_8)));
    8880        }
    8981    }
  • trunk/src/org/openstreetmap/josm/tools/bugreport/BugReportSender.java

    r10616 r10618  
    1010import java.net.URL;
    1111import java.net.URLEncoder;
    12 import java.nio.ByteBuffer;
    13 import java.nio.CharBuffer;
    14 import java.nio.charset.Charset;
    1512import java.nio.charset.StandardCharsets;
     13import java.util.Base64;
    1614
    1715import javax.swing.JOptionPane;
     
    2725import org.openstreetmap.josm.gui.widgets.JMultilineLabel;
    2826import org.openstreetmap.josm.gui.widgets.UrlLabel;
    29 import org.openstreetmap.josm.tools.Base64;
    3027import org.openstreetmap.josm.tools.GBC;
    3128import org.openstreetmap.josm.tools.HttpClient;
     
    8481        try {
    8582            String text = Utils.strip(statusText);
    86             ByteBuffer buffer = Charset.forName("UTF-8").encode(CharBuffer.wrap(text));
    87             String pdata = Base64.encode(buffer, false);
     83            String pdata = Base64.getEncoder().encodeToString(text.getBytes(StandardCharsets.UTF_8));
    8884            String postQuery = "pdata=" + URLEncoder.encode(pdata, "UTF-8");
    8985            HttpClient client = HttpClient.create(new URL(getJOSMTicketURL()), "POST")
Note: See TracChangeset for help on using the changeset viewer.