captcha
Class ZipBinaryImageCaptchaGenerator

java.lang.Object
  extended by captcha.ZipBinaryImageCaptchaGenerator
All Implemented Interfaces:
ICaptchaGenerator

public class ZipBinaryImageCaptchaGenerator
extends java.lang.Object
implements ICaptchaGenerator

This class creates zipped binary image captchas (the embedded text is visible on an image in our own binary image format).


Field Summary
private static java.lang.String CAPTCHA_DATA_FORMAT
          This is the format of the captcha data.
private static java.lang.String DEFAULT_FONT
          This is the font for drawing the text.
private  int m_height
          Stores the height in pixels all generated images will have.
private  int m_width
          Stores the width in pixels all generated images will have.
private static java.lang.String VALID_TEXT_CHARACTERS
          This is the string of valid captcha characters.
 
Constructor Summary
ZipBinaryImageCaptchaGenerator(int a_width, int a_height)
          Creates a new instance of ZipBinaryImageCaptchaGenerator.
 
Method Summary
 java.lang.String createCaptcha(java.lang.String a_embeddedText)
          Creates a new zipped binary image captcha and returns the image as Base64 encoded String.
private  java.awt.Image generateCaptchaImage(java.lang.String a_embeddedText)
          Creates a captcha image, which shows the specified text.
 java.lang.String getCaptchaDataFormat()
          Returns the format of the captcha data (ZIP_BINARY_IMAGE).
 int getMaximumStringLength()
          Returns the maximum number of characters of the captcha generators alphabet, which are supported as input when creating a captcha.
 java.lang.String getValidCharacters()
          Returns the string of valid captcha characters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_FONT

private static final java.lang.String DEFAULT_FONT
This is the font for drawing the text.

See Also:
Constant Field Values

VALID_TEXT_CHARACTERS

private static final java.lang.String VALID_TEXT_CHARACTERS
This is the string of valid captcha characters. The data which are included in the captcha can be words over this alphabet.

See Also:
Constant Field Values

CAPTCHA_DATA_FORMAT

private static final java.lang.String CAPTCHA_DATA_FORMAT
This is the format of the captcha data. So the JAP client of the blockee can present the data correctly.

See Also:
Constant Field Values

m_width

private int m_width
Stores the width in pixels all generated images will have.


m_height

private int m_height
Stores the height in pixels all generated images will have.

Constructor Detail

ZipBinaryImageCaptchaGenerator

public ZipBinaryImageCaptchaGenerator(int a_width,
                                      int a_height)
Creates a new instance of ZipBinaryImageCaptchaGenerator. All created captchas will have the size specified here.

Parameters:
a_width - The width in pixels all generated images will have.
a_height - The height in pixels all generated images will have.
Method Detail

createCaptcha

public java.lang.String createCaptcha(java.lang.String a_embeddedText)
                               throws java.lang.Exception
Creates a new zipped binary image captcha and returns the image as Base64 encoded String. If there is an error when creating the captcha (maybe you have specified invalid sizes in the constructor or the text to embed is to long, ...) an Exception is thrown.

Specified by:
createCaptcha in interface ICaptchaGenerator
Parameters:
a_embeddedText - The text which shall be visible in the zipped binary image.
Returns:
A Base64 encoded zipped binary image.
Throws:
java.lang.Exception

getValidCharacters

public java.lang.String getValidCharacters()
Returns the string of valid captcha characters. The data which are included in the captcha can be words over this alphabet.

Specified by:
getValidCharacters in interface ICaptchaGenerator
Returns:
An alphabet with characters this CaptchaGenerator supports.

getCaptchaDataFormat

public java.lang.String getCaptchaDataFormat()
Returns the format of the captcha data (ZIP_BINARY_IMAGE). So the JAP client of the blockee can present the data correctly.

Specified by:
getCaptchaDataFormat in interface ICaptchaGenerator
Returns:
A string with the data format of the captcha ("ZIP_BINARY_IMAGE").

getMaximumStringLength

public int getMaximumStringLength()
Returns the maximum number of characters of the captcha generators alphabet, which are supported as input when creating a captcha.

Specified by:
getMaximumStringLength in interface ICaptchaGenerator
Returns:
The maximum captcha generator input word length.

generateCaptchaImage

private java.awt.Image generateCaptchaImage(java.lang.String a_embeddedText)
                                     throws java.lang.Exception
Creates a captcha image, which shows the specified text.

Parameters:
a_embeddedText - The text, which shall be visible on the captcha image.
Returns:
The captcha image, which shows the text.
Throws:
java.lang.Exception