Packagecom.kaazing.gateway.client.security
Classpublic class ChallengeHandlers

Responsible for both loading fresh ChallengeHandler instances and managing a concept of a default challenge handler.

Loading Challenge Handler Instances

To be discovered using this ChallengeHandlers, a challenge handler implementation should be installed as default implementation of an abstract challenge handler class. For example,
     ChallengeHandlers.setDefaultImplementation(BasicChallengeHandler, MyCustomBasicHandler);
     var handler: ChallengeHandler = ChallengeHandlers.load(BasicChallengeHandler);
     // handler is an instance of class MyCustomBasicHandler

 

Note that by default this package automatically registers implementations of BasicChallengeHandler and DispatchChallengeHandler.

Managing the Default Challenge Handler

This class provides a way to get and set a default challenge handler, which is always defined (never null). The internal default handler cannot handle any challenges - it is up to the application to install its own default challenge handler for any 401 challenge management to operate at all.

Clients with a single challenge handling strategy for all 401 challenges can simply set a specific challenge handler as the default using setDefault(). For example, to register a BasicChallengeHandler object to handle all 401 requests by default, one can code:

 var loginHandler:LoginHandler = ...
 ChallengeHandlers.setDefault((ChallengeHandlers.load(BasicChallengeHandler.class) as BasicChallengeHandler)
               .setLoginHandler(loginHandler));
 

Clients with location-specific challenge handling strategies for location-dependent 401 challenges can register a DispatchChallengeHandler object, upon which location-specific ChallengeHandler objects are then registered. This arrangement means that whenever a request that matches one of the specific locations encounters a 401 challenge from the server, the corresponding ChallengeHandler object is invoked to handle the challenge.

 LoginHandler loginHandler = ...
  ChallengeHandlers.setDefault(ChallengeHandlers.load(DispatchChallengeHandler.class)
               .register("ws://my.server.com", ChallengeHandlers.load(BasicChallengeHandler.class)
                       .setLoginHandler(loginHandler)
               )
       );
 

See also

BasicChallengeHandler
DispatchChallengeHandler


Public Methods
 MethodDefined by
  
[static] Get a reference to the default challenge handler to be used for all HTTP requests
ChallengeHandlers
  
load(clazz:Class):*
[static] Find and instantiate a challenge handler by the class of ChallengeHandler.
ChallengeHandlers
  
loadByName(className:String):*
[static] Find and instantiate a challenge handler by the String name of a class of ChallengeHandler.
ChallengeHandlers
  
setDefault(challengeHandler:ChallengeHandler):void
[static] Define the default challenge handler to be used for all HTTP requests.
ChallengeHandlers
  
setDefaultImplementation(abstractClass:Class, implementationClass:Class):void
[static] Set the default implementation of an abstract Challenge Handler class.
ChallengeHandlers
  
setDefaultImplementationByName(abstractClass:Class, implementationClassName:String):void
[static] Set the default implementation of an abstract Challenge Handler class.
ChallengeHandlers
Method detail
getDefault()method
public static function getDefault():ChallengeHandler

Get a reference to the default challenge handler to be used for all HTTP requests

Returns
ChallengeHandler — a reference to the default challenge handler to be used for all HTTP requests.
load()method 
public static function load(clazz:Class):*

Find and instantiate a challenge handler by the class of ChallengeHandler.

Parameters
clazz:Class — the desired class of challenge handler

Returns
* — the appropriate ChallengeHandler , or null if no such handler can be found.
loadByName()method 
public static function loadByName(className:String):*

Find and instantiate a challenge handler by the String name of a class of ChallengeHandler.

Parameters
className:String — the fully-qualified String name of the desired class of challenge handler

Returns
* — the appropriate ChallengeHandler , or null if no such handler can be found.
setDefault()method 
public static function setDefault(challengeHandler:ChallengeHandler):void

Define the default challenge handler to be used for all HTTP requests.

Parameters
challengeHandler:ChallengeHandler — use this challenge handler as the default for all HTTP requests.
setDefaultImplementation()method 
public static function setDefaultImplementation(abstractClass:Class, implementationClass:Class):void

Set the default implementation of an abstract Challenge Handler class. Used to load instances of appropriate concrete subclasses

Parameters
abstractClass:Class — the abstract class corresponding to the type of ChallengeHandler required
 
implementationClass:Class — the concrete class to be instantiated when an instance of the abstract class is desired
setDefaultImplementationByName()method 
public static function setDefaultImplementationByName(abstractClass:Class, implementationClassName:String):void

Set the default implementation of an abstract Challenge Handler class. Used to load instances of appropriate concrete subclasses

Parameters
abstractClass:Class — the abstract class corresponding to the type of ChallengeHandler required
 
implementationClassName:String — the name of the concrete class to be instantiated when an instance of the abstract class is desired