io.netty.handler.codec.base64.Base64 Java Examples

The following examples show how to use io.netty.handler.codec.base64.Base64. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ILoveRadioManager.java    From The-5zig-Mod with GNU General Public License v3.0 6 votes vote down vote up
private String resolveCover(final String path) throws ExecutionException {
	return TRACK_IMAGE_LOOKUP.get(path, new Callable<String>() {
		@Override
		public String call() throws Exception {
			URL url = new URL(path);
			BufferedImage image = ImageIO.read(url);
			BufferedImage image1 = new BufferedImage(60, 60, image.getType());
			Graphics graphics = image1.getGraphics();
			try {
				graphics.drawImage(image, 0, 0, image1.getWidth(), image1.getHeight(), null);
			} finally {
				graphics.dispose();
			}
			// Converting Image byte array into Base64 String
			ByteBuf localByteBuf1 = Unpooled.buffer();
			ImageIO.write(image1, "PNG", new ByteBufOutputStream(localByteBuf1));
			ByteBuf localByteBuf2 = Base64.encode(localByteBuf1);
			return localByteBuf2.toString(Charsets.UTF_8);
		}
	});
}
 
Example #2
Source File: PemReader.java    From netty4.0.27Learn with Apache License 2.0 6 votes vote down vote up
static ByteBuf readPrivateKey(File file) throws KeyException {
    String content;
    try {
        content = readContent(file);
    } catch (IOException e) {
        throw new KeyException("failed to read a file: " + file, e);
    }

    Matcher m = KEY_PATTERN.matcher(content);
    if (!m.find()) {
        throw new KeyException("found no private key: " + file);
    }

    ByteBuf base64 = Unpooled.copiedBuffer(m.group(1), CharsetUtil.US_ASCII);
    ByteBuf der = Base64.decode(base64);
    base64.release();
    return der;
}
 
Example #3
Source File: Hash.java    From redisson with Apache License 2.0 6 votes vote down vote up
public static String hash128toBase64(ByteBuf objectState) {
    long[] hash = hash128(objectState);

    ByteBuf buf = Unpooled.copyLong(hash[0], hash[1]);
    try {
        ByteBuf b = Base64.encode(buf);
        try {
            String s = b.toString(CharsetUtil.UTF_8);
            return s.substring(0, s.length() - 2);
        } finally {
            b.release();
        }
    } finally {
        buf.release();
    }
}
 
Example #4
Source File: PemReader.java    From netty-4.1.22 with Apache License 2.0 6 votes vote down vote up
static ByteBuf readPrivateKey(InputStream in) throws KeyException {
    String content;
    try {
        content = readContent(in);
    } catch (IOException e) {
        throw new KeyException("failed to read key input stream", e);
    }

    Matcher m = KEY_PATTERN.matcher(content);
    if (!m.find()) {
        throw new KeyException("could not find a PKCS #8 private key in input stream" +
                " (see http://netty.io/wiki/sslcontextbuilder-and-private-key.html for more information)");
    }

    ByteBuf base64 = Unpooled.copiedBuffer(m.group(1), CharsetUtil.US_ASCII);
    ByteBuf der = Base64.decode(base64);
    base64.release();
    return der;
}
 
Example #5
Source File: Http2ServerUpgradeCodec.java    From netty-4.1.22 with Apache License 2.0 6 votes vote down vote up
/**
 * Decodes the settings header and returns a {@link Http2Settings} object.
 */
private Http2Settings decodeSettingsHeader(ChannelHandlerContext ctx, CharSequence settingsHeader)
        throws Http2Exception {
    ByteBuf header = ByteBufUtil.encodeString(ctx.alloc(), CharBuffer.wrap(settingsHeader), CharsetUtil.UTF_8);
    try {
        // Decode the SETTINGS payload.
        ByteBuf payload = Base64.decode(header, URL_SAFE);

        // Create an HTTP/2 frame for the settings.
        ByteBuf frame = createSettingsFrame(ctx, payload);

        // Decode the SETTINGS frame and return the settings object.
        return decodeSettings(ctx, frame);
    } finally {
        header.release();
    }
}
 
Example #6
Source File: Http2ClientUpgradeCodec.java    From netty-4.1.22 with Apache License 2.0 6 votes vote down vote up
/**
 * Converts the current settings for the handler to the Base64-encoded representation used in
 * the HTTP2-Settings upgrade header.
 */
