comparison Plugin/AuthorizationWebService.cpp @ 73:512247750f0a

new ValidityDuration arg in create token API
author Alain Mazy <am@osimis.io>
date Fri, 03 Mar 2023 10:41:27 +0100
parents e381ba725669
children aa73b10c2db9
comparison
equal deleted inserted replaced
72:e381ba725669 73:512247750f0a
165 165
166 bool AuthorizationWebService::CreateToken(IAuthorizationService::CreatedToken& response, 166 bool AuthorizationWebService::CreateToken(IAuthorizationService::CreatedToken& response,
167 const std::string& tokenType, 167 const std::string& tokenType,
168 const std::string& id, 168 const std::string& id,
169 const std::vector<IAuthorizationService::OrthancResource>& resources, 169 const std::vector<IAuthorizationService::OrthancResource>& resources,
170 const std::string& expirationDateString) 170 const std::string& expirationDateString,
171 const uint64_t& validityDuration)
171 { 172 {
172 if (tokenCreationBaseUrl_.empty()) 173 if (tokenCreationBaseUrl_.empty())
173 { 174 {
174 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadRequest, "Can not create tokens if the 'WebServiceTokenCreationBaseUrl' is not configured"); 175 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadRequest, "Can not create tokens if the 'WebServiceTokenCreationBaseUrl' is not configured");
175 } 176 }
215 216
216 body["type"] = tokenType; 217 body["type"] = tokenType;
217 if (!expirationDateString.empty()) 218 if (!expirationDateString.empty())
218 { 219 {
219 body["expiration-date"] = expirationDateString; 220 body["expiration-date"] = expirationDateString;
221 }
222 if (validityDuration > 0)
223 {
224 body["validity-duration"] = validityDuration;
220 } 225 }
221 226
222 std::string bodyAsString; 227 std::string bodyAsString;
223 Orthanc::Toolbox::WriteFastJson(bodyAsString, body); 228 Orthanc::Toolbox::WriteFastJson(bodyAsString, body);
224 229