org.opencms.frontend.templateone.form
Class CmsCaptchaSettings

java.lang.Object
  extended by org.opencms.frontend.templateone.form.CmsCaptchaSettings
All Implemented Interfaces:
java.lang.Cloneable

public final class CmsCaptchaSettings
extends java.lang.Object
implements java.lang.Cloneable

Stores the settings to render captcha images.


Field Summary
static java.lang.String C_PARAM_BACKGROUND_COLOR
          Request parameter for the background color.
static java.lang.String C_PARAM_CHARACTERS
          Request parameter for the min phrase length.
static java.lang.String C_PARAM_FILTER_AMPLITUDE
          Request parameter for the filter amplitude.
static java.lang.String C_PARAM_FILTER_WAVE_LENGTH
          Request parameter for the filter amplitude.
static java.lang.String C_PARAM_FONT_COLOR
          Request parameter for the font color.
static java.lang.String C_PARAM_HOLES_PER_GLYPH
          Request parameter for the font color.
static java.lang.String C_PARAM_IMAGE_HEIGHT
          Request parameter for the image height.
static java.lang.String C_PARAM_IMAGE_WIDTH
          Request parameter for the image width.
static java.lang.String C_PARAM_MAX_FONT_SIZE
          Request parameter for the max. font size.
static java.lang.String C_PARAM_MAX_PHRASE_LENGTH
          Request parameter for the max phrase length.
static java.lang.String C_PARAM_MIN_FONT_SIZE
          Request parameter for the min. font size.
static java.lang.String C_PARAM_MIN_PHRASE_LENGTH
          Request parameter for the min phrase length.
static java.lang.String C_PARAM_PRESET
          Request parameter for the min phrase length.
static java.lang.String C_PARAM_USE_BACKGROUND_IMAGE
          Request parameter for the min phrase length.
static java.lang.String NODE_CAPTCHAPRESET_BACKGROUNDCOLOR
          Configuration node name for the optional captcha background color.
static java.lang.String NODE_CAPTCHAPRESET_FILTER_AMPLITUDE
          Configuration node name for the field value node.
static java.lang.String NODE_CAPTCHAPRESET_FILTER_WAVELENGTH
          Configuration node name for the optional captcha image holes per glyph.
static java.lang.String NODE_CAPTCHAPRESET_FONTCOLOR
          Configuration node name for the optional captcha font color.
static java.lang.String NODE_CAPTCHAPRESET_HOLESPERGLYPH
          Configuration node name for the optional captcha image holes per glyph.
static java.lang.String NODE_CAPTCHAPRESET_IMAGEHEIGHT
          Configuration node name for the optional captcha image height.
static java.lang.String NODE_CAPTCHAPRESET_IMAGEWIDTH
          Configuration node name for the optional captcha image width.
static java.lang.String NODE_CAPTCHAPRESET_MAX_FONT_SIZE
          Configuration node name for the optional captcha max. font size.
static java.lang.String NODE_CAPTCHAPRESET_MAX_PHRASE_LENGTH
          Configuration node name for the optional captcha max. phrase length.
static java.lang.String NODE_CAPTCHAPRESET_MIN_FONT_SIZE
          Configuration node name for the optional captcha min. font size.
static java.lang.String NODE_CAPTCHAPRESET_MIN_PHRASE_LENGTH
          Configuration node name for the optional captcha min. phrase length.
 
Method Summary
protected  java.lang.Object clone()
           
 java.awt.Color getBackgroundColor()
          Returns the background color.
 java.lang.String getBackgroundColorString()
          Returns the background color as a hex string.
 int getFilterAmplitude()
          Returns the filter amplitude for the water filter that bends the text.
 int getFilterWaveLength()
          Returns the filter wave length for the water filter that bends the text.
 java.awt.Color getFontColor()
          Returns the font color.
 java.lang.String getFontColorString()
          Returns the font color as a hex string.
 java.lang.Integer getHolesPerGlyph()
          Returns the holes per glyph for a captcha image text (distortion).
 int getImageHeight()
          Returns the image height.
 int getImageWidth()
          Returns the image width.