private CharSequence getSettingsHeaderValue(ChannelHandlerContext ctx) {
    ByteBuf buf = null;
    ByteBuf encodedBuf = null;
    try {
        // Get the local settings for the handler.
        Http2Settings settings = connectionHandler.decoder().localSettings();

        // Serialize the payload of the SETTINGS frame.
        int payloadLength = SETTING_ENTRY_LENGTH * settings.size();
        buf = ctx.alloc().buffer(payloadLength);
        for (CharObjectMap.PrimitiveEntry<Long> entry : settings.entries()) {
            buf.writeChar(entry.key());
            buf.writeInt(entry.value().intValue());
        }

        // Base64 encode the payload and then convert to a string for the header.
        encodedBuf = Base64.encode(buf, URL_SAFE);
        return encodedBuf.toString(UTF_8);
    } finally {
        release(buf);
        release(encodedBuf);
    }
}
 
Example #7
Source File: HttpProxyHandler.java    From netty-4.1.22 with Apache License 2.0 6 votes vote down vote up
public HttpProxyHandler(SocketAddress proxyAddress, String username, String password,
                        HttpHeaders headers) {
    super(proxyAddress);
    if (username == null) {
        throw new NullPointerException("username");
    }
    if (password == null) {
        throw new NullPointerException("password");
    }
    this.username = username;
    this.password = password;

    ByteBuf authz = Unpooled.copiedBuffer(username + ':' + password, CharsetUtil.UTF_8);
    ByteBuf authzBase64 = Base64.encode(authz, false);

    authorization = new AsciiString("Basic " + authzBase64.toString(CharsetUtil.US_ASCII));

    authz.release();
    authzBase64.release();

    this.headers = headers;
}
 
Example #8
Source File: KeyCertLoader.java    From WeCross with Apache License 2.0 6 votes vote down vote up
ByteBuf readPrivateKey(InputStream in) throws KeyException {
    String content;
    try {
        content = readContent(in);
    } catch (IOException e) {
        throw new KeyException("failed to read key input stream", e);
    }

    Matcher m = KEY_PATTERN.matcher(content);
    if (!m.find()) {
        throw new KeyException(
                "could not find a PKCS #8 private key in input stream"
                        + " (see https://netty.io/wiki/sslcontextbuilder-and-private-key.html for more information)");
    }

    ByteBuf base64 = Unpooled.copiedBuffer(m.group(1), CharsetUtil.US_ASCII);
    ByteBuf der = Base64.decode(base64);
    base64.release();
    return der;
}
 
Example #9
Source File: Base64Renderer.java    From The-5zig-Mod with MIT License 6 votes vote down vote up
public static Base64Renderer getRenderer(BufferedImage icon, String id) {
	Base64Renderer renderer = CACHE.getIfPresent(id);
	if (renderer != null) {
		return renderer;
	}
	final Base64Renderer finalRenderer = new Base64Renderer(null, icon.getWidth(), icon.getHeight());
	CACHE.put(id, finalRenderer);
	try {
		ByteBuf decodedBuffer = Unpooled.buffer();
		ImageIO.write(icon, "PNG", new ByteBufOutputStream(decodedBuffer));
		ByteBuf encodedBuffer = Base64.encode(decodedBuffer);
		String imageDataString = encodedBuffer.toString(Charsets.UTF_8);

		finalRenderer.setBase64String(imageDataString, id);
	} catch (Exception e) {
		The5zigMod.logger.error("Could not load icon " + id, e);
	}
	return finalRenderer;
}
 
Example #10
Source File: EinsLiveManager.java    From The-5zig-Mod with MIT License 6 votes vote down vote up
private void resolveImage(ITunesSearchResultEntry searchEntry) {
	try {
		URL url = new URL(searchEntry.getArtworkUrl100());
		BufferedImage image = ImageIO.read(url);
		BufferedImage image1 = new BufferedImage(60, 60, image.getType());
		Graphics graphics = image1.getGraphics();
		try {
			graphics.drawImage(image, 0, 0, image1.getWidth(), image1.getHeight(), null);
		} finally {
			graphics.dispose();
		}
		// Converting Image byte array into Base64 String
		ByteBuf localByteBuf1 = Unpooled.buffer();
		ImageIO.write(image1, "PNG", new ByteBufOutputStream(localByteBuf1));
		ByteBuf localByteBuf2 = Base64.encode(localByteBuf1);
		String imageDataString = localByteBuf2.toString(Charsets.UTF_8);

		searchEntry.setImage(imageDataString);
	} catch (Exception e) {
		The5zigMod.logger.warn("Could not resolve image for track " + searchEntry.getTrackName() + "!");
	}
}
 
