source:
josm/trunk/patches/base64.patch@
13657
Last change on this file since 13657 was 8149, checked in by , 9 years ago | |
---|---|
File size: 4.8 KB |
-
src/com/kitfox/svg/SVGUniverse.java
From f44a63833a45ee8f67589334f56549a5d7b72fa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Sch=C3=A4fer?= <florian@schaeferban.de> Date: Sun, 22 Mar 2015 17:39:38 +0100 Subject: [PATCH] Use Base64-decoder from JAXB instead of Apache/Sun This removes the dependeny on Apache Commons Codec, which was solely used for Base64 decoding. Uses of both org.apache.commons.codec.binary.Base64 and sun.misc.BASE64Decoder are replaced by javax.xml.bind.DatatypeConverter which is part of Java since 1.6. --- src/com/kitfox/svg/SVGUniverse.java | 7 ++++--- src/com/kitfox/svg/app/data/Handler.java | 7 ++++--- src/oauth/signpost/signature/OAuthMessageSigner.java | 13 +++---------- src/org/openstreetmap/josm/tools/ImageProvider.java | 4 ++-- 4 files changed, 13 insertions(+), 18 deletions(-) diff --git a/src/com/kitfox/svg/SVGUniverse.java b/src/com/kitfox/svg/SVGUniverse.java index 9c244dd..1fe4a3d 100644
a b 61 61 import java.util.logging.Logger; 62 62 import java.util.zip.GZIPInputStream; 63 63 import javax.imageio.ImageIO; 64 import javax.xml.bind.DatatypeConverter; 64 65 import org.xml.sax.EntityResolver; 65 66 import org.xml.sax.InputSource; 66 67 import org.xml.sax.SAXException; … … URL registerImage(URI imageURI) 190 191 191 192 if (content.startsWith("base64")) 192 193 { 193 content = content.substring(6);194 194 try 195 195 { 196 byte[] buf = new sun.misc.BASE64Decoder().decodeBuffer(content);196 byte[] buf = DatatypeConverter.parseBase64Binary(content.substring(6)); 197 197 ByteArrayInputStream bais = new ByteArrayInputStream(buf); 198 198 BufferedImage img = ImageIO.read(bais); 199 199 … … URL registerImage(URI imageURI) 213 213 loadedImages.put(url, ref); 214 214 215 215 return url; 216 } catch (IOException ex) 216 } 217 catch (IOException | IllegalArgumentException ex) 217 218 { 218 219 Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, 219 220 "Could not decode inline image", ex); -
src/com/kitfox/svg/app/data/Handler.java
diff --git a/src/com/kitfox/svg/app/data/Handler.java b/src/com/kitfox/svg/app/data/Handler.java index 806dcd9..e35c260 100644
a b 44 44 import java.util.logging.Level; 45 45 import java.util.logging.Logger; 46 46 47 import javax.xml.bind.DatatypeConverter; 48 47 49 /** 48 50 * 49 51 * @author kitfox … … public Connection(URL url) 66 68 67 69 if (content.startsWith("base64,")) 68 70 { 69 content = content.substring(7);70 71 try 71 72 { 72 buf = new sun.misc.BASE64Decoder().decodeBuffer(content);73 buf = DatatypeConverter.parseBase64Binary(content.substring(7)); 73 74 } 74 catch (I OException e)75 catch (IllegalArgumentException e) 75 76 { 76 77 Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING, null, e); 77 78 } -
src/oauth/signpost/signature/OAuthMessageSigner.java
diff --git a/src/oauth/signpost/signature/OAuthMessageSigner.java b/src/oauth/signpost/signature/OAuthMessageSigner.java index 8d878ae..e24092d 100644
a b 16 16 17 17 import java.io.IOException; 18 18 import java.io.Serializable; 19 import javax.xml.bind.DatatypeConverter; 19 20 20 21 import oauth.signpost.exception.OAuthMessageSignerException; 21 22 import oauth.signpost.http.HttpRequest; 22 23 import oauth.signpost.http.HttpParameters; 23 24 24 import org.apache.commons.codec.binary.Base64;25 26 25 public abstract class OAuthMessageSigner implements Serializable { 27 26 28 27 private static final long serialVersionUID = 4445779788786131202L; 29 28 30 private transient Base64 base64;31 32 29 private String consumerSecret; 33 30 34 31 private String tokenSecret; 35 32 36 public OAuthMessageSigner() {37 this.base64 = new Base64();38 }39 33 40 34 public abstract String sign(HttpRequest request, HttpParameters requestParameters) 41 35 throws OAuthMessageSignerException; … … public void setTokenSecret(String tokenSecret) { 59 53 } 60 54 61 55 protected byte[] decodeBase64(String s) { 62 return base64.decode(s.getBytes());56 return DatatypeConverter.parseBase64Binary(s); 63 57 } 64 58 65 59 protected String base64Encode(byte[] b) { 66 return new String(base64.encode(b));60 return DatatypeConverter.printBase64Binary(b); 67 61 } 68 62 69 63 private void readObject(java.io.ObjectInputStream stream) 70 64 throws IOException, ClassNotFoundException { 71 65 stream.defaultReadObject(); 72 this.base64 = new Base64();73 66 } 74 67 }
Note:
See TracBrowser
for help on using the repository browser.