AIP Providers

Important: This documentation applies to 2.0 Beta only. The 1.0 documentation is here

There are three kinds of providers used by AIP: text, image and filter providers. The AIP library provides implementations of each so that you can immediately use the AIP web control in your websites.

Text Providers

Text providers are classes that derive from the DaveSexton.Web.Controls.AutoInputProtectionTextProvider class, directly or indirectly. The purpose of a text provider is to generate random CAPTCHA text and validate the user's input.

For help creating a custom text provider, see How Do I create a custom AIP text provider?.

Configuration
Text providers may be added to the textProviders collection element in the autoInputProtection section of a web.config file. For example:

<autoInputProtection>
  <textProviders>
    <add name="a text provider"
         type="DaveSexton.Web.Controls.BasicEnglishAutoInputProtectionTextProvider, DaveSexton.AutoInputProtection"
         colors="Red,Green,Blue,Brown" fonts="Times New Roman,Arial" />
  </textProviders>
</autoInputProtection>

The colors and fonts attributes are required for all text providers, regardless of the implementation.

Default Text Provider
A default text provider is required by the AIP web control. Only one provider may be registered as the default using the defaultTextProvider attribute of the autoInputProtection element. The specified name must correspond with a provider that you have added to the textProviders element.

If you do not add a textProviders element to the autoInputProtection section in your web.config file, then the basic English text provider will be used automatically.

Built-In Text Providers
There are two concrete implementations built-in to the AIP library:
  • BasicEnglishAutoInputProtectionTextProvider (default)
  • RandomCharactersAutoInputProtectionTextProvider
Refer to the reference documentation for more information.

Image Providers

Image providers are classes that derive from the DaveSexton.Web.Controls.AutoInputProtectionImageProvider class, directly or indirectly. The purpose of an image provider is to create a class that derives from AutoInputProtectionImage, which will generate an image from the specified Size and AutoInputProtectionTextProvider implementation.

For help creating a custom image provider, see How Do I create a custom AIP image provider?.

Configuration
Image providers may be added to the imageProviders collection element in the autoInputProtection section of a web.config file. For example:

<autoInputProtection>
  <imageProviders>
    <add name="an image provider" 
         type="DaveSexton.Web.Controls.ResourceAutoInputProtectionImageProvider, DaveSexton.AutoInputProtection" />
  </imageProviders>
</autoInputProtection>

There are no required attributes other than name and type.

Default Image Provider
A default image provider is required by the AIP web control. Only one provider may be registered as the default using the defaultImageProvider attribute of the autoInputProtection element. The specified name must correspond with a provider that you have added to the imageProviders element.

If you do not add an imageProviders element to the autoInputProtection section in your web.config file, then the line-noise image provider will be used automatically.

Built-In Image Providers
There are two concrete implementations and a derived abstract base class built-in to the AIP library:
  • PartitionedAutoInputProtectionImageProvider (abstract)
  • ResourceAutoInputProtectionImageProvider
  • LineNoiseAutoInputProtectionImageProvider (default)
Refer to the reference documentation for more information.

Filter Providers

Filter providers are classes that derive from the DaveSexton.Web.Controls.AutoInputProtectionFilterProvider class, directly or indirectly. Filters are optional providers that will modify the image generated by an image provider. Filter providers are used to increase the randomization of AIP or to make the generated images aesthetically pleasing in the context of your website. They are especially useful for applying common effects to third-party image providers. Filters are purely graphical and do not have any reference to the validation text.

For help creating a custom filter provider, see How Do I create a custom AIP filter provider?.

Configuration
Filter providers may be added to the filters collection element in the autoInputProtection section of a web.config file. For example:

<autoInputProtection>
  <filters>
    <add name="horizontal bars" 
         type="DaveSexton.Web.Controls.TranslucentBarsOverlayAutoInputProtectionFilterProvider, DaveSexton.AutoInputProtection"
         colors="Orange,Yellow,Fuchsia" />
  </filters>
</autoInputProtection>

Any number of filters may be applied. The order in which the filters are processed is the order in which they are added to the filters element, top-down, in your web.config file. All of the filters in the filters element are used; if you want to exclude a filter then you must remove it from the configuration.

The base filter provider has no required attributes other than name and type; however, the TranslucentBarsOverlayAutoInputProtectionFilterProvider class requires the colors attribute to be specified as well.

Built-In Filter Providers
There are two concrete implementations built-in to the AIP library:
  • TranslucentBarsOverlayAutoInputProtectionFilterProvider
  • CrossHatchAutoInputProtectionFilterProvider
Refer to the reference documentation for more information.

Modes of Operation
There are two modes in which a filter provider may be applied: Preprocess and Post-process. Filters may provide one or both modes.

PreProcess
A preprocess filter applies to the background image before the composite image has been created. The composite image is the image's background with the validation text rendered on top. The background image is referred to as a surface image and it's provided by an AutoInputProtectionImage implementation, which is provided by an AutoInputProtectionImageProvider implementation.

Post-Process
A post-process filter applies to the composite image, which includes the prerendered challenge text.

Last edited Apr 2, 2008 at 12:57 PM by davedev, version 4

Comments

No comments yet.