public static RequestInterceptor Create(string realm, MembershipProvider membershipProvider) { var basicAuthenticationCredentialsExtractor = new BasicAuthenticationCredentialsExtractor(new Base64Decoder(), new DecodedCredentialsExtractor()); var httpRequestAuthorizationExtractor = new AuthorizationStringExtractor(); var responseMessageFactory = new ResponseMessageFactory(realm); var serviceSecurityContextFactory = new ServiceSecurityContextFactory(new AuthorizationPolicyFactory()); var basicAuthenticationManager = new BasicAuthenticationManager(basicAuthenticationCredentialsExtractor, httpRequestAuthorizationExtractor, membershipProvider, responseMessageFactory, serviceSecurityContextFactory); return new BasicAuthenticationInterceptor(basicAuthenticationManager); }
public void ShouldAddBasicAuthenticationHeaderToHttpResponse() { const string AuthorizationRealm = "MyAuthorizationRealm"; var responseMessageFactory = new ResponseMessageFactory(AuthorizationRealm); const string AuthorizationHeaderValue = "Basic realm=\"MyAuthorizationRealm\""; Message message = responseMessageFactory.CreateInvalidAuthorizationMessage(); var authenticationRealm = (HttpResponseMessageProperty)message.Properties[HttpResponseMessageProperty.Name]; const string BasicAuthenticationHeaderName = "WWW-Authenticate"; Assert.That(authenticationRealm.Headers[BasicAuthenticationHeaderName], Is.EqualTo(AuthorizationHeaderValue)); }
internal BasicAuthenticationManager(BasicAuthenticationCredentialsExtractor basicAuthenticationCredentialsExtractor, AuthorizationStringExtractor httpRequestAuthorizationExtractor, MembershipProvider membershipProvider, ResponseMessageFactory responseMessageFactory, ServiceSecurityContextFactory serviceSecurityContextFactory) { this.basicAuthenticationCredentialsExtractor = basicAuthenticationCredentialsExtractor; this.httpRequestAuthorizationExtractor = httpRequestAuthorizationExtractor; this.membershipProvider = membershipProvider; this.responseMessageFactory = responseMessageFactory; this.serviceSecurityContextFactory = serviceSecurityContextFactory; }