@ -189,14 +189,19 @@ function onRequest(context) {
var jwtService = carbonServer . osgiService ( 'org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService' ) ;
var jwtService = carbonServer . osgiService ( 'org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService' ) ;
var jwtClient = jwtService . getJWTClient ( ) ;
var jwtClient = jwtService . getJWTClient ( ) ;
var encodedClientKeys = session . get ( constants [ "ENCODED_TENANT_BASED_WEB_SOCKET_CLIENT_CREDENTIALS" ] ) ;
var encodedClientKeys = session . get ( constants [ "ENCODED_TENANT_BASED_WEB_SOCKET_CLIENT_CREDENTIALS" ] ) ;
var tokenPair = null ;
var token = "" ;
var token = "" ;
if ( encodedClientKeys ) {
if ( encodedClientKeys ) {
var tokenUtil = require ( "/app/modules/oauth/token-handler-utils.js" ) [ "utils" ] ;
var tokenUtil = require ( "/app/modules/oauth/token-handler-utils.js" ) [ "utils" ] ;
var resp = tokenUtil . decode ( encodedClientKeys ) . split ( ":" ) ;
var resp = tokenUtil . decode ( encodedClientKeys ) . split ( ":" ) ;
var tokenPair = jwtClient . getAccessToken ( resp [ 0 ] , resp [ 1 ] , context . user . username , "default" , { } ) ;
if ( context . user . domain == "carbon.super" ) {
tokenPair = jwtClient . getAccessToken ( resp [ 0 ] , resp [ 1 ] , context . user . username , "default" , { } ) ;
} else {
tokenPair = jwtClient . getAccessToken ( resp [ 0 ] , resp [ 1 ] , context . user . username + "@" + context . user . domain , "default" , { } ) ;
}
if ( tokenPair ) {
if ( tokenPair ) {
token = tokenPair . accessToken ;
token = tokenPair . accessToken ;
}
}
}
}
remoteSessionEndpoint = remoteSessionEndpoint + "/remote/session/clients/" + deviceType + "/" + deviceId +
remoteSessionEndpoint = remoteSessionEndpoint + "/remote/session/clients/" + deviceType + "/" + deviceId +
"?websocketToken=" + token
"?websocketToken=" + token