Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
55 lines (38 sloc) 1.33 KB
// TDAuthorizer.h
// TouchDB
// Created by Jens Alfke on 5/21/12.
// Copyright (c) 2012 Couchbase, Inc. All rights reserved.
#import <Foundation/Foundation.h>
/** Protocol for adding authorization to HTTP requests. */
@protocol TDAuthorizer <NSObject>
/** Should generate and return an authorization string for the given request.
The string, if non-nil, will be set as the value of the "Authorization:" HTTP header. */
- (NSString*) authorizeURLRequest: (NSMutableURLRequest*)request
forRealm: (NSString*)realm;
/** Simple implementation of TDAuthorizer that does HTTP Basic Auth. */
@interface TDBasicAuthorizer : NSObject <TDAuthorizer>
NSURLCredential* _credential;
/** Initialize given a credential object that contains a username and password. */
- (id) initWithCredential: (NSURLCredential*)credential;
/** Implementation of TDAuthorizer that supports MAC authorization as used in OAuth 2. */
@interface TDMACAuthorizer : NSObject <TDAuthorizer>
NSString *_key, *_identifier;
NSDate* _issueTime;
NSData* (*_hmacFunction)(NSData*, NSData*);
/** Initialize given MAC credentials */
- (id) initWithKey: (NSString*)key
identifier: (NSString*)identifier
algorithm: (NSString*)algorithm
issueTime: (NSDate*)issueTime;
Something went wrong with that request. Please try again.