Example #11
Source File: SkinManager.java    From The-5zig-Mod with MIT License 6 votes vote down vote up
private void downloadBase64Skin(final String uuid) {
	executorService.submit(new Runnable() {
		@Override
		public void run() {
			try {
				URL url = new URL("https://cravatar.eu/avatar/" + uuid + "/64.png");
				BufferedImage image = ImageIO.read(url);
				// Converting Image byte array into Base64 String
				ByteBuf localByteBuf1 = Unpooled.buffer();
				ImageIO.write(image, "PNG", new ByteBufOutputStream(localByteBuf1));
				ByteBuf localByteBuf2 = Base64.encode(localByteBuf1);
				String imageDataString = localByteBuf2.toString(Charsets.UTF_8);
				setBase64EncodedSkin(uuid, imageDataString);
				The5zigMod.logger.debug("Got Base64 encoded skin for {}", uuid);
			} catch (Exception e) {
				The5zigMod.logger.warn("Could not get Base64 skin for " + uuid, e);
			}
		}
	});
}
 
Example #12
Source File: ILoveRadioManager.java    From The-5zig-Mod with MIT License 6 votes vote down vote up
private String resolveCover(final String path) throws ExecutionException {
	return TRACK_IMAGE_LOOKUP.get(path, new Callable<String>() {
		@Override
		public String call() throws Exception {
			URL url = new URL(path);
			BufferedImage image = ImageIO.read(url);
			BufferedImage image1 = new BufferedImage(60, 60, image.getType());
			Graphics graphics = image1.getGraphics();
			try {
				graphics.drawImage(image, 0, 0, image1.getWidth(), image1.getHeight(), null);
			} finally {
				graphics.dispose();
			}
			// Converting Image byte array into Base64 String
			ByteBuf localByteBuf1 = Unpooled.buffer();
			ImageIO.write(image1, "PNG", new ByteBufOutputStream(localByteBuf1));
			ByteBuf localByteBuf2 = Base64.encode(localByteBuf1);
			return localByteBuf2.toString(Charsets.UTF_8);
		}
	});
}
 
Example #13
Source File: Base64Renderer.java    From The-5zig-Mod with GNU General Public License v3.0 6 votes vote down vote up
public static Base64Renderer getRenderer(BufferedImage icon, String id) {
	Base64Renderer renderer = CACHE.getIfPresent(id);
	if (renderer != null) {
		return renderer;
	}
	final Base64Renderer finalRenderer = new Base64Renderer(null, icon.getWidth(), icon.getHeight());
	CACHE.put(id, finalRenderer);
	try {
		ByteBuf decodedBuffer = Unpooled.buffer();
		ImageIO.write(icon, "PNG", new ByteBufOutputStream(decodedBuffer));
		ByteBuf encodedBuffer = Base64.encode(decodedBuffer);
		String imageDataString = encodedBuffer.toString(Charsets.UTF_8);

		finalRenderer.setBase64String(imageDataString, id);
	} catch (Exception e) {
		The5zigMod.logger.error("Could not load icon " + id, e);
	}
	return finalRenderer;
}
 
Example #14
Source File: SkinManager.java    From The-5zig-Mod with GNU General Public License v3.0 6 votes vote down vote up
private void downloadBase64Skin(final String uuid) {
	executorService.submit(new Runnable() {
		@Override
		public void run() {
			try {
				URL url = new URL("https://cravatar.eu/avatar/" + uuid + "/64.png");
				BufferedImage image = ImageIO.read(url);
				// Converting Image byte array into Base64 String
				ByteBuf localByteBuf1 = Unpooled.buffer();
				ImageIO.write(image, "PNG", new ByteBufOutputStream(localByteBuf1));
				ByteBuf localByteBuf2 = Base64.encode(localByteBuf1);
				String imageDataString = localByteBuf2.toString(Charsets.UTF_8);
				setBase64EncodedSkin(uuid, imageDataString);
				The5zigMod.logger.debug("Got Base64 encoded skin for {}", uuid);
			} catch (Exception e) {
				The5zigMod.logger.warn("Could not get Base64 skin for " + uuid, e);
			}
		}
	});
}
 
