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.
Constructor Attributes | Constructor Name and Description |
---|---|
jabberwerx.SASLMechanism(client, encoded)
Creates a new SASLMechanism with the given client. |
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 Attributes | Method Name and Description |
---|---|
evaluate(input)
Evaluates a step in the SASL negotation. |
|
evaluateChallenge(inb)
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
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
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:
- #evaluateStart is called
- 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:
- The challenge data (if any) is decoded from base64
- #evaluateChallenge is called, and the response data noted
- 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:
- The success data (if any) is decoded from base64
- If there is success data, #evaluateChallenge is called
- #complete is checked to see that it is now equal to true
If called with a <failure/> element, it performs error handling:
- The condition from the failure is analyzed
- 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.
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
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/>
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
Retrieves the connection/authentication properties from the client.
- Returns:
- {Object} The properties object from #client