com.nimbusds.oauth2.sdk.util
Class URLUtils

java.lang.Object
  extended by com.nimbusds.oauth2.sdk.util.URLUtils

public class URLUtils
extends Object

URL operations.

Version:
$version$ (2012-05-07)
Author:
Vladimir Dzhuvinov

Field Summary
static String CHARSET
          The default character set.
 
Method Summary
static URL getBaseURL(URL url)
          Gets the base part (protocol, host, port and path) of the specified URL.
static Map<String,String> parseParameters(String query)
          Parses the specified URL query string into a parameter map.
static String serializeParameters(Map<String,String> params)
          Serialises the specified map of parameters into a URL query string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHARSET

public static final String CHARSET
The default character set.

See Also:
Constant Field Values
Method Detail

getBaseURL

public static URL getBaseURL(URL url)
Gets the base part (protocol, host, port and path) of the specified URL.

Parameters:
url - The URL. May be null.
Returns:
The base part of the URL, null if the original URL is null or doesn't specify a protocol.

serializeParameters

public static String serializeParameters(Map<String,String> params)
Serialises the specified map of parameters into a URL query string. The parameter keys and values are application/x-www-form-urlencoded encoded.

Note that the '?' character preceding the query string in GET requests is not included in the returned string.

Example query string:

 response_type=code
 &client_id=s6BhdRkqt3
 &state=xyz
 &redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb
 

The opposite method is parseParameters(java.lang.String).

Parameters:
params - A map of the URL query parameters. May be empty or null.
Returns:
The serialised URL query string, empty if no parameters.

parseParameters

public static Map<String,String> parseParameters(String query)
Parses the specified URL query string into a parameter map. If a parameter has multiple values only the first one will be saved. The parameter keys and values are application/x-www-form-urlencoded decoded.

Note that the '?' character preceding the query string in GET requests must not be included.

Example query string:

 response_type=code
 &client_id=s6BhdRkqt3
 &state=xyz
 &redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb
 

The opposite method serializeParameters(java.util.Map).

Parameters:
query - The URL query string to parse. May be null.
Returns:
A map of the URL query parameters, empty if none are found.


Copyright © 2013 NimbusDS. All Rights Reserved.