@Nonnull
    public static String removeBracketsFromIpv6Address(@Nonnull final String address)
    {
        final String result;
        if (address.startsWith("[") && address.endsWith("]")) {
            result = address.substring(1, address.length()-1);
            try {
                Ipv6.parse(result);
                // The remainder is a valid IPv6 address. Return the original value.
                return result;
            } catch (IllegalArgumentException e) {
                // The remainder isn't a valid IPv6 address. Return the original value.
                return address;
            }
        }
        // Not a bracket-enclosed string. Return the original input.
        return address;
    }
When the provided input is an IPv6 literal that is enclosed in brackets (the [] style as expressed in
https://tools.ietf.org/html/rfc2732 and https://tools.ietf.org/html/rfc6874), this method returns the value
stripped from those brackets (the IPv6 address, instead of the literal). In all other cases, the input value is
returned.

@param address The value from which to strip brackets.
@return the input value, stripped from brackets if applicable.
xmppserver/src/main/java/org/jivesoftware/util/IpUtils.java