Repository: qpid-broker-j Updated Branches: refs/heads/master b770054f4 -> c8c820330
http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/c8c82033/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/ServletConnectionPrincipal.java ---------------------------------------------------------------------- diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/ServletConnectionPrincipal.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/ServletConnectionPrincipal.java index 6d442a8..543e7df 100644 --- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/ServletConnectionPrincipal.java +++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/ServletConnectionPrincipal.java @@ -26,10 +26,10 @@ import java.net.SocketAddress; import java.nio.charset.StandardCharsets; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; +import java.util.Base64; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; -import javax.xml.bind.DatatypeConverter; import org.apache.qpid.server.management.plugin.HttpManagementUtil; import org.apache.qpid.server.model.Port; @@ -66,7 +66,7 @@ public class ServletConnectionPrincipal implements ManagementConnectionPrincipal throw new RuntimeException("Cannot create SHA-256 hash", e); } byte[] digest = md.digest(); - _sessionId = DatatypeConverter.printBase64Binary(digest).substring(0, HASH_TRUNCATION_LENGTH); + _sessionId = Base64.getEncoder().encodeToString(digest).substring(0, HASH_TRUNCATION_LENGTH); } else { http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/c8c82033/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/query/ConfiguredObjectExpressionFactory.java ---------------------------------------------------------------------- diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/query/ConfiguredObjectExpressionFactory.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/query/ConfiguredObjectExpressionFactory.java index 85e3a34..de8eb5a 100644 --- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/query/ConfiguredObjectExpressionFactory.java +++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/query/ConfiguredObjectExpressionFactory.java @@ -20,6 +20,18 @@ */ package org.apache.qpid.server.management.plugin.servlet.query; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.ZoneId; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.time.chrono.IsoChronology; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeFormatterBuilder; +import java.time.format.DateTimeParseException; +import java.time.temporal.ChronoField; +import java.time.temporal.TemporalAccessor; import java.util.Arrays; import java.util.Calendar; import java.util.Collection; @@ -31,7 +43,6 @@ import java.util.Map; import java.util.Set; import java.util.TimeZone; -import javax.xml.bind.DatatypeConverter; import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.DatatypeFactory; import javax.xml.datatype.Duration; @@ -48,6 +59,22 @@ public class ConfiguredObjectExpressionFactory private static final TimeZone UTC = TimeZone.getTimeZone("UTC"); private static final DatatypeFactory DATATYPE_FACTORY; + private static final DateTimeFormatter ISO_DATE_TIME_FORMAT = new DateTimeFormatterBuilder() + .parseCaseInsensitive() + .append(DateTimeFormatter.ISO_LOCAL_DATE) + .optionalStart() + .appendLiteral('T') + .append(DateTimeFormatter.ISO_LOCAL_TIME) + .optionalStart() + .appendOffsetId() + .optionalStart() + .appendLiteral('[') + .parseCaseSensitive() + .appendZoneRegionId() + .appendLiteral(']') + .toFormatter() + .withChronology(IsoChronology.INSTANCE); + static { try @@ -122,13 +149,28 @@ public class ConfiguredObjectExpressionFactory } try { - final Calendar calendar = DatatypeConverter.parseDateTime((String) dateTime); - return calendar.getTime(); + + return DateTimeFormatter.ISO_ZONED_DATE_TIME.parse((String)dateTime) + .query(this::convertToDate); } - catch (IllegalArgumentException e) + catch (DateTimeParseException e1) + { + throw new IllegalArgumentException(TO_DATE + + " requires an ISO-8601 format date or date/time.", + e1); + } + + } + + private Date convertToDate(TemporalAccessor t) + { + if(!t.isSupported(ChronoField.INSTANT_SECONDS)) { - throw new IllegalArgumentException(TO_DATE + " requires an ISO-8601 format date or date/time.", e); + t = LocalDateTime.of(LocalDate.from(t), LocalTime.MIN).atOffset(ZoneOffset.UTC); } + return new Date((t.getLong(ChronoField.INSTANT_SECONDS) * 1000L) + + t.getLong(ChronoField.MILLI_OF_SECOND)); + } }; } @@ -199,7 +241,7 @@ public class ConfiguredObjectExpressionFactory cal.setTime((Date) obj); if (format == null) { - return DatatypeConverter.printDateTime(cal); + return DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(cal.toInstant().atZone(ZoneId.of(timezoneName == null ? "UTC" : (String)timezoneName))); } else { http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/c8c82033/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/SaslServlet.java ---------------------------------------------------------------------- diff --git a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/SaslServlet.java b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/SaslServlet.java index 8d10ec4..102062d 100644 --- a/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/SaslServlet.java +++ b/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/SaslServlet.java @@ -24,6 +24,7 @@ import java.io.IOException; import java.security.AccessController; import java.security.Principal; import java.security.SecureRandom; +import java.util.Base64; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -34,7 +35,6 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; -import javax.xml.bind.DatatypeConverter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -254,7 +254,7 @@ public class SaslServlet extends AbstractServlet HttpManagementUtil.saveAuthorisedSubject(request, subject); if(challenge != null && challenge.length != 0) { - outputObject.put("additionalData", DatatypeConverter.printBase64Binary(challenge)); + outputObject.put("additionalData", Base64.getEncoder().encodeToString(challenge)); } responseStatus = HttpServletResponse.SC_OK; } @@ -279,7 +279,7 @@ public class SaslServlet extends AbstractServlet session, request); outputObject.put("id", id); - outputObject.put("challenge", DatatypeConverter.printBase64Binary(challenge)); + outputObject.put("challenge", Base64.getEncoder().encodeToString(challenge)); responseStatus = HttpServletResponse.SC_OK; } else http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/c8c82033/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/GunzipOutputStreamTest.java ---------------------------------------------------------------------- diff --git a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/GunzipOutputStreamTest.java b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/GunzipOutputStreamTest.java index 3711d1c..6a6301e 100644 --- a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/GunzipOutputStreamTest.java +++ b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/GunzipOutputStreamTest.java @@ -25,8 +25,7 @@ import static org.junit.Assert.assertEquals; import java.io.ByteArrayOutputStream; import java.nio.ByteBuffer; - -import javax.xml.bind.DatatypeConverter; +import java.util.Base64; import org.junit.Test; @@ -64,7 +63,7 @@ public class GunzipOutputStreamTest extends UnitTestBase @Test public void testDecompressingWithEmbeddedFileName() throws Exception { - byte[] data = DatatypeConverter.parseBase64Binary(GZIP_CONTENT_WITH_EMBEDDED_FILE_NAME); + byte[] data = Base64.getDecoder().decode(GZIP_CONTENT_WITH_EMBEDDED_FILE_NAME); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); GunzipOutputStream guos = new GunzipOutputStream(outputStream); @@ -77,7 +76,7 @@ public class GunzipOutputStreamTest extends UnitTestBase @Test public void testDecompressingMultipleMembers() throws Exception { - byte[] data = DatatypeConverter.parseBase64Binary(GZIP_CONTENT_WITH_MULTIPLE_MEMBERS); + byte[] data = Base64.getDecoder().decode(GZIP_CONTENT_WITH_MULTIPLE_MEMBERS); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); GunzipOutputStream guos = new GunzipOutputStream(outputStream); http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/c8c82033/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/query/ConfiguredObjectQueryTest.java ---------------------------------------------------------------------- diff --git a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/query/ConfiguredObjectQueryTest.java b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/query/ConfiguredObjectQueryTest.java index 670bad8..a0a56d0 100644 --- a/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/query/ConfiguredObjectQueryTest.java +++ b/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/query/ConfiguredObjectQueryTest.java @@ -25,8 +25,13 @@ import static org.junit.Assert.fail; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; import java.util.ArrayList; -import java.util.Calendar; import java.util.Collections; import java.util.Date; import java.util.HashMap; @@ -36,8 +41,6 @@ import java.util.Map; import java.util.UUID; import java.util.concurrent.TimeUnit; -import javax.xml.bind.DatatypeConverter; - import com.google.common.collect.Lists; import com.google.common.collect.Maps; import org.junit.Test; @@ -316,9 +319,9 @@ public class ConfiguredObjectQueryTest extends UnitTestBase public void testQuery_DateEquality() { final long now = System.currentTimeMillis(); - final Calendar calendar = Calendar.getInstance(); - calendar.setTimeInMillis(now); - String nowIso8601Str = DatatypeConverter.printDateTime(calendar); + + final ZonedDateTime zonedDateTime = Instant.ofEpochMilli(now).atZone(ZoneId.systemDefault()); + String nowIso8601Str = DateTimeFormatter.ISO_ZONED_DATE_TIME.format(zonedDateTime); final UUID objectUuid = UUID.randomUUID(); http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/c8c82033/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/client/MessageVerifier.java ---------------------------------------------------------------------- diff --git a/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/client/MessageVerifier.java b/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/client/MessageVerifier.java index 45f4abc..4f9183b 100644 --- a/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/client/MessageVerifier.java +++ b/systests/end-to-end-conversion-tests/src/main/java/org/apache/qpid/systests/end_to_end_conversion/client/MessageVerifier.java @@ -39,7 +39,8 @@ import javax.jms.MessageEOFException; import javax.jms.ObjectMessage; import javax.jms.StreamMessage; import javax.jms.TextMessage; -import javax.xml.bind.DatatypeConverter; + +import org.apache.qpid.server.util.StringUtil; public class MessageVerifier { @@ -257,12 +258,12 @@ public class MessageVerifier { final byte[] expectedValueAsBytes = (byte[]) expectedValue; final byte[] actualValueAsBytes = (byte[]) actualValue; - String expectedValueAsString = DatatypeConverter.printHexBinary(expectedValueAsBytes); + String expectedValueAsString = StringUtil.toHex(expectedValueAsBytes); if (expectedValueAsString.length() > 20) { expectedValueAsString = expectedValueAsString.substring(0, 20) + "..."; } - String actualValueAsString = DatatypeConverter.printHexBinary(actualValueAsBytes); + String actualValueAsString = StringUtil.toHex(actualValueAsBytes); if (actualValueAsString.length() > 20) { actualValueAsString = actualValueAsString.substring(0, 20) + "..."; http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/c8c82033/systests/protocol-tests-core/src/main/java/org/apache/qpid/tests/protocol/SaslUtils.java ---------------------------------------------------------------------- diff --git a/systests/protocol-tests-core/src/main/java/org/apache/qpid/tests/protocol/SaslUtils.java b/systests/protocol-tests-core/src/main/java/org/apache/qpid/tests/protocol/SaslUtils.java index 5833599..2659fd3 100644 --- a/systests/protocol-tests-core/src/main/java/org/apache/qpid/tests/protocol/SaslUtils.java +++ b/systests/protocol-tests-core/src/main/java/org/apache/qpid/tests/protocol/SaslUtils.java @@ -23,10 +23,20 @@ import java.nio.charset.StandardCharsets; import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; -import javax.xml.bind.DatatypeConverter; public class SaslUtils { + private static final char[] HEX = "0123456789abcdef".toCharArray(); + + private static String toHex(byte[] bin) + { + StringBuilder result = new StringBuilder(2 * bin.length); + for (byte b : bin) { + result.append(HEX[(b >> 4) & 0xF]); + result.append(HEX[(b & 0xF)]); + } + return result.toString(); + } public static byte[] generateCramMD5ClientResponse(String userName, String userPassword, byte[] challengeBytes) throws Exception { @@ -34,8 +44,7 @@ public class SaslUtils Mac mac = Mac.getInstance(macAlgorithm); mac.init(new SecretKeySpec(userPassword.getBytes(StandardCharsets.UTF_8), macAlgorithm)); final byte[] messageAuthenticationCode = mac.doFinal(challengeBytes); - String responseAsString = userName + " " + DatatypeConverter.printHexBinary(messageAuthenticationCode) - .toLowerCase(); + String responseAsString = userName + " " + toHex(messageAuthenticationCode); return responseAsString.getBytes(); } } http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/c8c82033/systests/qpid-systests-http-management/src/main/java/org/apache/qpid/tests/http/HttpTestHelper.java ---------------------------------------------------------------------- diff --git a/systests/qpid-systests-http-management/src/main/java/org/apache/qpid/tests/http/HttpTestHelper.java b/systests/qpid-systests-http-management/src/main/java/org/apache/qpid/tests/http/HttpTestHelper.java index 7421aa9..04bb288 100644 --- a/systests/qpid-systests-http-management/src/main/java/org/apache/qpid/tests/http/HttpTestHelper.java +++ b/systests/qpid-systests-http-management/src/main/java/org/apache/qpid/tests/http/HttpTestHelper.java @@ -34,6 +34,7 @@ import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.security.UnrecoverableKeyException; import java.security.cert.X509Certificate; +import java.util.Base64; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; @@ -46,7 +47,6 @@ import javax.net.ssl.SSLContext; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; import javax.servlet.http.HttpServletResponse; -import javax.xml.bind.DatatypeConverter; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; @@ -170,7 +170,7 @@ public class HttpTestHelper if(_username != null) { - String encoded = DatatypeConverter.printBase64Binary((_username + ":" + _password).getBytes(UTF_8)); + String encoded = Base64.getEncoder().encodeToString((_username + ":" + _password).getBytes(UTF_8)); httpCon.setRequestProperty("Authorization", "Basic " + encoded); } http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/c8c82033/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/authentication/SaslTest.java ---------------------------------------------------------------------- diff --git a/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/authentication/SaslTest.java b/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/authentication/SaslTest.java index 9201793..7977cec 100644 --- a/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/authentication/SaslTest.java +++ b/systests/qpid-systests-http-management/src/test/java/org/apache/qpid/tests/http/authentication/SaslTest.java @@ -33,12 +33,11 @@ import static org.junit.Assert.assertTrue; import java.io.IOException; import java.io.OutputStream; import java.net.HttpURLConnection; +import java.util.Base64; import java.util.List; import java.util.Map; import java.util.UUID; -import javax.xml.bind.DatatypeConverter; - import org.junit.Before; import org.junit.Test; @@ -116,7 +115,7 @@ public class SaslTest extends HttpTestBase public void plainSASLAuthenticationWithMalformedInitialResponse() throws Exception { byte[] responseBytes = "null".getBytes(); - String responseData = DatatypeConverter.printBase64Binary(responseBytes); + String responseData = Base64.getEncoder().encodeToString(responseBytes); String parameters = String.format("mechanism=%s&response=%s", PlainNegotiator.MECHANISM, responseData); HttpURLConnection connection = getHelper().openManagementConnection(SASL_SERVICE, "POST"); @@ -221,7 +220,7 @@ public class SaslTest extends HttpTestBase List<String> cookies = connection.getHeaderFields().get(SET_COOKIE_HEADER); - String responseData = DatatypeConverter.printBase64Binary("null".getBytes()); + String responseData = Base64.getEncoder().encodeToString("null".getBytes()); String requestParameters = String.format("id=%s&response=%s", response.get("id"), responseData); postResponse(cookies, requestParameters, SC_UNAUTHORIZED); @@ -246,10 +245,10 @@ public class SaslTest extends HttpTestBase List<String> cookies = connection.getHeaderFields().get(SET_COOKIE_HEADER); - byte[] challengeBytes = DatatypeConverter.parseBase64Binary(challenge); + byte[] challengeBytes = Base64.getDecoder().decode(challenge); byte[] responseBytes = generateClientResponse(CramMd5Negotiator.MECHANISM, _userName, _userPassword, challengeBytes); - String responseData = DatatypeConverter.printBase64Binary(responseBytes); + String responseData = Base64.getEncoder().encodeToString(responseBytes); String requestParameters = (String.format("id=%s&response=%s", UUID.randomUUID().toString(), responseData)); postResponse(cookies, requestParameters, SC_EXPECTATION_FAILED); @@ -267,7 +266,7 @@ public class SaslTest extends HttpTestBase final int expectedResponseCode) throws Exception { byte[] responseBytes = generatePlainClientResponse(userName, userPassword); - String responseData = DatatypeConverter.printBase64Binary(responseBytes); + String responseData = Base64.getEncoder().encodeToString(responseBytes); String parameters = String.format("mechanism=%s&response=%s", PlainNegotiator.MECHANISM, responseData); HttpURLConnection connection = getHelper().openManagementConnection(SASL_SERVICE, "POST"); @@ -318,9 +317,9 @@ public class SaslTest extends HttpTestBase String challenge = (String) response.get("challenge"); assertNotNull("Challenge is not found", challenge); - byte[] challengeBytes = DatatypeConverter.parseBase64Binary(challenge); + byte[] challengeBytes = Base64.getDecoder().decode(challenge); byte[] responseBytes = generateClientResponse(mechanism, userName, userPassword, challengeBytes); - String responseData = DatatypeConverter.printBase64Binary(responseBytes); + String responseData = Base64.getEncoder().encodeToString(responseBytes); String requestParameters = (String.format("id=%s&response=%s", response.get("id"), responseData)); postResponse(requestChallengeConnection.getHeaderFields().get(SET_COOKIE_HEADER), http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/c8c82033/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/extensions/tls/TlsTest.java ---------------------------------------------------------------------- diff --git a/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/extensions/tls/TlsTest.java b/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/extensions/tls/TlsTest.java index 7d7e1a1..7f61e4f 100644 --- a/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/extensions/tls/TlsTest.java +++ b/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/extensions/tls/TlsTest.java @@ -43,6 +43,7 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.security.Key; import java.security.cert.Certificate; +import java.util.Base64; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -51,7 +52,6 @@ import java.util.Map; import javax.jms.Connection; import javax.jms.JMSException; import javax.jms.Session; -import javax.xml.bind.DatatypeConverter; import org.junit.AfterClass; import org.junit.BeforeClass; @@ -685,7 +685,7 @@ public class TlsTest extends JmsTestBase { Key pvt = ks.getKey(TestSSLConstants.CERT_ALIAS_APP1, KEYSTORE_PASSWORD.toCharArray()); kos.write("-----BEGIN PRIVATE KEY-----\n".getBytes()); - String base64encoded = DatatypeConverter.printBase64Binary(pvt.getEncoded()); + String base64encoded = Base64.getEncoder().encodeToString(pvt.getEncoded()); while (base64encoded.length() > 76) { kos.write(base64encoded.substring(0, 76).getBytes()); @@ -705,7 +705,7 @@ public class TlsTest extends JmsTestBase for (Certificate pub : chain) { cos.write("-----BEGIN CERTIFICATE-----\n".getBytes()); - String base64encoded = DatatypeConverter.printBase64Binary(pub.getEncoded()); + String base64encoded = Base64.getEncoder().encodeToString(pub.getEncoded()); while (base64encoded.length() > 76) { cos.write(base64encoded.substring(0, 76).getBytes()); @@ -739,7 +739,7 @@ public class TlsTest extends JmsTestBase { Certificate pub = ks.getCertificate(alias); cos.write("-----BEGIN CERTIFICATE-----\n".getBytes()); - String base64encoded = DatatypeConverter.printBase64Binary(pub.getEncoded()); + String base64encoded = Base64.getEncoder().encodeToString(pub.getEncoded()); while (base64encoded.length() > 76) { cos.write(base64encoded.substring(0, 76).getBytes()); http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/c8c82033/tools/src/main/java/org/apache/qpid/tools/RestStressTestClient.java ---------------------------------------------------------------------- diff --git a/tools/src/main/java/org/apache/qpid/tools/RestStressTestClient.java b/tools/src/main/java/org/apache/qpid/tools/RestStressTestClient.java index 4beac5f..7242a65 100644 --- a/tools/src/main/java/org/apache/qpid/tools/RestStressTestClient.java +++ b/tools/src/main/java/org/apache/qpid/tools/RestStressTestClient.java @@ -34,6 +34,7 @@ import java.security.KeyManagementException; import java.security.NoSuchAlgorithmException; import java.security.cert.X509Certificate; import java.util.Arrays; +import java.util.Base64; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; @@ -49,7 +50,6 @@ import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLContext; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; -import javax.xml.bind.DatatypeConverter; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; @@ -282,7 +282,7 @@ public class RestStressTestClient if (saslMechanism == null) { - _authorizationHeader = "Basic " + DatatypeConverter.printBase64Binary((_username + ":" + _password).getBytes(UTF_8)); + _authorizationHeader = "Basic " + Base64.getEncoder().encodeToString((_username + ":" + _password).getBytes(UTF_8)); } else { @@ -530,7 +530,7 @@ public class RestStressTestClient final byte[] messageAuthenticationCode = mac.doFinal(challengeBytes); String responseAsString = username + " " + toHex(messageAuthenticationCode); byte[] responseBytes = responseAsString.getBytes(UTF_8); - return DatatypeConverter.printBase64Binary(responseBytes); + return Base64.getEncoder().encodeToString(responseBytes); } catch (Exception e) { @@ -546,7 +546,7 @@ public class RestStressTestClient throw new IllegalArgumentException("Cannot convert string '"+ base64String+ "'to a byte[] - it does not appear to be base64 data"); } - return DatatypeConverter.parseBase64Binary(base64String); + return Base64.getDecoder().decode(base64String); } private String toHex(byte[] data) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org