return sendCoreError(ctx, http.StatusBadRequest, fmt.Sprintf(errMsg, "invalid format for invoker"))
}
+ if im.isInvokerOnboarded(newInvoker) {
+ return sendCoreError(ctx, http.StatusForbidden, fmt.Sprintf(errMsg, "invoker already onboarded"))
+ }
+
if err := im.validateInvoker(newInvoker, ctx); err != nil {
return sendCoreError(ctx, http.StatusBadRequest, fmt.Sprintf(errMsg, err))
}
return nil
}
+func (im *InvokerManager) isInvokerOnboarded(newInvoker invokerapi.APIInvokerEnrolmentDetails) bool {
+ for _, invoker := range im.onboardedInvokers {
+ if newInvoker.OnboardingInformation.ApiInvokerPublicKey == invoker.OnboardingInformation.ApiInvokerPublicKey {
+ return true
+ }
+ }
+ return false
+}
+
func (im *InvokerManager) prepareNewInvoker(newInvoker *invokerapi.APIInvokerEnrolmentDetails) {
var apiList invokerapi.APIList = im.publishRegister.GetAllPublishedServices()
newInvoker.ApiList = &apiList