org.blojsom.plugin.security
Class BasicAuthenticationPlugin

java.lang.Object
  extended byorg.blojsom.plugin.admin.BaseAdminPlugin
      extended byorg.blojsom.plugin.security.BasicAuthenticationPlugin
All Implemented Interfaces:
PermissionedPlugin, Plugin

public class BasicAuthenticationPlugin
extends BaseAdminPlugin

Basic Authentication plugin performs a BASIC authorization check so that users much authenticate before they are able to see any blog entries.

Since:
blojsom 3.0
Version:
$Id: BasicAuthenticationPlugin.java,v 1.5 2007/01/25 22:47:58 czarneckid Exp $
Author:
David Czarnecki

Field Summary
 
Fields inherited from class org.blojsom.plugin.admin.BaseAdminPlugin
_authorizationProvider, _ignoreParams, _logger, _resourceManager, _servletConfig, ACTION_PARAM, ADMIN_ADMINISTRATION_PAGE, ADMIN_AJAX_RESPONSE, ADMIN_LOGIN_PAGE, BLOJSOM_ADMIN_MESSAGES_RESOURCE, BLOJSOM_ADMIN_PLUGIN_AUTHENTICATED_KEY, BLOJSOM_ADMIN_PLUGIN_OPERATION_RESULT, BLOJSOM_ADMIN_PLUGIN_PASSWORD_PARAM, BLOJSOM_ADMIN_PLUGIN_USERNAME, BLOJSOM_ADMIN_PLUGIN_USERNAME_KEY, BLOJSOM_ADMIN_PLUGIN_USERNAME_PARAM, BLOJSOM_PERMISSION_CHECKER, BLOJSOM_USER_AUTHENTICATED, LOGIN_ACTION, LOGIN_ERROR_TEXT_KEY, LOGOUT_ACTION, PAGE_ACTION, PLUGIN_ADMIN_INHERIT_APACHE_CREDENTIALS, SUBACTION_PARAM
 
Constructor Summary
BasicAuthenticationPlugin()
          Construct a new instance of the Basic Authentication plugin
 
Method Summary
 void cleanup()
          Perform any cleanup for the plugin.
protected  boolean decodeCredentialsAndAuthenticate(javax.servlet.http.HttpServletRequest httpServletRequest, Blog blog)
          Decode the BASIC authentication credentials and check the username/password against the authorized users for the blog.
 void destroy()
          Called when BlojsomServlet is taken out of service
 Entry[] process(javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse, Blog blog, java.util.Map context, Entry[] entries)
          Process the blog entries
protected  void setAuthenticationRequired(javax.servlet.http.HttpServletResponse httpServletResponse, Blog blog)
          Set the appropriate headers for BASIC authentication
 
Methods inherited from class org.blojsom.plugin.admin.BaseAdminPlugin
addOperationResultMessage, authenticateUser, checkPermission, formatAdminResource, getAdminResource, getUsernameFromSession, init, setAuthorizationProvider, setResourceManager, setServletConfig
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicAuthenticationPlugin

public BasicAuthenticationPlugin()
Construct a new instance of the Basic Authentication plugin

Method Detail

setAuthenticationRequired

protected void setAuthenticationRequired(javax.servlet.http.HttpServletResponse httpServletResponse,
                                         Blog blog)
Set the appropriate headers for BASIC authentication

Parameters:
httpServletResponse - Response
blog - Blog

decodeCredentialsAndAuthenticate

protected boolean decodeCredentialsAndAuthenticate(javax.servlet.http.HttpServletRequest httpServletRequest,
                                                   Blog blog)
Decode the BASIC authentication credentials and check the username/password against the authorized users for the blog.

Parameters:
httpServletRequest - Request
blog - Blog
Returns:
true if the BASIC authentication credentials are available and pass authentication, false otherwise

process

public Entry[] process(javax.servlet.http.HttpServletRequest httpServletRequest,
                       javax.servlet.http.HttpServletResponse httpServletResponse,
                       Blog blog,
                       java.util.Map context,
                       Entry[] entries)
                throws PluginException
Process the blog entries

Specified by:
process in interface Plugin
Overrides:
process in class BaseAdminPlugin
Parameters:
httpServletRequest - Request
httpServletResponse - Response
blog - Blog instance
context - Context
entries - Blog entries retrieved for the particular request
Returns:
Modified set of blog entries
Throws:
PluginException - If there is an error processing the blog entries

cleanup

public void cleanup()
             throws PluginException
Perform any cleanup for the plugin. Called after process(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.blojsom.blog.Blog, java.util.Map, org.blojsom.blog.Entry[]).

Specified by:
cleanup in interface Plugin
Overrides:
cleanup in class BaseAdminPlugin
Throws:
PluginException - If there is an error performing cleanup for this plugin

destroy

public void destroy()
             throws PluginException
Called when BlojsomServlet is taken out of service

Specified by:
destroy in interface Plugin
Overrides:
destroy in class BaseAdminPlugin
Throws:
PluginException - If there is an error in finalizing this plugin