VError VRIAServerJSContextMgr::ReleaseJSContext( VJSGlobalContext* inContext) { VError err = VE_OK; if (inContext != NULL) { VJSContext jsContext( inContext); VRIAJSRuntimeContext *runtimeContext = VRIAJSRuntimeContext::GetFromJSContext( jsContext); if (runtimeContext != NULL) { VRIAServerProject *application = runtimeContext->GetRootApplication(); if (application != NULL) { application->ReleaseJSContext( inContext, NULL); } else { err = VRIAServerApplication::Get()->ReleaseJSContext( inContext); } } } return err; }
bool VJSDebuggerSettings::UserCanDebug ( const UniChar* inUserName, const UniChar* inUserPassword ) const { if ( fServerSolution == 0 ) { xbox_assert ( false ); return false; // Something went really wrong } if ( !NeedsAuthentication ( ) ) return true; CUAGDirectory* uagDirectory = fServerSolution-> RetainUAGDirectory ( ); if ( uagDirectory == 0 ) return true; // No directory defined at all so access is not protected VString vstrUserName ( inUserName ); VString vstrUserPassword ( inUserPassword ); bool bCanDebug = false; VError vError = VE_OK; CUAGSession* cSession = NULL; if ((uagDirectory != NULL) && uagDirectory->HasLoginListener()) { // sc 22/06/2012, custom JavaScript authentication support VectorOfApplication applications; fServerSolution->GetApplications( applications); VRIAServerProject *app = (!applications.empty()) ? applications.front() : NULL; if (app != NULL) { VJSGlobalContext *globalContext = app->RetainJSContext( vError, true, NULL); if (vError == VE_OK) { if (testAssert(globalContext != NULL)) { VJSContext jsContext( globalContext); cSession = uagDirectory-> OpenSession ( inUserName, inUserPassword, &vError, &jsContext ); } else { vError = VE_UNKNOWN_ERROR; } } app->ReleaseJSContext( globalContext, NULL); } } else { cSession = uagDirectory-> OpenSession ( inUserName, inUserPassword, &vError, NULL ); } if ( cSession != 0 && vError == VE_OK ) { VUUID vuuidDebuggerGroup; bool bOK = uagDirectory-> GetSpecialGroupID ( CUAGDirectory::DebuggerGroup, vuuidDebuggerGroup ); xbox_assert ( bOK ); if ( cSession-> BelongsTo ( vuuidDebuggerGroup ) ) bCanDebug = true; } ReleaseRefCountable ( &cSession ); ReleaseRefCountable ( &uagDirectory ); return bCanDebug; }