ikrs.io.fileio.htaccess
Class HypertextPasswordFile

java.lang.Object
  extended by ikrs.io.fileio.htaccess.HypertextPasswordFile

public class HypertextPasswordFile
extends java.lang.Object

This is a simple class for checking/reading htpassword files.


Method Summary
static char[] getPasswordData(java.io.File file, java.lang.String username, boolean strictMode)
          Tries to load the password data for the given user.
static char[] getPasswordData(java.io.InputStream in, java.lang.String username, boolean strictMode)
          Tries to load the password data for the given user.
static char[] getPasswordData(java.io.LineNumberReader lnr, java.lang.String username, boolean strictMode)
          Tries to load the password data for the given user.
static void main(java.lang.String[] argv)
          For testing only.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getPasswordData

public static char[] getPasswordData(java.io.File file,
                                     java.lang.String username,
                                     boolean strictMode)
                              throws java.io.IOException,
                                     java.text.ParseException
Tries to load the password data for the given user. If the desired user cannot be found in the file this method will return null.

Parameters:
file - The input file (must be a text file in .htpasswd format).
username - The user's name.
strictMode - If this mode is set to true the reader will NOT ignore any unknown/unexpected irregularities but throw a ParseException.
Throws:
java.io.IOException - If any IO errors occur.
java.text.ParseException - If the passed file cannot be parsed or is not a htpasswd file.

getPasswordData

public static char[] getPasswordData(java.io.InputStream in,
                                     java.lang.String username,
                                     boolean strictMode)
                              throws java.io.IOException,
                                     java.text.ParseException
Tries to load the password data for the given user. If the desired user cannot be found in the file this method will return null.

Parameters:
file - The input file (must be a text file in .htpasswd format).
username - The user's name.
strictMode - If this mode is set to true the reader will NOT ignore any unknown/unexpected irregularities but throw a ParseException.
Throws:
java.io.IOException - If any IO errors occur.
java.text.ParseException - If the passed file cannot be parsed or is not a htpasswd file.

getPasswordData

public static char[] getPasswordData(java.io.LineNumberReader lnr,
                                     java.lang.String username,
                                     boolean strictMode)
                              throws java.io.IOException,
                                     java.text.ParseException
Tries to load the password data for the given user. If the desired user cannot be found in the file this method will return null.

Parameters:
file - The input file (must be a text file in .htpasswd format).
username - The user's name.
strictMode - If this mode is set to true the reader will NOT ignore any unknown/unexpected irregularities but throw a ParseException.
Throws:
java.io.IOException - If any IO errors occur.
java.text.ParseException - If the passed file cannot be parsed or is not a htpasswd file.

main

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