ikrs.httpd
Class CustomUtil

java.lang.Object
  extended by ikrs.httpd.CustomUtil

public class CustomUtil
extends java.lang.Object

This class holds some helper methods.


Constructor Summary
CustomUtil()
           
 
Method Summary
static java.lang.String bytes2hexString(byte[] arr)
           
static boolean classImplementsInterface(java.lang.Class<?> c, java.lang.String interfaceName, boolean includeSuperClasses)
           
static boolean equalFileExtensions(java.lang.String extensionA, java.lang.String extensionB, boolean caseSensitive, boolean dotSensitive)
           
static boolean getBoolean(CustomLogger logger, BasicType wrapper, boolean nullSubstitute)
           
static java.lang.String getFileExtension(java.io.File file)
           
static byte[] hex2bytes(java.lang.String hex)
           
static int hex2int(char hex)
           
static java.lang.String implode(java.util.List<java.lang.String> values, java.lang.String separator)
          This method implodes the given String-list with the given separator by the use of a StringBuffer.
static java.lang.String implode(java.lang.String[] values, java.lang.String separator)
          This method implodes the given String-array with the given separator by the use of a StringBuffer.
static boolean isApacheMD5(java.lang.String str)
          This method checks if the passed string is in the Apache-MD5 format (such as hashes are stored in apache's htaccess-files).
static boolean isMD5(java.lang.String str)
          This method checks if the passed string represents an MD5 checksum.
static char lowerNibble2hexChar(byte b)
           
static void main(java.lang.String[] argv)
           
static java.util.Map<java.lang.String,java.lang.String> parseDigestAuthorizationChallenge(java.lang.String line)
          This method parses the "Digest" authorization response (sent by the client).
static java.lang.String processCustomizedFilePath(java.lang.String filePath)
           
static java.lang.String repeat(java.lang.String token, int count)
          This method repeats the given token by concatenating it 'count' times with itself.
static int[] string2int(java.lang.String[] splits)
           
static java.lang.String stripQuotes(java.lang.String str)
           
static long transfer(java.io.InputStream in, java.io.OutputStream out, long maxReadLength, int bufferSize)
           
static char upperNibble2hexChar(byte b)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CustomUtil

public CustomUtil()
Method Detail

getBoolean

public static boolean getBoolean(CustomLogger logger,
                                 BasicType wrapper,
                                 boolean nullSubstitute)

getFileExtension

public static java.lang.String getFileExtension(java.io.File file)
                                         throws java.lang.NullPointerException
Throws:
java.lang.NullPointerException

processCustomizedFilePath

public static java.lang.String processCustomizedFilePath(java.lang.String filePath)

equalFileExtensions

public static boolean equalFileExtensions(java.lang.String extensionA,
                                          java.lang.String extensionB,
                                          boolean caseSensitive,
                                          boolean dotSensitive)

classImplementsInterface

public static boolean classImplementsInterface(java.lang.Class<?> c,
                                               java.lang.String interfaceName,
                                               boolean includeSuperClasses)

isMD5

public static boolean isMD5(java.lang.String str)
                     throws java.lang.NullPointerException
This method checks if the passed string represents an MD5 checksum. The passed string must not be null.

Throws:
java.lang.NullPointerException

isApacheMD5

public static boolean isApacheMD5(java.lang.String str)
                           throws java.lang.NullPointerException
This method checks if the passed string is in the Apache-MD5 format (such as hashes are stored in apache's htaccess-files). The passed string must not be null.

Throws:
java.lang.NullPointerException

implode

public static java.lang.String implode(java.lang.String[] values,
                                       java.lang.String separator)
This method implodes the given String-array with the given separator by the use of a StringBuffer.

Parameters:
values - The array to implode.
separator - The separator string to use.
Returns:
A new String with the format: values[0] + separator + values[1] + separator + ... + separator + values[n].

implode

public static java.lang.String implode(java.util.List<java.lang.String> values,
                                       java.lang.String separator)
This method implodes the given String-list with the given separator by the use of a StringBuffer.

Parameters:
values - The list to implode.
separator - The separator string to use.
Returns:
A new String with the format: values.get(0) + separator + values.get(1) + separator + ... + separator + values.get(n).

repeat

public static java.lang.String repeat(java.lang.String token,
                                      int count)
This method repeats the given token by concatenating it 'count' times with itself. return 'count' times tehe given token in a new string.


parseDigestAuthorizationChallenge

public static java.util.Map<java.lang.String,java.lang.String> parseDigestAuthorizationChallenge(java.lang.String line)
This method parses the "Digest" authorization response (sent by the client). Such a response line has the format: [ pair0 [ "," pair1 [ "," pair2 [...] ] ] ] pair := key "=" value key := token value := token | quoted_string token := quoted_string := '"' '"' | "'" "'" Example: username="keel", realm="Password Required", nonce="123456", uri="/secret", algorithm=MD5, response="c21340f3fdd7194ab8e397ff1a9a750f" The returned map will contain the parsed key-tuple-pairs. The key comparator is not case-sensitive.


stripQuotes

public static java.lang.String stripQuotes(java.lang.String str)

string2int

public static int[] string2int(java.lang.String[] splits)
                        throws java.lang.NullPointerException,
                               java.lang.NumberFormatException
Throws:
java.lang.NullPointerException
java.lang.NumberFormatException

hex2bytes

public static byte[] hex2bytes(java.lang.String hex)
                        throws java.lang.NumberFormatException
Throws:
java.lang.NumberFormatException

hex2int

public static int hex2int(char hex)
                   throws java.lang.NumberFormatException
Throws:
java.lang.NumberFormatException

bytes2hexString

public static java.lang.String bytes2hexString(byte[] arr)

lowerNibble2hexChar

public static char lowerNibble2hexChar(byte b)

upperNibble2hexChar

public static char upperNibble2hexChar(byte b)

transfer

public static long transfer(java.io.InputStream in,
                            java.io.OutputStream out,
                            long maxReadLength,
                            int bufferSize)
                     throws java.lang.IllegalArgumentException,
                            java.io.IOException
Throws:
java.lang.IllegalArgumentException
java.io.IOException

main

public static void main(java.lang.String[] argv)