comparison Plugin/Plugin.cpp @ 163:4f5c7acb626f

more detailed error message
author Alain Mazy <am@orthanc.team>
date Thu, 25 Apr 2024 15:30:24 +0200
parents db1a5d1634e0
children a1fbf3f982f8 99bdc05012c0
comparison
equal deleted inserted replaced
162:db1a5d1634e0 163:4f5c7acb626f
713 } 713 }
714 else 714 else
715 { 715 {
716 // since this is a series/instance find, make sure the user has access to the parent study 716 // since this is a series/instance find, make sure the user has access to the parent study
717 Json::Value studyOrthancIds; 717 Json::Value studyOrthancIds;
718 if (!OrthancPlugins::RestApiPost(studyOrthancIds, "/tools/lookup", studyInstanceUID, false) || studyOrthancIds.size() != 1) 718 if (!OrthancPlugins::RestApiPost(studyOrthancIds, "/tools/lookup", studyInstanceUID, false))
719 { 719 {
720 throw Orthanc::OrthancException(Orthanc::ErrorCode_ForbiddenAccess, "Auth plugin: when using tools/find at Series or Instance level, unable to get the orthanc ID of StudyInstanceUID specified in the query."); 720 throw Orthanc::OrthancException(Orthanc::ErrorCode_ForbiddenAccess, "Auth plugin: when using tools/find at Series or Instance level, unable to get the orthanc ID of StudyInstanceUID specified in the query.");
721 }
722 else if (studyOrthancIds.size() != 1)
723 {
724 throw Orthanc::OrthancException(Orthanc::ErrorCode_ForbiddenAccess, "Auth plugin: when using tools/find at Series or Instance level, unable to get the orthanc ID of StudyInstanceUID specified in the query. Found " + boost::lexical_cast<std::string>(studyOrthancIds.size()) + " orthanc studies with this StudyInstanceUID");
721 } 725 }
722 726
723 bool granted = false; 727 bool granted = false;
724 OrthancPlugins::IAuthorizationParser::AccessedResources accessedResources; 728 OrthancPlugins::IAuthorizationParser::AccessedResources accessedResources;
725 authorizationParser_->AddDicomStudy(accessedResources, studyInstanceUID); 729 authorizationParser_->AddDicomStudy(accessedResources, studyInstanceUID);
747 { 751 {
748 throw Orthanc::OrthancException(Orthanc::ErrorCode_ForbiddenAccess, "Auth plugin: unable to call tools/find when the user does not have access to any labels and if there is no StudyInstanceUID in the query."); 752 throw Orthanc::OrthancException(Orthanc::ErrorCode_ForbiddenAccess, "Auth plugin: unable to call tools/find when the user does not have access to any labels and if there is no StudyInstanceUID in the query.");
749 } 753 }
750 754
751 Json::Value studyOrthancIds; 755 Json::Value studyOrthancIds;
752 if (!OrthancPlugins::RestApiPost(studyOrthancIds, "/tools/lookup", studyInstanceUID, false) || studyOrthancIds.size() != 1) 756 if (!OrthancPlugins::RestApiPost(studyOrthancIds, "/tools/lookup", studyInstanceUID, false))
753 { 757 {
754 throw Orthanc::OrthancException(Orthanc::ErrorCode_ForbiddenAccess, "Auth plugin: when using tools/find with a resource token, unable to get the orthanc ID of StudyInstanceUID specified in the query."); 758 throw Orthanc::OrthancException(Orthanc::ErrorCode_ForbiddenAccess, "Auth plugin: when using tools/find with a resource token, unable to get the orthanc ID of StudyInstanceUID specified in the query.");
759 }
760 else if (studyOrthancIds.size() != 1)
761 {
762 throw Orthanc::OrthancException(Orthanc::ErrorCode_ForbiddenAccess, "Auth plugin: when using tools/find with a resource token, unable to get the orthanc ID of StudyInstanceUID specified in the query. Found " + boost::lexical_cast<std::string>(studyOrthancIds.size()) + " orthanc studies with this StudyInstanceUID");
755 } 763 }
756 764
757 std::vector<TokenAndValue> authTokens; // the tokens that are set in this request 765 std::vector<TokenAndValue> authTokens; // the tokens that are set in this request
758 GetAuthTokens(authTokens, request->headersCount, request->headersKeys, request->headersValues, request->getCount, request->getKeys, request->getValues); 766 GetAuthTokens(authTokens, request->headersCount, request->headersKeys, request->headersValues, request->getCount, request->getKeys, request->getValues);
759 767