public override void Validate() { if (string.IsNullOrEmpty(this.ResponseType) || string.IsNullOrEmpty(this.ClientId) || this.RedirectUri == null) { throw new OAuthMessageException(Resources.ID3716); } if (!EndUserAuthorizationRequest.IsValidResponseType(this.ResponseType)) { throw new OAuthMessageException( string.Format(Resources.ID3717, this.ResponseType)); } }
protected virtual OAuthMessage CreateTypedOAuthMessageFromParameters(Uri baseUri, NameValueCollection parameters) { if (parameters == null) { throw new ArgumentNullException("parameters"); } OAuthMessage request = null; if (parameters["response_type"] == "code" || parameters["response_type"] == "token") { request = new EndUserAuthorizationRequest(baseUri); } if (!string.IsNullOrEmpty(parameters["code"]) || (!string.IsNullOrEmpty(parameters["access_token"]) && string.IsNullOrEmpty(parameters["refresh_token"]))) { request = new EndUserAuthorizationResponse(baseUri); } if (!string.IsNullOrEmpty(parameters["error"])) { request = new EndUserAuthorizationFailedResponse(baseUri); } if (!string.IsNullOrEmpty(parameters["grant_type"]) && parameters["grant_type"] == "authorization_code") { request = new AccessTokenRequestWithAuthorizationCode(baseUri); } if (!string.IsNullOrEmpty(parameters["grant_type"]) && parameters["grant_type"] == OAuthConstants.AccessGrantType.ClientCredentials) { request = new AccessTokenRequest(baseUri); } if (!string.IsNullOrEmpty(parameters["access_token"])) { request = new AccessTokenResponse(baseUri); } if (request == null) { throw new OAuthMessageSerializationException(Resources.ID3723); } request.Parameters.Add(parameters); request.Validate(); return(request); }
protected virtual OAuthMessage CreateTypedOAuthMessageFromParameters(Uri baseUri, NameValueCollection parameters) { if (parameters == null) { throw new ArgumentNullException("parameters"); } OAuthMessage request = null; if (parameters["response_type"] == "code" || parameters["response_type"] == "token") { request = new EndUserAuthorizationRequest(baseUri); } if (!string.IsNullOrEmpty(parameters["code"]) || (!string.IsNullOrEmpty(parameters["access_token"]) && string.IsNullOrEmpty(parameters["refresh_token"]))) { request = new EndUserAuthorizationResponse(baseUri); } if (!string.IsNullOrEmpty(parameters["error"])) { request = new EndUserAuthorizationFailedResponse(baseUri); } if (!string.IsNullOrEmpty(parameters["grant_type"]) && parameters["grant_type"] == "authorization_code") { request = new AccessTokenRequestWithAuthorizationCode(baseUri); } if (!string.IsNullOrEmpty(parameters["access_token"])) { request = new AccessTokenResponse(baseUri); } if (request == null) { throw new OAuthMessageSerializationException(Resources.ID3723); } request.Parameters.Add(parameters); request.Validate(); return request; }