Source:
<code>public void channelRead(final ChannelHandlerContext ctx, final Object msg) { if (msg instanceof FullHttpMessage) { final FullHttpMessage request = (FullHttpMessage) msg; if (!request.headers().contains("Authorization")) { sendError(ctx, msg); return; } final String basic = "Basic "; final String authorizationHeader = request.headers().get("Authorization"); if (!authorizationHeader.startsWith(basic)) { sendError(ctx, msg); return; } byte[] decodedUserPass = null; try { final String encodedUserPass = authorizationHeader.substring(basic.length()); decodedUserPass = decoder.decode(encodedUserPass); } catch (IndexOutOfBoundsException iae) { sendError(ctx, msg); return; } catch (IllegalArgumentException iae) { sendError(ctx, msg); return; } final String authorization = new String(decodedUserPass, Charset.forName("UTF-8")); final String[] split = authorization.split(":"); if (split.length != 2) { sendError(ctx, msg); return; } final Map<String,String> credentials = new HashMap<>(); credentials.put(PROPERTY_USERNAME, split[0]); credentials.put(PROPERTY_PASSWORD, split[1]); try { authenticator.authenticate(credentials); ctx.fireChannelRead(request); if (authenticationSettings.enableAuditLog) { String[] authClassParts = authenticator.getClass().toString().split("[.]"); auditLogger.info("User with address authenticated by {}", credentials.get(PROPERTY_USERNAME), <START> ctx.channel().remoteAddress().toString().substring(1), authClassParts[authClassParts.length - 1]); <END> } } catch (AuthenticationException ae) { sendError(ctx, msg); } } }</code><technical_language>substring(1) assumes remoteAddress unresolved (reverse lookup) hostname. I if this is case</technical_language>

Target:
public void channelRead(final ChannelHandlerContext ctx, final Object msg) { if (msg instanceof FullHttpMessage) { final FullHttpMessage request = (FullHttpMessage) msg; if (!request.headers().contains("Authorization")) { sendError(ctx, msg); return; } final String basic = "Basic "; final String authorizationHeader = request.headers().get("Authorization"); if (!authorizationHeader.startsWith(basic)) { sendError(ctx, msg); return; } byte[] decodedUserPass = null; try { final String encodedUserPass = authorizationHeader.substring(basic.length()); decodedUserPass = decoder.decode(encodedUserPass); } catch (IndexOutOfBoundsException iae) { sendError(ctx, msg); return; } catch (IllegalArgumentException iae) { sendError(ctx, msg); return; } final String authorization = new String(decodedUserPass, Charset.forName("UTF-8")); final String[] split = authorization.split(":"); if (split.length != 2) { sendError(ctx, msg); return; } final Map<String,String> credentials = new HashMap<>(); credentials.put(PROPERTY_USERNAME, split[0]); credentials.put(PROPERTY_PASSWORD, split[1]); try { authenticator.authenticate(credentials); ctx.fireChannelRead(request); if (authenticationSettings.enableAuditLog) { String address = ctx.channel().remoteAddress().toString(); if (address.startsWith("/") && address.length() > 1) address = address.substring(1); final String[] authClassParts = authenticator.getClass().toString().split("[.]"); auditLogger.info("User with address authenticated by {}", credentials.get(PROPERTY_USERNAME), address, authClassParts[authClassParts.length - 1]); } } catch (AuthenticationException ae) { sendError(ctx, msg); } } }