Example #15
Source File: AbstractGenericHandler.java    From couchbase-jvm-core with Apache License 2.0 6 votes vote down vote up
/**
 * Add basic authentication headers to a {@link HttpRequest}.
 *
 * The given information is Base64 encoded and the authorization header is set appropriately. Since this needs
 * to be done for every request, it is refactored out.
 *
 * @param ctx the handler context.
 * @param request the request where the header should be added.
 * @param user the username for auth.
 * @param password the password for auth.
 */
public static void addHttpBasicAuth(final ChannelHandlerContext ctx, final HttpRequest request, final String user,
    final String password) {

    // if both user and password are null or empty, don't add http basic auth
    // this is usually the case when certificate auth is used.
    if ((user == null || user.isEmpty()) && (password == null || password.isEmpty())) {
        return;
    }

    final String pw = password == null ? "" : password;

    ByteBuf raw = ctx.alloc().buffer(user.length() + pw.length() + 1);
    raw.writeBytes((user + ":" + pw).getBytes(CHARSET));
    ByteBuf encoded = Base64.encode(raw, false);
    request.headers().add(HttpHeaders.Names.AUTHORIZATION, "Basic " + encoded.toString(CHARSET));
    encoded.release();
    raw.release();
}
 
Example #16
Source File: SpotifyWebAPI.java    From The-5zig-Mod with GNU General Public License v3.0 6 votes vote down vote up
public boolean resolveTrackImage(final SpotifyNewTrack track) throws IOException {
    URL url = new URL(track.getImageUrl());
    BufferedImage image = ImageIO.read(url);
    BufferedImage image1 = new BufferedImage(128, 128, image.getType());
    Graphics graphics = image1.getGraphics();
    try {
        graphics.drawImage(image, 0, 0, image1.getWidth(), image1.getHeight(), null);
    } finally {
        graphics.dispose();
    }
    // Converting Image byte array into Base64 String
    ByteBuf localByteBuf1 = Unpooled.buffer();
    ImageIO.write(image1, "PNG", new ByteBufOutputStream(localByteBuf1));
    ByteBuf localByteBuf2 = Base64.encode(localByteBuf1);
    String imageDataString = localByteBuf2.toString(Charsets.UTF_8);

    track.setImage(imageDataString);
    TRACK_IMAGE_LOOKUP.put(track.getId(), imageDataString);

    return true;
}
 
Example #17
Source File: EinsLiveManager.java    From The-5zig-Mod with GNU General Public License v3.0 6 votes vote down vote up
private void resolveImage(ITunesSearchResultEntry searchEntry) {
	try {
		URL url = new URL(searchEntry.getArtworkUrl100());
		BufferedImage image = ImageIO.read(url);
		BufferedImage image1 = new BufferedImage(60, 60, image.getType());
		Graphics graphics = image1.getGraphics();
		try {
			graphics.drawImage(image, 0, 0, image1.getWidth(), image1.getHeight(), null);
		} finally {
			graphics.dispose();
		}
		// Converting Image byte array into Base64 String
		ByteBuf localByteBuf1 = Unpooled.buffer();
		ImageIO.write(image1, "PNG", new ByteBufOutputStream(localByteBuf1));
		ByteBuf localByteBuf2 = Base64.encode(localByteBuf1);
		String imageDataString = localByteBuf2.toString(Charsets.UTF_8);

		searchEntry.setImage(imageDataString);
	} catch (Exception e) {
		The5zigMod.logger.warn("Could not resolve image for track " + searchEntry.getTrackName() + "!");
	}
}
 
