public class StringUtilities extends Object
| Constructor and Description |
|---|
StringUtilities() |
| Modifier and Type | Method and Description |
|---|---|
static void |
addValueToHeader(Map<String,List<String>> headers,
String key,
String value,
boolean singleValued)
Adds an header to the provided map of headers.
|
static String |
copyDirective(HashMap<String,String> src,
HashMap<String,String> dst,
String directive)
Copy the directive from the source map to the destination map, if it's
value isn't null.
|
static void |
copyDirective(HashMap<String,String> directives,
StringBuilder sb,
String directive)
Copy the directive to the
StringBuilder if not null. |
static String |
getDirectiveValue(HashMap<String,String> directivesMap,
String directive,
boolean mandatory)
A directive is a parameter of the digest authentication process.
|
static String |
getSingleValuedHeader(Map<String,List<String>> headers,
String key)
Returns the value of the named header.
|
static boolean |
isLws(byte b)
Is character a linear white space ?
LWS = [CRLF] 1*( SP | HT )
Note that we're checking individual bytes instead of CRLF
|
static HashMap<String,String> |
parseDirectives(byte[] buf)
Parses digest-challenge string, extracting each token and value(s).
|
static String |
stringTo8859_1(String str)
Used to convert username-value, passwd or realm to 8859_1 encoding
if all chars in string are within the 8859_1 (Latin 1) encoding range.
|
public static String getDirectiveValue(HashMap<String,String> directivesMap, String directive, boolean mandatory) throws AuthenticationException
AuthenticationException.directivesMap - the directive's mapdirective - the name of the directive we want to retrievemandatory - is the directive mandatoryAuthenticationException - if mandatory is true and if
directivesMap.get(directive) == nullpublic static void copyDirective(HashMap<String,String> directives, StringBuilder sb, String directive)
StringBuilder if not null.
(A directive is a parameter of the digest authentication process.)directives - the directives mapsb - the output bufferdirective - the directive name to look forpublic static String copyDirective(HashMap<String,String> src, HashMap<String,String> dst, String directive)
src - the source mapdst - the destination mapdirective - the directive namepublic static HashMap<String,String> parseDirectives(byte[] buf) throws SaslException
buf - A non-null digest-challenge string.UnsupportedEncodingExceptionSaslException - if the String cannot be parsed according to RFC 2831public static boolean isLws(byte b)
b - the byte to checktrue if it's a linear white spacepublic static String stringTo8859_1(String str) throws UnsupportedEncodingException
str - a non-null StringAuthenticationExceptionUnsupportedEncodingExceptionpublic static String getSingleValuedHeader(Map<String,List<String>> headers, String key)
IllegalArgumentException is thrownheaders - the http headers mapkey - the key of the headerpublic static void addValueToHeader(Map<String,List<String>> headers, String key, String value, boolean singleValued)
headers - the http headers mapkey - the name of the new header to addvalue - the value of the added headersingleValued - if true and the map already contains one value
then it is replaced by the new value. Otherwise it simply adds a new
value to this multi-valued header.