/// <summary> /// Try to authenticate the client. /// </summary> /// <param name="authorizationServerHost">Provides host-specific authorization server services needed by this library.</param> /// <param name="requestMessage">A direct message from the client to the authorization server that includes the client's credentials.</param> /// <param name="clientIdentifier">The client identifier.</param> /// <returns>Describes the various levels at which client information may be extracted from an inbound message.</returns> public override Framework.ChannelElements.ClientAuthenticationResult TryAuthenticateClient( Session.IAuthorizationServerHost authorizationServerHost, Consumer.Session.Authorization.Messages.AuthenticatedClientRequestBase requestMessage, out string clientIdentifier) { // Set the initial client identifier to null. clientIdentifier = null; // If a client identifier exists. if (!string.IsNullOrEmpty(requestMessage.ClientIdentifier)) { // Get the client decription. IF client not found // then return un-authenticated. var client = authorizationServerHost.GetClient(requestMessage.ClientIdentifier); if (client != null) { // Get the client secret. If no secret foune then // return un-authenticated. string consumerSecret = _consumerStore.GetConsumerSecret(requestMessage.ClientIdentifier); if (!string.IsNullOrEmpty(consumerSecret)) { // If the client secret is valid. if (client.IsValidClientSecret(consumerSecret)) { // Set the client identifier and // authenticate the client. clientIdentifier = requestMessage.ClientIdentifier; return(Framework.ChannelElements.ClientAuthenticationResult.ClientAuthenticated); } else { // Invalid client secret return(Framework.ChannelElements.ClientAuthenticationResult.ClientAuthenticationRejected); } } else { // No client secret provided return(Framework.ChannelElements.ClientAuthenticationResult.ClientIdNotAuthenticated); } } else { // The client identifier is not recognized. return(Framework.ChannelElements.ClientAuthenticationResult.ClientAuthenticationRejected); } } else { // No client id provided. return(Framework.ChannelElements.ClientAuthenticationResult.NoAuthenticationRecognized); } }
protected virtual SigningContext CreateSignatureContextForConsumer(IOAuthContext context) { var signingContext = new SigningContext { ConsumerSecret = _consumerStore.GetConsumerSecret(context) }; if (SignatureMethodRequiresCertificate(context.SignatureMethod)) { signingContext.Algorithm = _consumerStore.GetConsumerPublicKey(context); } return(signingContext); }