Class CaptchaImageResource
- java.lang.Object
-
- org.apache.wicket.request.resource.AbstractResource
-
- org.apache.wicket.request.resource.DynamicImageResource
-
- org.apache.wicket.extensions.markup.html.captcha.CaptchaImageResource
-
- All Implemented Interfaces:
Serializable
,IResource
,IClusterable
public class CaptchaImageResource extends DynamicImageResource
Generates a captcha image.- Author:
- Joshua Perlow
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.wicket.request.resource.AbstractResource
AbstractResource.ContentRangeType, AbstractResource.ResourceResponse, AbstractResource.WriteCallback
-
Nested classes/interfaces inherited from interface org.apache.wicket.request.resource.IResource
IResource.Attributes
-
-
Field Summary
-
Fields inherited from class org.apache.wicket.request.resource.AbstractResource
CONTENT_DISPOSITION_HEADER_NAME, CONTENT_RANGE_ENDBYTE, CONTENT_RANGE_STARTBYTE, INTERNAL_HEADERS
-
-
Constructor Summary
Constructors Constructor Description CaptchaImageResource()
Construct.CaptchaImageResource(String challengeId)
Construct.CaptchaImageResource(String challengeId, int fontSize, int margin)
Construct.CaptchaImageResource(IModel<String> challengeId)
Construct.CaptchaImageResource(IModel<String> challengeId, int fontSize, int margin)
Construct.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getChallengeId()
Gets the id for the challenge.IModel<String>
getChallengeIdModel()
Gets the id for the challengeprotected byte[]
getImageData(IResource.Attributes attributes)
Get image data for our dynamic image resource.void
invalidate()
Causes the image to be redrawn the next time its requested.protected Random
newRandomNumberGenerator()
protected byte[]
render()
Renders this image-
Methods inherited from class org.apache.wicket.request.resource.DynamicImageResource
configureResponse, getFormat, newResourceResponse, setFormat, setLastModifiedTime, toImageData
-
Methods inherited from class org.apache.wicket.request.resource.AbstractResource
configureCache, getCachingStrategy, respond, setRequestMetaData, setRequestRangeMetaData, setResponseContentRangeHeaderFields, setResponseHeaders
-
-
-
-
Constructor Detail
-
CaptchaImageResource
public CaptchaImageResource()
Construct.
-
CaptchaImageResource
public CaptchaImageResource(String challengeId)
Construct.- Parameters:
challengeId
- The id of the challenge
-
CaptchaImageResource
public CaptchaImageResource(IModel<String> challengeId)
Construct.- Parameters:
challengeId
- The id of the challenge
-
CaptchaImageResource
public CaptchaImageResource(IModel<String> challengeId, int fontSize, int margin)
Construct.- Parameters:
challengeId
- The id of the challengefontSize
- The font sizemargin
- The image's margin
-
CaptchaImageResource
public CaptchaImageResource(String challengeId, int fontSize, int margin)
Construct.- Parameters:
challengeId
- The id of the challengefontSize
- The font sizemargin
- The image's margin
-
-
Method Detail
-
newRandomNumberGenerator
protected Random newRandomNumberGenerator()
-
getChallengeId
public final String getChallengeId()
Gets the id for the challenge.- Returns:
- The id for the challenge
-
getChallengeIdModel
public final IModel<String> getChallengeIdModel()
Gets the id for the challenge- Returns:
- The id for the challenge
-
invalidate
public final void invalidate()
Causes the image to be redrawn the next time its requested.
-
getImageData
protected final byte[] getImageData(IResource.Attributes attributes)
Description copied from class:DynamicImageResource
Get image data for our dynamic image resource. If the subclass regenerates the data, it should set theDynamicImageResource.setLastModifiedTime(Instant)
when it does so. This ensures that image caching works correctly.- Specified by:
getImageData
in classDynamicImageResource
- Parameters:
attributes
- the context bringing the request, response and the parameters- Returns:
- The image data for this dynamic image.
null
means there is no image and 404 (Not found) response will be return.
-
render
protected byte[] render()
Renders this image- Returns:
- The image data
-
-