Class Index | Minimal

Classes


Class jabberwerx.SASLMechanism (MINIMAL)


Extends jabberwerx.JWBase.

Base class for SASL support.

NOTE: When defining new SASL mechanisms, the call to #.extend MUST include the mechanism name:

var namespace.SASLSomeClient = jabberwerx.SASLMechanism.extend(
     { ... },
     "namespace.SASLSomeClient",
     "SOME-MECH");

The mechanism name then becomes a property of the class and its instances.

Class Summary
Constructor Attributes Constructor Name and Description
 
jabberwerx.SASLMechanism(client, encoded)

Creates a new SASLMechanism with the given client.

Field Summary
Field Attributes Field Name and Description
 
The client to operate against
 
Flag to check to check if this SASLMechanism has completed the authentication negotation (successful or not).
 
The mechanism name.
 
Flag to indicate the mechanism has been started.
Method Summary
Method Attributes Method Name and Description
 
evaluate(input)

Evaluates a step in the SASL negotation.

 

Called by #evaluate to process challenge data into a response.

 

Called by #evaluate to start use of this SASLMechanism.

<static>  
jabberwerx.SASLMechanism.extend(props, type, mechname)

Defines a new subclass of jabberwerx.SASLMechanism.

 

Retrieves the connection/authentication properties from the client.

Methods borrowed from class jabberwerx.JWBase:
destroy, getClassName, graphUnserialized, init, invocation, shouldBeSavedWithGraph, shouldBeSerializedInline, toString, wasUnserialized, willBeSerialized
Class Detail
jabberwerx.SASLMechanism(client, encoded)

Creates a new SASLMechanism with the given client. The name of this SASLMechanism is established by its type definition via #.extend.

If {encoded} is true, then #evaluateStart and #evaluateChallenge are expected to perform the base64 encoding and decoding; #evaluate will not automatically perform this step.

Parameters:
{jabberwerx.Client} client
The client
{Boolean} encoded Optional
true if the mechanism's #evaluateStart and #evaluateChallenge return data that is already base-64 encoded (default is false)
Throws:
TypeError If {client} is not a jabberwerx.Client
Field Detail
{jabberwerx.Client} client
The client to operate against

{Boolean} complete
Flag to check to check if this SASLMechanism has completed the authentication negotation (successful or not).

{String} mechanismName
The mechanism name. This is automatically set by the init method for jabberwerx.SASLMechanism, based on the mechanism name given when the type is defined.

{Boolean} started
Flag to indicate the mechanism has been started.
Method Detail
{Element} evaluate(input)

Evaluates a step in the SASL negotation. This method processes the SASL "challenge", "failure" and "success" stanzas, and returns "auth" and "response" stanzas.

If called with no arguments, this method performs the initial step:

  1. #evaluateStart is called
  2. The <auth mechanism="#mechanismName"/> is generated and returned, including any initial data as base64-encoded text content.

If called with a <challenge/> element, it performs the subsequent steps:

  1. The challenge data (if any) is decoded from base64
  2. #evaluateChallenge is called, and the response data noted
  3. The <response/> stanza is generated and returned, including any response data as base64-encoded text content

If called with a <success/> element, it performs the finalization step:

  1. The success data (if any) is decoded from base64
  2. If there is success data, #evaluateChallenge is called
  3. #complete is checked to see that it is now equal to true

If called with a <failure/> element, it performs error handling:

  1. The condition from the failure is analyzed
  2. A jabberwrex.SASLMechanism.SASLAuthFailure error is thrown.

Parameters:
{Element} input Optional
The challenge to evaluate, or undefined for the initial step.
Throws:
{TypeError}
If {input} is not an Element
{jabberwerx.SASLMechanism.SASLAuthFailure}
If a problem is encountered
Returns:
{Element} The response, or null if no further responses are necessary.

{String} evaluateChallenge(inb)

Called by #evaluate to process challenge data into a response. Subclasses MUST override this method to perform the steps of SASL negotation appropriate to the mechanism. If this step completes the negotation (even if part of a <challenge/> instead of a <success/>), this method MUST set the #complete flag to true.

The input is the text content of the <challenge/> or <success/>, decoded from base64.

This implementation always throws an Error.

Parameters:
{String} inb
The input data ("" if there is no challenge data)
Throws:
{jabberwerx.SASLMechanism.SASLAuthFailure}
If there is a problem evaluating the challenge.
Returns:
{String} The output data, or null if no response data is available

evaluateStart()

Called by #evaluate to start use of this SASLMechanism. Subclasses MUST override this method to perform the initial step.

This implementation always throws an Error.

Returns:
The initial data to send, or null to send an empty <auth/>

<static> {Class} jabberwerx.SASLMechanism.extend(props, type, mechname)

Defines a new subclass of jabberwerx.SASLMechanism. This method overrides JWBase.extend to also include the name of the SASL mechanism. This method will also register the new mechanism with the global SASLMechanismFactory jabberwerx.sasl.

Parameters:
{Object} props
The properties and methods for the subclass
{String} type
The fully-qualified name of the subclass
{String} mechname
The SASL mechanism name this subclass supports
Throws:
{TypeError}
If {mechname} is not a non-empty string
Returns:
{Class} The subclass of jabberwerx.SASLMechanism

{Object} getProperties()

Retrieves the connection/authentication properties from the client.

Returns:
{Object} The properties object from #client

Documentation generated by JsDoc Toolkit 2.4.0 on Wed Apr 02 2014 13:23:42 GMT-0600 (MDT)