Package com.sun.identity.shared.encode
Class URLEncDec
- java.lang.Object
-
- com.sun.identity.shared.encode.URLEncDec
-
public class URLEncDec extends Object
-
-
Constructor Summary
Constructors Constructor Description URLEncDec()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringappendQueryParameter(String url, String name, String value)Puts a query parameter on a URL, encoding it and keeping it in front of the fragment.static Stringdecode(String s)Decodes aapplication/x-www-form-urlencodedstring using the UTF-8 encoding scheme.static Stringencode(String s)Translates a string intoapplication/x-www-form-urlencodedformat using the UTF-8 encoding scheme.static StringencodeLDAPUrl(String s)static StringencodeUrlPath(String u)
-
-
-
Method Detail
-
encode
public static String encode(String s)
Translates a string intoapplication/x-www-form-urlencodedformat using the UTF-8 encoding scheme. The World Wide Web Consortium Recommendation states that UTF-8 should be used to ensure compatibilities.- Parameters:
s-Stringto be translated.- Returns:
- the translated
String.
-
appendQueryParameter
public static String appendQueryParameter(String url, String name, String value)
Puts a query parameter on a URL, encoding it and keeping it in front of the fragment.A plain concatenation puts the parameter inside the fragment of a URL such as
/openam/XUI/#login, where the server never gets to see it, and leaves any reserved character in the value to be read back as part of the query string.An occurrence of the same name already on the URL is dropped rather than appended next to. Every consumer reads the parameter back with
ServletRequest.getParameter(String), where the first occurrence wins, so a caller who put one there first would otherwise stay in charge of the value.- Parameters:
url- The URL to put the parameter on, may benull.name- The name of the parameter, in its decoded form. Anullor empty name leaves the URL as it stands: there is no parameter to put on it.value- The value of the parameter, in its decoded form. Anullvalue is written as an empty one, the way a parameter carrying nothing is spelled on a query string.- Returns:
- The URL carrying the query parameter, or
nullif the URL was.
-
decode
public static String decode(String s)
Decodes aapplication/x-www-form-urlencodedstring using the UTF-8 encoding scheme. The World Wide Web Consortium Recommendation states that UTF-8 should be used to ensure compatibilities.- Parameters:
s- theStringto decode- Returns:
- the newly decoded
String
-
encodeUrlPath
public static String encodeUrlPath(String u) throws MalformedURLException
- Throws:
MalformedURLException
-
-