Example #18
Source File: Favicon.java    From ServerListPlus with GNU General Public License v3.0 6 votes vote down vote up
public static String create(BufferedImage image) throws IOException {
    checkArgument(image.getWidth() == 64, "favicon must be 64 pixels wide");
    checkArgument(image.getHeight() == 64, "favicon must be 64 pixels high");

    ByteBuf buf = Unpooled.buffer();
    try {
        ImageIO.write(image, "PNG", new ByteBufOutputStream(buf));
        ByteBuf base64 = Base64.encode(buf, false);
        try {
            return FAVICON_PREFIX + base64.toString(Charsets.UTF_8);
        } finally {
            base64.release();
        }
    } finally {
        buf.release();
    }
}
 
Example #19
Source File: NettyHttpUtil.java    From netty-cookbook with Apache License 2.0 5 votes vote down vote up
public static FullHttpResponse theBase64Image1pxGif() {
	ByteBuf byteBuf = Base64.decode(Unpooled.copiedBuffer(BASE64GIF_BYTES));
	FullHttpResponse response = new DefaultFullHttpResponse(HTTP_1_1, OK , byteBuf);
	response.headers().set(CONTENT_TYPE, ContentTypePool.GIF);
	response.headers().set(CONTENT_LENGTH, byteBuf.readableBytes());
	response.headers().set(CONNECTION, HEADER_CONNECTION_CLOSE);
	return response;
}
 
Example #20
Source File: PemReader.java    From netty4.0.27Learn with Apache License 2.0 5 votes vote down vote up
static ByteBuf[] readCertificates(File file) throws CertificateException {
    String content;
    try {
        content = readContent(file);
    } catch (IOException e) {
        throw new CertificateException("failed to read a file: " + file, e);
    }

    List<ByteBuf> certs = new ArrayList<ByteBuf>();
    Matcher m = CERT_PATTERN.matcher(content);
    int start = 0;
    for (;;) {
        if (!m.find(start)) {
            break;
        }

        ByteBuf base64 = Unpooled.copiedBuffer(m.group(1), CharsetUtil.US_ASCII);
        ByteBuf der = Base64.decode(base64);
        base64.release();
        certs.add(der);

        start = m.end();
    }

    if (certs.isEmpty()) {
        throw new CertificateException("found no certificates: " + file);
    }

    return certs.toArray(new ByteBuf[certs.size()]);
}
 
Example #21
Source File: NettyHttpClient.java    From ari4java with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void initialize(String baseUrl, String username, String password) throws URISyntaxException {
    if (!baseUrl.endsWith("/")) {
        baseUrl = baseUrl + "/";
    }
    logger.debug("initialize url: {}, user: {}", baseUrl, username);
    baseUri = new URI(baseUrl);
    String protocol = baseUri.getScheme();
    if (!HTTP.equalsIgnoreCase(protocol) && !HTTPS.equalsIgnoreCase(protocol)) {
        logger.warn("Not http(s), protocol: {}", protocol);
        throw new IllegalArgumentException("Unsupported protocol: " + protocol);
    }
    this.auth = "Basic " + Base64.encode(Unpooled.copiedBuffer((username + ":" + password), ARIEncoder.ENCODING)).toString(ARIEncoder.ENCODING);
    initHttpBootstrap();
}
 
Example #22
Source File: NettyConnector.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
private static String base64(byte[] data) {
   ByteBuf encodedData = Unpooled.wrappedBuffer(data);
   ByteBuf encoded = Base64.encode(encodedData);
   String encodedString = encoded.toString(StandardCharsets.UTF_8);
   encoded.release();
   return encodedString;
}
 
Example #23
Source File: EtcdNettyClient.java    From etcd4j with Apache License 2.0 5 votes vote down vote up
private void addBasicAuthHeader(HttpRequest request) {
  ByteBuf byteBuf = Base64.encode(
          Unpooled.copiedBuffer( securityContext.username() + ":" + securityContext.password(), CharsetUtil.UTF_8));
  final String auth;
  try {
    auth = byteBuf.toString(CharsetUtil.UTF_8);
  } finally {
    byteBuf.release();
  }

  request.headers().add(HttpHeaderNames.AUTHORIZATION, "Basic " + auth);
}
 
Example #24
Source File: NettyHttpUtil.java    From netty-cookbook with Apache License 2.0 5 votes vote down vote up
public static FullHttpResponse theBase64Image1pxGif() {
	ByteBuf byteBuf = Base64.decode(Unpooled.copiedBuffer(BASE64GIF_BYTES));
	FullHttpResponse response = new DefaultFullHttpResponse(HTTP_1_1, OK , byteBuf);
	response.headers().set(CONTENT_TYPE, ContentTypePool.GIF);
	response.headers().set(CONTENT_LENGTH, byteBuf.readableBytes());
	response.headers().set(CONNECTION, HEADER_CONNECTION_CLOSE);
	return response;
}
 
