public static boolean urisEqualAfterPortNormalization(final URI uri1, final URI uri2) {
        if (uri1 == null && uri2 == null) {
            return true;
        }
        if (uri1 == null || uri2 == null) {
            return false;
        }

        try {
            val normalizedUri1 = normalizePortNumbersInUri(uri1);
            val normalizedUri2 = normalizePortNumbersInUri(uri2);
            val eq = normalizedUri1.equals(normalizedUri2);
            return eq;
        } catch (final URISyntaxException use) {
            LOGGER.error("Cannot compare 2 URIs.", use);
            return false;
        }
    }
Compares two URIs for equality, ignoring default port numbers for selected protocols.

By default, {@link URI#equals(Object)} doesn't take into account default port numbers,
so http://server:80/resource is a different URI than http://server/resource.

And URLs should not be used for comparison, as written here:
http://stackoverflow.com/questions/3771081/proper-way-to-check-for-url-equality

@param uri1
           URI 1 to be compared.
@param uri2
           URI 2 to be compared.
@return True if both URIs are equal.
pac4j-saml/src/main/java/org/pac4j/saml/util/SAML2Utils.java