static CmsCaptchaSettings getInstance(org.opencms.jsp.CmsJspActionElement jsp)
          Returns a clone of the singleton instance of the "master" CmsCaptchaSettings and potential overridden values from the request context.
 int getMaxFontSize()
          Returns the max. font size.
 int getMaxPhraseLength()
          Returns the max. phrase length.
 int getMinFontSize()
          Returns the min. font size.
 int getMinPhraseLength()
          Returns the min. phrase length.
 void init(org.opencms.jsp.CmsJspActionElement jsp)
          Configures the instance with values overridden from the the request parameters.
 void init(org.opencms.file.CmsObject cms, org.opencms.xml.content.CmsXmlContent content, java.util.Locale locale)
          Configures the instance with overridden values from the given XML content.
 boolean isUseBackgroundImage()
          Returns the flag that decides wethter a background image or a background color is used.
 void setBackgroundColor(java.awt.Color backgroundColor)
          Sets the background color.
 void setBackgroundColor(java.lang.String backgroundColor)
          Sets the background color as a hex string.
 void setFilterAmplitude(int i)
          Sets the filter amplitude for the water filter that will bend the text.
 void setFilterWaveLength(int filterWaveLength)
          Sets the filter wave length for the water filter that bends the text.
 void setFontColor(java.awt.Color fontColor)
          Sets the font color.
 void setFontColor(java.lang.String fontColor)
          Sets the font color as a hex string.
 void setHolesPerGlyph(int holes)
          Sets the holes per glyph for a captcha image text (distortion).
 void setImageHeight(int imageHeight)
          Sets the image height.
 void setImageWidth(int imageWidth)
          Sets the image width.
 void setMaxFontSize(int maxFontSize)
          Sets the max. font size.
 void setMaxPhraseLength(int maxPhraseLength)
          Sets the max. phrase length.
 void setMinFontSize(int minFontSize)
          Sets the min. font size.
 void setMinPhraseLength(int minPhraseLength)
          Sets the min. phrase length.
 void setUseBackgroundImage(boolean useBackgroundImage)
          Returns the flag that decides wethter a background image or a background color is used.
 java.lang.String toRequestParams(org.opencms.file.CmsObject cms)
          Creates a request parameter string from including all captcha settings.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

C_PARAM_BACKGROUND_COLOR

public static final java.lang.String C_PARAM_BACKGROUND_COLOR
Request parameter for the background color.

See Also:
Constant Field Values

C_PARAM_CHARACTERS

public static final java.lang.String C_PARAM_CHARACTERS
Request parameter for the min phrase length.

See Also:
Constant Field Values

C_PARAM_FILTER_AMPLITUDE

public static final java.lang.String C_PARAM_FILTER_AMPLITUDE
Request parameter for the filter amplitude.

See Also:
Constant Field Values

C_PARAM_FILTER_WAVE_LENGTH

public static final java.lang.String C_PARAM_FILTER_WAVE_LENGTH
Request parameter for the filter amplitude.

See Also:
Constant Field Values

C_PARAM_FONT_COLOR

public static final java.lang.String C_PARAM_FONT_COLOR
Request parameter for the font color.

See Also:
Constant Field Values

C_PARAM_HOLES_PER_GLYPH

public static final java.lang.String C_PARAM_HOLES_PER_GLYPH
Request parameter for the font color.

See Also:
Constant Field Values

C_PARAM_IMAGE_HEIGHT

public static final java.lang.String C_PARAM_IMAGE_HEIGHT
Request parameter for the image height.

See Also:
Constant Field Values

C_PARAM_IMAGE_WIDTH

public static final java.lang.String C_PARAM_IMAGE_WIDTH
Request parameter for the image width.

See Also:
Constant Field Values

C_PARAM_MAX_FONT_SIZE

public static final java.lang.String C_PARAM_MAX_FONT_SIZE
Request parameter for the max. font size.

See Also:
Constant Field Values

C_PARAM_MAX_PHRASE_LENGTH

public static final java.lang.String C_PARAM_MAX_PHRASE_LENGTH
Request parameter for the max phrase length.

See Also:
Constant Field Values

C_PARAM_MIN_FONT_SIZE

public static final java.lang.String C_PARAM_MIN_FONT_SIZE
Request parameter for the min. font size.

See Also:
Constant Field Values

C_PARAM_MIN_PHRASE_LENGTH

public static final java.lang.String C_PARAM_MIN_PHRASE_LENGTH
Request parameter for the min phrase length.

See Also:
Constant Field Values

C_PARAM_PRESET

public static final java.lang.String C_PARAM_PRESET
Request parameter for the min phrase length.

See Also:
Constant Field Values

C_PARAM_USE_BACKGROUND_IMAGE