Example #25
Source File: NettyHttpUtil.java    From netty-cookbook with Apache License 2.0 5 votes vote down vote up
public static FullHttpResponse theBase64Image1pxGif() {
	ByteBuf byteBuf = Base64.decode(Unpooled.copiedBuffer(BASE64GIF_BYTES));
	FullHttpResponse response = new DefaultFullHttpResponse(HTTP_1_1, OK , byteBuf);
	response.headers().set(CONTENT_TYPE, ContentTypePool.GIF);
	response.headers().set(CONTENT_LENGTH, byteBuf.readableBytes());
	response.headers().set(CONNECTION, HEADER_CONNECTION_CLOSE);
	return response;
}
 
Example #26
Source File: NettyHttpUtil.java    From netty-cookbook with Apache License 2.0 5 votes vote down vote up
public static FullHttpResponse theBase64Image1pxGif() {
	ByteBuf byteBuf = Base64.decode(Unpooled.copiedBuffer(BASE64GIF_BYTES));
	FullHttpResponse response = new DefaultFullHttpResponse(HTTP_1_1, OK , byteBuf);
	response.headers().set(CONTENT_TYPE, ContentTypePool.GIF);
	response.headers().set(CONTENT_LENGTH, byteBuf.readableBytes());
	response.headers().set(CONNECTION, HEADER_CONNECTION_CLOSE);
	return response;
}
 
Example #27
Source File: NettyHttpUtil.java    From netty-cookbook with Apache License 2.0 5 votes vote down vote up
public static FullHttpResponse theBase64Image1pxGif() {
	ByteBuf byteBuf = Base64.decode(Unpooled.copiedBuffer(BASE64GIF_BYTES));
	FullHttpResponse response = new DefaultFullHttpResponse(HTTP_1_1, OK , byteBuf);
	response.headers().set(CONTENT_TYPE, ContentTypePool.GIF);
	response.headers().set(CONTENT_LENGTH, byteBuf.readableBytes());
	response.headers().set(CONNECTION, HEADER_CONNECTION_CLOSE);
	return response;
}
 
Example #28
Source File: NettyHttpUtil.java    From netty-cookbook with Apache License 2.0 5 votes vote down vote up
public static FullHttpResponse theBase64Image1pxGif() {
	ByteBuf byteBuf = Base64.decode(Unpooled.copiedBuffer(BASE64GIF_BYTES));
	FullHttpResponse response = new DefaultFullHttpResponse(HTTP_1_1, OK , byteBuf);
	response.headers().set(CONTENT_TYPE, ContentTypePool.GIF);
	response.headers().set(CONTENT_LENGTH, byteBuf.readableBytes());
	response.headers().set(CONNECTION, HEADER_CONNECTION_CLOSE);
	return response;
}
 
Example #29
Source File: NettyHttpUtil.java    From netty-cookbook with Apache License 2.0 5 votes vote down vote up
public static FullHttpResponse theBase64Image1pxGif() {
	ByteBuf byteBuf = Base64.decode(Unpooled.copiedBuffer(BASE64GIF_BYTES));
	FullHttpResponse response = new DefaultFullHttpResponse(HTTP_1_1, OK , byteBuf);
	response.headers().set(CONTENT_TYPE, ContentTypePool.GIF);
	response.headers().set(CONTENT_LENGTH, byteBuf.readableBytes());
	response.headers().set(CONNECTION, HEADER_CONNECTION_CLOSE);
	return response;
}
 
Example #30
Source File: WebSocketUtil.java    From netty4.0.27Learn with Apache License 2.0 5 votes vote down vote up
/**
 * Performs base64 encoding on the specified data
 *
 * @param data The data to encode
 * @return An encoded string containing the data
 */
static String base64(byte[] data) {
    ByteBuf encodedData = Unpooled.wrappedBuffer(data);
    ByteBuf encoded = Base64.encode(encodedData);
    String encodedString = encoded.toString(CharsetUtil.UTF_8);
    encoded.release();
    return encodedString;
}