void* RTSPRequestInterface::GetLocalPath(QTSSDictionary* inRequest, UInt32* outLen) { // This function always gets called RTSPRequestInterface* theRequest = (RTSPRequestInterface*)inRequest; QTSS_AttributeID theID = qtssRTSPReqFilePath; // Get the truncated path on a setup, because setups have the trackID appended if (theRequest->GetMethod() == qtssSetupMethod) { theID = qtssRTSPReqFilePathTrunc; // invoke the param retrieval function here so that we can use the internal GetValue function later RTSPRequestInterface::GetTruncatedPath(inRequest, outLen); } StrPtrLen* thePath = theRequest->GetValue(theID); StrPtrLen filePath(thePath->Ptr, thePath->Len); StrPtrLen* theRootDir = theRequest->GetValue(qtssRTSPReqRootDir); if (theRootDir->Len && theRootDir->Ptr[theRootDir->Len -1] == kPathDelimiterChar && thePath->Len && thePath->Ptr[0] == kPathDelimiterChar) { char *thePathEnd = &(filePath.Ptr[filePath.Len]); while (filePath.Ptr != thePathEnd) { if (*filePath.Ptr != kPathDelimiterChar) break; filePath.Ptr ++; filePath.Len --; } } char rootDir[512] = { 0 }; ::strncpy(rootDir, theRootDir->Ptr, theRootDir->Len); OS::RecursiveMakeDir(rootDir); UInt32 fullPathLen = filePath.Len + theRootDir->Len; char* theFullPath = NEW char[fullPathLen+1]; theFullPath[fullPathLen] = '\0'; ::memcpy(theFullPath, theRootDir->Ptr, theRootDir->Len); ::memcpy(theFullPath + theRootDir->Len, filePath.Ptr, filePath.Len); (void)theRequest->SetValue(qtssRTSPReqLocalPath, 0, theFullPath,fullPathLen , QTSSDictionary::kDontObeyReadOnly); // delete our copy of the data delete [] theFullPath; *outLen = 0; return NULL; }
QTSS_Error QTSSCallbacks::QTSS_Authenticate(const char* inAuthUserName, const char* inAuthResourceLocalPath, const char* inAuthMoviesDir, QTSS_ActionFlags inAuthRequestAction, QTSS_AuthScheme inAuthScheme, QTSS_RTSPRequestObject ioAuthRequestObject) { if((inAuthUserName == NULL) || (inAuthResourceLocalPath == NULL) || (inAuthMoviesDir == NULL) || (ioAuthRequestObject == NULL)) return QTSS_BadArgument; if(inAuthRequestAction == qtssActionFlagsNoFlags) return QTSS_BadArgument; if(inAuthScheme == qtssAuthNone) return QTSS_BadArgument; // First create a RTSPRequestInterface object // There is no session attached to it, so just pass in NULL for the RTSPSession RTSPRequestInterface *request = (RTSPRequestInterface *) ioAuthRequestObject; // Set all the attributes required by the authentication module, using the input values (void) request->SetValue(qtssRTSPReqUserName, 0, inAuthUserName , ::strlen(inAuthUserName), QTSSDictionary::kDontObeyReadOnly); (void) request->SetValue(qtssRTSPReqLocalPath, 0, inAuthResourceLocalPath , ::strlen(inAuthResourceLocalPath), QTSSDictionary::kDontObeyReadOnly); (void) request->SetValue(qtssRTSPReqRootDir, 0, inAuthMoviesDir , ::strlen(inAuthMoviesDir), QTSSDictionary::kNoFlags); (void) request->SetValue(qtssRTSPReqAction, 0, (const void *)&inAuthRequestAction , sizeof(QTSS_ActionFlags), QTSSDictionary::kNoFlags); (void) request->SetValue(qtssRTSPReqAuthScheme, 0, (const void *)&inAuthScheme , sizeof(QTSS_AuthScheme), QTSSDictionary::kDontObeyReadOnly); QTSSUserProfile *profile = request->GetUserProfile(); (void) profile->SetValue(qtssUserName, 0, inAuthUserName, ::strlen(inAuthUserName), QTSSDictionary::kDontObeyReadOnly); // Because this is a role being executed from inside a callback, we need to // make sure that QTSS_RequestEvent will not work. Task* curTask = NULL; QTSS_ModuleState* theState = (QTSS_ModuleState*)OSThread::GetMainThreadData(); if (OSThread::GetCurrent() != NULL) theState = (QTSS_ModuleState*)OSThread::GetCurrent()->GetThreadData(); if (theState != NULL) curTask = theState->curTask; // Setup the authentication param block QTSS_RoleParams theAuthenticationParams; theAuthenticationParams.rtspAthnParams.inRTSPRequest = request; QTSS_Error theErr = QTSS_RequestFailed; UInt32 x = 0; UInt32 numModules = QTSServerInterface::GetNumModulesInRole(QTSSModule::kRTSPAthnRole); QTSSModule* theModulePtr = NULL; Bool16 allowedDefault = QTSServerInterface::GetServer()->GetPrefs()->GetAllowGuestDefault(); Bool16 allowed = allowedDefault; //server pref? Bool16 hasUser = false; Bool16 handled = false; // Call all the modules that are registered for the RTSP Authorize Role for ( ; x < numModules; x++) { request->SetAllowed(allowedDefault); request->SetHasUser(false); request->SetAuthHandled(false); debug_printf(" QTSSCallbacks::QTSS_Authenticate calling module module = %lu numModules=%lu\n", x,numModules); theModulePtr = QTSServerInterface::GetModule(QTSSModule::kRTSPAthnRole, x); theErr = QTSS_NoErr; if (theModulePtr) { theErr = theModulePtr->CallDispatch(QTSS_RTSPAuthenticate_Role, &theAuthenticationParams); debug_printf(" QTSSCallbacks::QTSS_Authorize calling module module = %lu numModules=%lu ModuleError=%ld\n", x,numModules, theErr); } else { debug_printf(" QTSSCallbacks::QTSS_Authorize calling module module = %lu is NULL! numModules=%lu\n", x,numModules); continue; } allowed = request->GetAllowed(); hasUser = request->GetHasUser(); handled = request->GetAuthHandled(); debug_printf("QTSSCallbacks::QTSS_Authenticate allowedDefault =%d allowed= %d hasUser = %d handled=%d \n",allowedDefault, allowed,hasUser, handled); if (hasUser || handled ) //See RTSPSession.cpp::Run state=kAuthenticatingRequest { debug_printf(" QTSSCallbacks::QTSS_Authenticate skipping other modules fCurrentModule = %lu numModules=%lu\n", x,numModules); break; } } // Reset the curTask to what it was before this role started if (theState != NULL) theState->curTask = curTask; return theErr; }
void* RTSPRequestInterface::GetAuthDigestResponse(QTSSDictionary* inRequest, UInt32* ) { RTSPRequestInterface* theRequest = (RTSPRequestInterface*)inRequest; (void)theRequest->SetValue(qtssRTSPReqDigestResponse, 0, theRequest->fAuthDigestResponse.Ptr,theRequest->fAuthDigestResponse.Len , QTSSDictionary::kDontObeyReadOnly); return NULL; }