public static final java.lang.String C_PARAM_USE_BACKGROUND_IMAGE
Request parameter for the min phrase length.

See Also:
Constant Field Values

NODE_CAPTCHAPRESET_BACKGROUNDCOLOR

public static final java.lang.String NODE_CAPTCHAPRESET_BACKGROUNDCOLOR
Configuration node name for the optional captcha background color.

See Also:
Constant Field Values

NODE_CAPTCHAPRESET_FILTER_AMPLITUDE

public static final java.lang.String NODE_CAPTCHAPRESET_FILTER_AMPLITUDE
Configuration node name for the field value node.

See Also:
Constant Field Values

NODE_CAPTCHAPRESET_FILTER_WAVELENGTH

public static final java.lang.String NODE_CAPTCHAPRESET_FILTER_WAVELENGTH
Configuration node name for the optional captcha image holes per glyph.

See Also:
Constant Field Values

NODE_CAPTCHAPRESET_FONTCOLOR

public static final java.lang.String NODE_CAPTCHAPRESET_FONTCOLOR
Configuration node name for the optional captcha font color.

See Also:
Constant Field Values

NODE_CAPTCHAPRESET_HOLESPERGLYPH

public static final java.lang.String NODE_CAPTCHAPRESET_HOLESPERGLYPH
Configuration node name for the optional captcha image holes per glyph.

See Also:
Constant Field Values

NODE_CAPTCHAPRESET_IMAGEHEIGHT

public static final java.lang.String NODE_CAPTCHAPRESET_IMAGEHEIGHT
Configuration node name for the optional captcha image height.

See Also:
Constant Field Values

NODE_CAPTCHAPRESET_IMAGEWIDTH

public static final java.lang.String NODE_CAPTCHAPRESET_IMAGEWIDTH
Configuration node name for the optional captcha image width.

See Also:
Constant Field Values

NODE_CAPTCHAPRESET_MAX_FONT_SIZE

public static final java.lang.String NODE_CAPTCHAPRESET_MAX_FONT_SIZE
Configuration node name for the optional captcha max. font size.

See Also:
Constant Field Values

NODE_CAPTCHAPRESET_MAX_PHRASE_LENGTH

public static final java.lang.String NODE_CAPTCHAPRESET_MAX_PHRASE_LENGTH
Configuration node name for the optional captcha max. phrase length.

See Also:
Constant Field Values

NODE_CAPTCHAPRESET_MIN_FONT_SIZE

public static final java.lang.String NODE_CAPTCHAPRESET_MIN_FONT_SIZE
Configuration node name for the optional captcha min. font size.

See Also:
Constant Field Values

NODE_CAPTCHAPRESET_MIN_PHRASE_LENGTH

public static final java.lang.String NODE_CAPTCHAPRESET_MIN_PHRASE_LENGTH
Configuration node name for the optional captcha min. phrase length.

See Also:
Constant Field Values
Method Detail

getInstance

public static CmsCaptchaSettings getInstance(org.opencms.jsp.CmsJspActionElement jsp)
Returns a clone of the singleton instance of the "master" CmsCaptchaSettings and potential overridden values from the request context.

The "master" CmsCaptchaSettings are read from an XML content that contains the global defaults.

Parameters:
jsp - used to potentially access the XML content with the default captcha settings and to read overriden values from the request parameters.
Returns:
a clone of the singleton instance of the "master" CmsCaptchaSettings.

getBackgroundColor

public java.awt.Color getBackgroundColor()
Returns the background color.

Returns:
the background color

getBackgroundColorString

public java.lang.String getBackgroundColorString()
Returns the background color as a hex string.

Returns:
the background color as a hex string

getFilterAmplitude

public int getFilterAmplitude()
Returns the filter amplitude for the water filter that bends the text.

Returns:
the filter amplitude for the water filter that bends the text.

getFilterWaveLength

public int getFilterWaveLength()
Returns the filter wave length for the water filter that bends the text.

Returns:
the filter wave length for the water filter that bends the text.

getFontColor

public java.awt.Color getFontColor()
Returns the font color.

Returns:
the font color

getFontColorString

public java.lang.String getFontColorString()
Returns the font color as a hex string.

Returns:
the font color as a hex string

getHolesPerGlyph

public java.lang.Integer getHolesPerGlyph()
Returns the holes per glyph for a captcha image text (distortion).

Returns:
the holes per glyph for a captcha image text

getImageHeight

public int getImageHeight()
Returns the image height.

