「应用安全」OAuth和OpenID Connect的全面比较(31)


redirectUri.getHost() ) == false )
{
// This registered redirect URI does not match.
continue;

// Compare the port parts. Here I use an imaginary
// method 'getPortOrDefaultPort()' because the
// code would become too long if I inlined it. The
// method returns the default port number of the
// scheme when 'getPort()' returns -1. The last
// resort is 'URI.toURL().getDefaultPort()'. -1 is
// returned If 'getDefaultPort()' throws an exception.
if ( getPortOrDefaultPort( registeredRedirectUri ) !=
getPortOrDefaultPort( redirectUri ) )
{
// This registered redirect URI does not match.
continue;

// Compare the path parts. Here I use the imaginary
// method 'equalsSafely()' again.
if ( equalsSafely( registeredRedirectUri.getPath()
redirectUri.getPath() ) == false )
{
// This registered redirect URI does not match.
continue;

// The specified redirect URI is registered.
registered = true;
break;

推荐阅读