com.cenqua.fisheye.user.plugin
Class ExampleFishEyeHttpAuthenticator

java.lang.Object
  extended by com.cenqua.fisheye.user.plugin.AbstractFishEyeAuthenticator
      extended by com.cenqua.fisheye.user.plugin.ExampleFishEyeHttpAuthenticator
All Implemented Interfaces:
FishEyeAuthenticator

public class ExampleFishEyeHttpAuthenticator
extends AbstractFishEyeAuthenticator

An authenticator that accepts requests coming from a list (comma seperated) of preconfigured remote addresses. It also logs all calls to stdout. This can be used to learn more about the lifecycle of Authenticators in FishEye. An example configuration in the config.xml is:

     <custom
      classname="com.cenqua.fisheye.user.plugin.ExampleFishEyeHttpAuthenticator"
      auto-add="true"
      positive-cache-ttl="5mins">
      <properties>
        allow.from=127.0.0.1,192.168.0.1
      </properties>
    </custom>
    


Constructor Summary
ExampleFishEyeHttpAuthenticator()
           
 
Method Summary
 AuthToken checkPassword(java.lang.String username, java.lang.String password)
          Called to check a user's password.
 AuthToken checkRequest(javax.servlet.http.HttpServletRequest request)
          Called to allow implementations to determine if the request is pre-authenticated, bypassing FishEye's own HTTP authentication.
 void close()
          Called when this authenticator will no longer be used.
 boolean hasPermissionToAccess(AuthToken tok, java.lang.String repname, java.lang.String constraint)
          Check if a user has permission to access the given repository.
 void init(java.util.Properties cfg)
          Called to configure this authenticator.
 boolean isRequestUserStillValid(java.lang.String username, javax.servlet.http.HttpServletRequest req)
          Checks that the given username is still valid for the request.
 AuthToken recreateAuth(java.lang.String username)
          Used to re-create a token for a user that was previously authenticated.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExampleFishEyeHttpAuthenticator

public ExampleFishEyeHttpAuthenticator()
Method Detail

checkRequest

public AuthToken checkRequest(javax.servlet.http.HttpServletRequest request)
Description copied from interface: FishEyeAuthenticator
Called to allow implementations to determine if the request is pre-authenticated, bypassing FishEye's own HTTP authentication.

Specified by:
checkRequest in interface FishEyeAuthenticator
Overrides:
checkRequest in class AbstractFishEyeAuthenticator
Parameters:
request - the servlet request to check
Returns:
an authentication token if the request is authenticated, or null otherwise.

isRequestUserStillValid

public boolean isRequestUserStillValid(java.lang.String username,
                                       javax.servlet.http.HttpServletRequest req)
Description copied from interface: FishEyeAuthenticator
Checks that the given username is still valid for the request.

Specified by:
isRequestUserStillValid in interface FishEyeAuthenticator
Overrides:
isRequestUserStillValid in class AbstractFishEyeAuthenticator
Parameters:
username - the UserName, must not be null
req - the request to check the username against
Returns:
true if the username is still valid, false otherwise.

init

public void init(java.util.Properties cfg)
          throws java.lang.Exception
Description copied from interface: FishEyeAuthenticator
Called to configure this authenticator.

Parameters:
cfg - the configuration properties, as specified in the <properties> element in the <custom> config. (non-null)
Throws:
java.lang.Exception - an error occurred during configuration.

close

public void close()
Description copied from interface: FishEyeAuthenticator
Called when this authenticator will no longer be used.


checkPassword

public AuthToken checkPassword(java.lang.String username,
                               java.lang.String password)
Description copied from interface: FishEyeAuthenticator
Called to check a user's password.

You should not make any assumptions about the arguments. For example, they could be the empty string, or null.

Parameters:
username - given username (may be null)
password - given password (may be null)
Returns:
an authentication token on successful authentication, or null otherwise.

recreateAuth

public AuthToken recreateAuth(java.lang.String username)
Description copied from interface: FishEyeAuthenticator
Used to re-create a token for a user that was previously authenticated. For example, this method is called when a user returns and they have selected "remember me" when they logged in.

Returns:
a re-created token, or null if the user cannot be re-created without re-authentication

hasPermissionToAccess

public boolean hasPermissionToAccess(AuthToken tok,
                                     java.lang.String repname,
                                     java.lang.String constraint)
Description copied from interface: FishEyeAuthenticator
Check if a user has permission to access the given repository.

This method is notcalled when users are not logged in (anonymous users).

If a custom constraint has been specified in config.xml, then that value is passed as constraint. This is taken from the <security><custom constraint=""> setting in either <repository> or <repository-defaults>.

A constraint could be used (for example) to specify a group that a user must belong to in order to access a repository.

Parameters:
tok - an authentication token as returned by FishEyeAuthenticator.checkPassword(java.lang.String, java.lang.String) or FishEyeAuthenticator.recreateAuth(java.lang.String) (not null)
repname - the symbolic name of the repository (not null)
constraint - a constraint as specified in config.xml (or null if not specified).