Class wsc.AuthHandler
The authentication handler is used by the session to get "SERVICE" or "TURN" authentication information.
The client application should set a wsc.AuthHandler object for a Session object.
The event handler function refresh should be set by web applications for the AuthHandler object.
The function "refresh" returns a JSON object or false.
Constructor Attributes | Constructor Name and Description |
---|---|
wsc.AuthHandler(session)
|
Event Attributes | Event Name and Description |
---|---|
refresh(authType, authHeaders)
The callback function to handle the authentication event
|
Class Detail
wsc.AuthHandler(session)
var authHandler = new wsc.AuthHandler(wscSession);
authHandler.refresh = refreshAuth
function refreshAuth(authType, authHeaders){
var authInfo = null;
if(authType==wsc.AUTHTYPE.SERVICE) {
// Return a JSON object according to the content of the "authHeaders". authInfo = ...; } else if(authType==wsc.AUTHTYPE.TURN) {
// Return a JSON object formatted like this: {"iceServers" : [ {"url":"turn:test@: ", "credential":" "} ]}. authInfo = ...;
}
return authInfo;
};
Following is an authHeaders sample for Digest authentication:
{ "scheme": "Digest", "nonce": "a12e8f74-af01-4e74-9714-4d65bae4e024", "realm": "example.com", "qop": "auth", "challenge_code": "407", "opaque": "YXBwLTNjOHFlaHR2eGRhcnxiYWNkMTIxMWFmZDlkNmUyMThmZmI0ZDc4ZmY3ZmY1YUAxMC4xODIuMTMuMTh8Mzc3N2E3Nzc0ODYyMGY4", "charset": "utf-8", "method": "REGISTER", "uri": "sip:10.182.12.165:5060" } Digest authentication is fully described in RFC 2617.
- Parameters:
- {wsc.Session} session
- An instance of the wsc.Session object.
Event Detail
refresh(authType, authHeaders)
The callback function to handle the authentication event
- Parameters:
- {String} authType
- the authentication type
- {object} authHeaders
- the headers that used for the authentication.