protected bool ValidateRequest(HttpRequest request, RequestValidationType validationType, Application application = null) { var creds = GetCredentialsFromAuthorizationHeader(request); if (ValidateCredentials(creds)) { if (application is null) { return(false); } return((validationType == RequestValidationType.CredentialsAndOwner) ? application.OwnerEmail.ToUpper() == creds.Value.Email.ToUpper() : application.OwnerEmail.ToUpper() == creds.Value.Email.ToUpper() && ValidateIPIfNecessary(application)); } else { return(false); } }
public void ValidateBeforeRequest(RequestValidationType tokenType) { if (this.Credentials == null) { throw new ArgumentNullException("You must set the Quickblox API Credentials Object to the QuickBloxClient."); } else { if (String.IsNullOrEmpty(this.Credentials.ApplicationID) || String.IsNullOrEmpty(this.Credentials.AuthKey) || String.IsNullOrEmpty(this.Credentials.AuthSecret)) { throw new ArgumentNullException("The Application Credentials must be set in the Quick Blox Client, you require ApplicationID, AuthKey & AuthSecret"); } } if (tokenType == RequestValidationType.QuickBloxUserToken) { if (this.UserCredentials == null || String.IsNullOrEmpty(UserCredentials.UserLogin) || String.IsNullOrEmpty(UserCredentials.Password)) { throw new ArgumentNullException("The request is an quickblox user orientated request.\n This kind of request requires you to enter login credentials as either the Admin user, or a user of the quickblox app you are trying to use."); } } }