public static String normalizeUrl(String requestUrl) throws OAuthException {
  if ((requestUrl == null) || (requestUrl.length() == 0)) {
    throw new OAuthException("Request Url cannot be empty");
  }
  URI uri;
  try {
    uri=new URI(requestUrl);
  }
 catch (  URISyntaxException e) {
    throw new OAuthException(e);
  }
  String authority=uri.getAuthority();
  String scheme=uri.getScheme();
  if (authority == null || scheme == null) {
    throw new OAuthException("Invalid Request Url");
  }
  authority=authority.toLowerCase();
  scheme=scheme.toLowerCase();
  if ((scheme.equals("http") && uri.getPort() == 80) || (scheme.equals("https") && uri.getPort() == 443)) {
    int index=authority.lastIndexOf(":");
    if (index >= 0) {
      authority=authority.substring(0,index);
    }
  }
  return scheme + "://" + authority+ uri.getRawPath();
}

public static String normalizeUrl ( String requestUrl ) throws OAuthException { if ( ( requestUrl == null ) || ( requestUrl . length ( ) == 0 ) ) { throw new OAuthException ( "Request Url cannot be empty" ) ; } URI uri ; try { uri = new URI ( requestUrl ) ; } catch ( URISyntaxException e ) { throw new OAuthException ( e ) ; } String authority = uri . getAuthority ( ) ; String scheme = uri . getScheme ( ) ; if ( authority == null || scheme == null ) { throw new OAuthException ( "Invalid Request Url" ) ; } authority = authority . toLowerCase ( ) ; scheme = scheme . toLowerCase ( ) ; if ( ( scheme . equals ( "http" ) && uri . getPort ( ) == 80 ) || ( scheme . equals ( "https" ) && uri . getPort ( ) == 443 ) ) { int index = authority . lastIndexOf ( ":" ) ; if ( index >= 0 ) { authority = authority . substring ( 0 , index ) ; } } return scheme + "://" + authority + uri . getRawPath ( ) ; }
calculates the normalized request url , as per section 9 . 1 . 2 of the oauth spec . this removes the querystring from the url and the port ( if it is the standard http or https port ) .
