com.planet_ink.coffee_mud.WebMacros
Class ImageVerificationImage

java.lang.Object
  extended by com.planet_ink.coffee_mud.WebMacros.StdWebMacro
      extended by com.planet_ink.coffee_mud.WebMacros.ImageVerificationImage
All Implemented Interfaces:
CMObject, WebMacro, java.lang.Cloneable, java.lang.Comparable<CMObject>

public class ImageVerificationImage
extends StdWebMacro

ImageVerification is a simple utility class for creating an image verification PNG file that will allow you to make sure that only a human can read the alphanumeric values and enter them into a text field during verification. Make sure that when you can getVerificationCode you don't encode the value in the URL or inside the HTML form - otherwise, this whole excerise is pointless (dummy!).


Nested Class Summary
static class ImageVerificationImage.ImgCacheEntry
           
 
Field Summary
static java.lang.Object sync
           
 
Constructor Summary
ImageVerificationImage()
           
ImageVerificationImage(int height, int width, java.lang.String oldValue, java.io.OutputStream out)
           
ImageVerificationImage(java.lang.String oldValue, java.io.OutputStream out)
           
 
Method Summary
 java.lang.String getFilename(com.planet_ink.coffee_web.interfaces.HTTPRequest httpReq, java.lang.String filename)
           
 java.lang.String getVerificationValue()
          return the value to check for when the user enters it in.
static SLinkedList<ImageVerificationImage.ImgCacheEntry> getVerifyCache()
           
 boolean isAWebPath()
          Whether this macro substitutes as an aspect of the web path instead of a standard web macro.
 boolean preferBinary()
          Whether the runMacro or runBinaryMacro executor should be called.
 byte[] runBinaryMacro(com.planet_ink.coffee_web.interfaces.HTTPRequest httpReq, java.lang.String parm, com.planet_ink.coffee_web.interfaces.HTTPResponse httpResp)
          This method is executed only if this macro returns true for preferBinary().
 java.lang.String runMacro(com.planet_ink.coffee_web.interfaces.HTTPRequest httpReq, java.lang.String parm, com.planet_ink.coffee_web.interfaces.HTTPResponse httpResp)
          This method is executed only if this macro returns false for preferBinary().
 
Methods inherited from class com.planet_ink.coffee_mud.WebMacros.StdWebMacro
clearWebMacros, clearWebMacros, colorwebifyOnly, compareTo, copyOf, getHTTPFileData, grabFile, helpHelp, helpHelp, helpHelp, htmlIncomingFilter, htmlIncomingFilter, htmlOutgoingFilter, htmlOutgoingFilter, ID, initializeClass, isAdminMacro, L, name, newInstance, parseOrderedParms, parseParms, parseParms, safeIncomingfilter, webify
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sync

public static java.lang.Object sync
Constructor Detail

ImageVerificationImage

public ImageVerificationImage()

ImageVerificationImage

public ImageVerificationImage(java.lang.String oldValue,
                              java.io.OutputStream out)
                       throws java.io.IOException
Throws:
java.io.IOException

ImageVerificationImage

public ImageVerificationImage(int height,
                              int width,
                              java.lang.String oldValue,
                              java.io.OutputStream out)
                       throws java.io.IOException
Throws:
java.io.IOException
Method Detail

isAWebPath

public boolean isAWebPath()
Description copied from interface: WebMacro
Whether this macro substitutes as an aspect of the web path instead of a standard web macro. If true is returned, URLs such as: http://mydomain.com/mymacroname?firstparm=value&secondparm=value might succeeed

Specified by:
isAWebPath in interface WebMacro
Overrides:
isAWebPath in class StdWebMacro
Returns:
whether this is a wierd URL macro

preferBinary

public boolean preferBinary()
Description copied from interface: WebMacro
Whether the runMacro or runBinaryMacro executor should be called.

Specified by:
preferBinary in interface WebMacro
Overrides:
preferBinary in class StdWebMacro
Returns:
whether the runBinaryMacro executor should be called instead of runMacro
See Also:
WebMacro.runBinaryMacro(HTTPRequest, String, HTTPResponse), WebMacro.runMacro(HTTPRequest, String, HTTPResponse)

getVerifyCache

public static SLinkedList<ImageVerificationImage.ImgCacheEntry> getVerifyCache()

getFilename

public java.lang.String getFilename(com.planet_ink.coffee_web.interfaces.HTTPRequest httpReq,
                                    java.lang.String filename)

runBinaryMacro

public byte[] runBinaryMacro(com.planet_ink.coffee_web.interfaces.HTTPRequest httpReq,
                             java.lang.String parm,
                             com.planet_ink.coffee_web.interfaces.HTTPResponse httpResp)
                      throws HTTPServerException
Description copied from interface: WebMacro
This method is executed only if this macro returns true for preferBinary(). It will execute the macro and return its results as a binary byte array. The response object is used to set cookies and headers only. Any response body is in the return object. Since 99% of macros are only filling in an existing page, nothing will be done with that anyway, and is only important when isAWebPath return true.

Specified by:
runBinaryMacro in interface WebMacro
Overrides:
runBinaryMacro in class StdWebMacro
Parameters:
httpReq - the external requests object
parm - any parameter strings given to the macro
httpResp - the response, with headers
Returns:
the binary stream result of running this macro
Throws:
HTTPServerException - a http error to pass to the user
See Also:
WebMacro.preferBinary(), HTTPRequest

runMacro

public java.lang.String runMacro(com.planet_ink.coffee_web.interfaces.HTTPRequest httpReq,
                                 java.lang.String parm,
                                 com.planet_ink.coffee_web.interfaces.HTTPResponse httpResp)
                          throws HTTPServerException
Description copied from interface: WebMacro
This method is executed only if this macro returns false for preferBinary(). It will execute the macro and return its results as a string, which is then substituted for the macro reference in the web page where the macro was found. The response object is used to set cookies and headers only. Any response body is in the return object. Since 99% of macros are only filling in an existing page, nothing will be done with that anyway, and is only important when isAWebPath return true.

Specified by:
runMacro in interface WebMacro
Overrides:
runMacro in class StdWebMacro
Parameters:
httpReq - the external requests object
parm - any parameter strings given to the macro
httpResp - the response, with headers
Returns:
the string result of running this macro
Throws:
HTTPServerException - a http error to pass to the user
See Also:
WebMacro.preferBinary(), HTTPRequest

getVerificationValue

public java.lang.String getVerificationValue()
return the value to check for when the user enters it in. Make sure you store this off in the session or something like a database and NOT in the form of the webpage since the whole point of this exercise is to ensure that only humans and not machines are entering the data.

Returns:
the value to enter