MCPcopy Create free account
hub / github.com/Icinga/icinga2 / GenerateTicket

Method GenerateTicket

lib/icinga/apiactions.cpp:644–665  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

642}
643
644Dictionary::Ptr ApiActions::GenerateTicket(const ConfigObject::Ptr&, const ApiUser::Ptr&, const Dictionary::Ptr& params)
645{
646 if (!params->Contains("cn"))
647 return ApiActions::CreateResult(400, "Option 'cn' is required");
648
649 String cn = HttpUtility::GetLastParameter(params, "cn");
650
651 ApiListener::Ptr listener = ApiListener::GetInstance();
652 String salt = listener->GetTicketSalt();
653
654 if (salt.IsEmpty())
655 return ApiActions::CreateResult(500, "Ticket salt is not configured in ApiListener object");
656
657 String ticket = PBKDF2_SHA1(cn, salt, 50000);
658
659 Dictionary::Ptr additional = new Dictionary({
660 { "ticket", ticket }
661 });
662
663 return ApiActions::CreateResult(200, "Generated PKI ticket '" + ticket + "' for common name '"
664 + cn + "'.", additional);
665}
666
667Value ApiActions::GetSingleObjectByNameUsingPermissions(const String& type, const String& objectName, const ApiUser::Ptr& user)
668{

Callers

nothing calls this directly

Calls 3

PBKDF2_SHA1Function · 0.85
ContainsMethod · 0.45
IsEmptyMethod · 0.45

Tested by

no test coverage detected