Returns:
the image height

getImageWidth

public int getImageWidth()
Returns the image width.

Returns:
the image width

getMaxFontSize

public int getMaxFontSize()
Returns the max. font size.

Returns:
the max. font size

getMaxPhraseLength

public int getMaxPhraseLength()
Returns the max. phrase length.

Returns:
the max. phrase length

getMinFontSize

public int getMinFontSize()
Returns the min. font size.

Returns:
the min. font size

getMinPhraseLength

public int getMinPhraseLength()
Returns the min. phrase length.

Returns:
the min. phrase length

init

public void init(org.opencms.jsp.CmsJspActionElement jsp)
Configures the instance with values overridden from the the request parameters.

Parameters:
jsp - a Cms JSP page
See Also:
C_PARAM_BACKGROUND_COLOR, C_PARAM_FILTER_AMPLITUDE

init

public void init(org.opencms.file.CmsObject cms,
                 org.opencms.xml.content.CmsXmlContent content,
                 java.util.Locale locale)
Configures the instance with overridden values from the given XML content.

Xmlcontent configuration notes

    • If the xmlcontent contains no node for BackgroundColor (NODE_CAPTCHAPRESET_BACKGROUNDCOLOR), a background image will be used.
    • If the xmlcontent node contains an empty node (trimmable to the empty String), the default background colour Color.WHITE) will be used as background.
    • Else the chosen background color will be used.

Parameters:
cms - the current user's Cms object
content - the XML content of the form
locale - the current locale

isUseBackgroundImage

public boolean isUseBackgroundImage()
Returns the flag that decides wethter a background image or a background color is used.

Returns:
the flag that decides wethter a background image or a background color is used

setBackgroundColor

public void setBackgroundColor(java.awt.Color backgroundColor)
Sets the background color.

Parameters:
backgroundColor - the background color to set

setBackgroundColor

public void setBackgroundColor(java.lang.String backgroundColor)
Sets the background color as a hex string.

Parameters:
backgroundColor - the background color to set as a hex string

setFilterAmplitude

public void setFilterAmplitude(int i)
Sets the filter amplitude for the water filter that will bend the text.

Parameters:
i - the filter amplitude for the water filter that will bend the text to set.

setFilterWaveLength

public void setFilterWaveLength(int filterWaveLength)
Sets the filter wave length for the water filter that bends the text.

Parameters:
filterWaveLength - the filter wave length for the water filter that bends the text to set

setFontColor

public void setFontColor(java.awt.Color fontColor)
Sets the font color.

Parameters:
fontColor - the font color to set

setFontColor

public void setFontColor(java.lang.String fontColor)
Sets the font color as a hex string.

Parameters:
fontColor - the font color to set as a hex string

setHolesPerGlyph

public void setHolesPerGlyph(int holes)
Sets the holes per glyph for a captcha image text (distortion).

Parameters:
holes - the holes per glyph for a captcha image text to set.

setImageHeight

public void setImageHeight(int imageHeight)
Sets the image height.

Parameters:
imageHeight - the image height to set

setImageWidth

public void setImageWidth(int imageWidth)
Sets the image width.

Parameters:
imageWidth - the image width to set

setMaxFontSize

public void setMaxFontSize(int maxFontSize)
Sets the max. font size.

Parameters:
maxFontSize - the max. font size to set

setMaxPhraseLength

public void setMaxPhraseLength(int maxPhraseLength)
Sets the max. phrase length.

Parameters:
maxPhraseLength - the max. phrase length to set

setMinFontSize

public void setMinFontSize(int minFontSize)
Sets the min. font size.

Parameters:
minFontSize - the min. font size to set

setMinPhraseLength

public void setMinPhraseLength(int minPhraseLength)
Sets the min. phrase length.

Parameters:
minPhraseLength - the min. phrase length to set

setUseBackgroundImage

public void setUseBackgroundImage(boolean useBackgroundImage)
Returns the flag that decides wethter a background image or a background color is used.

Parameters:
useBackgroundImage - the flag that decides wethter a background image or a background color is used.

toRequestParams

public java.lang.String toRequestParams(org.opencms.file.CmsObject cms)
Creates a request parameter string from including all captcha settings.

Parameters:
cms - needed for the context / encoding
Returns:
a request parameter string from including all captcha settings

clone

protected java.lang.Object clone()
Overrides:
clone in class java.lang.Object
See Also:
Object.clone()