From a401798e5e8f3142b49858c958bfcb9d4a764ddb Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Tue, 04 Sep 2012 16:29:01 +0000
Subject: [PATCH] Fix OPENDJ-369: Consider exposing base 64 encode/decode APIs
---
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Base64.java | 16 +++++++++-------
1 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/Base64.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Base64.java
similarity index 96%
rename from opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/Base64.java
rename to opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Base64.java
index c2f7ec3..5686d5b 100755
--- a/opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/Base64.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Base64.java
@@ -24,7 +24,7 @@
* Copyright 2006-2009 Sun Microsystems, Inc.
* Portions copyright 2012 ForgeRock AS.
*/
-package com.forgerock.opendj.util;
+package org.forgerock.opendj.ldap;
import static com.forgerock.opendj.util.Validator.ensureNotNull;
import static org.forgerock.opendj.ldap.CoreMessages.ERR_BASE64_DECODE_INVALID_CHARACTER;
@@ -32,17 +32,19 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizedIllegalArgumentException;
-import org.forgerock.opendj.ldap.ByteSequence;
-import org.forgerock.opendj.ldap.ByteString;
-import org.forgerock.opendj.ldap.ByteStringBuilder;
/**
* This class provides methods for performing base64 encoding and decoding.
* Base64 is a mechanism for encoding binary data in ASCII form by converting
* sets of three bytes with eight significant bits each to sets of four bytes
* with six significant bits each.
+ * <p>
+ * <b>NOTE:</b> the JDK class {@link javax.xml.bind.DatatypeConverter} provides
+ * similar functionality, however the methods are better suited to the LDAP SDK.
+ * For example, the JDK encoder does not handle array/offset/len parameters, and
+ * the decoder ignores invalid Base64 data.
*/
-public final class Base64 {
+final class Base64 {
/**
* The set of characters that may be used in base64-encoded values.
*/
@@ -61,7 +63,7 @@
* @throws NullPointerException
* If {@code base64} was {@code null}.
*/
- public static ByteString decode(final String base64) {
+ static ByteString decode(final String base64) {
ensureNotNull(base64);
// The encoded value must have length that is a multiple of four
@@ -315,7 +317,7 @@
* @throws NullPointerException
* If {@code bytes} was {@code null}.
*/
- public static String encode(final ByteSequence bytes) {
+ static String encode(final ByteSequence bytes) {
ensureNotNull(bytes);
final StringBuilder buffer = new StringBuilder(4 * bytes.length() / 3);
--
Gitblit v1.10.0