mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-24 09:59:43 +00:00
added more infrastructure for KeepassHttp
This commit is contained in:
@@ -15,7 +15,6 @@
|
||||
}
|
||||
|
||||
- (void)respondTo:(NSDictionary *)data {
|
||||
// todo;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -32,7 +32,7 @@ NSString *const MPRequestTypeKey = @"RequestType";
|
||||
// See also: expectsRequestBodyFromMethod:atPath:
|
||||
|
||||
if([method isEqualToString:@"POST"]) {
|
||||
return YES;
|
||||
return (requestContentLength < 500);
|
||||
}
|
||||
return [super supportsMethod:method atPath:path];
|
||||
}
|
||||
@@ -55,6 +55,9 @@ NSString *const MPRequestTypeKey = @"RequestType";
|
||||
}
|
||||
|
||||
- (void)processBodyData:(NSData *)postDataChunk {
|
||||
/*
|
||||
Store the data in the message body
|
||||
*/
|
||||
[request appendData:postDataChunk];
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ APPKIT_EXTERN NSString *const MPDocumentGroupKey;
|
||||
|
||||
@class KdbGroup;
|
||||
@class KdbEntry;
|
||||
@class UUID;
|
||||
|
||||
@interface MPDocument : NSDocument
|
||||
|
||||
@@ -33,6 +34,9 @@ APPKIT_EXTERN NSString *const MPDocumentGroupKey;
|
||||
- (id)initWithVersion:(MPDatabaseVersion)version;
|
||||
- (BOOL)decryptWithPassword:(NSString *)password keyFileURL:(NSURL *)keyFileURL;
|
||||
|
||||
/* Lookup */
|
||||
- (KdbEntry *)findEntry:(UUID *)uuid;
|
||||
|
||||
/* Undoable Intiialization of elements */
|
||||
- (KdbGroup *)createGroup:(KdbGroup *)parent;
|
||||
- (KdbEntry *)createEntry:(KdbGroup *)parent;
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#import "MPDatabaseVersion.h"
|
||||
#import "KdbGroup+Undo.h"
|
||||
#import "KdbGroup+KVOAdditions.h"
|
||||
#import "KdbGroup+MPTreeTools.h"
|
||||
#import "KdbEntry+Undo.h"
|
||||
|
||||
NSString *const MPDocumentDidAddGroupNotification = @"MPDocumentDidAddGroupNotification";
|
||||
@@ -43,7 +44,7 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey";
|
||||
{
|
||||
return [self initWithVersion:MPDatabaseVersion4];
|
||||
}
|
||||
|
||||
#pragma mark NSDocument essentials
|
||||
- (id)initWithVersion:(MPDatabaseVersion)version {
|
||||
self = [super init];
|
||||
if(self) {
|
||||
@@ -67,7 +68,7 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey";
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) makeWindowControllers {
|
||||
- (void)makeWindowControllers {
|
||||
MPDocumentWindowController *windowController = [[MPDocumentWindowController alloc] init];
|
||||
[self addWindowController:windowController];
|
||||
[windowController release];
|
||||
@@ -100,6 +101,7 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey";
|
||||
return _isDecrypted;
|
||||
}
|
||||
|
||||
#pragma mark Protection
|
||||
- (BOOL)decryptWithPassword:(NSString *)password keyFileURL:(NSURL *)keyFileURL {
|
||||
self.password = password;
|
||||
@try {
|
||||
@@ -146,10 +148,17 @@ NSString *const MPDocumentGroupKey = @"MPDocumentGroupKey";
|
||||
return NO;
|
||||
}
|
||||
|
||||
#pragma mark Data Accesors
|
||||
- (KdbGroup *)root {
|
||||
return [self.tree root];
|
||||
}
|
||||
|
||||
- (KdbEntry *)findEntry:(UUID *)uuid {
|
||||
return [self.root entryForUUID:uuid];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark Data manipulation
|
||||
- (KdbEntry *)createEntry:(KdbGroup *)parent {
|
||||
KdbEntry *newEntry = [self.tree createEntry:parent];
|
||||
newEntry.title = NSLocalizedString(@"DEFAULT_ENTRY_TITLE", @"Title for a newly created entry");
|
||||
|
||||
20
MacPass/MPDocumentQueryService.h
Normal file
20
MacPass/MPDocumentQueryService.h
Normal file
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// MPDocumentQueryService.h
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 17.06.13.
|
||||
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@class KdbEntry;
|
||||
|
||||
@interface MPDocumentQueryService : NSObject
|
||||
|
||||
+ (MPDocumentQueryService *)defaultService;
|
||||
|
||||
- (KdbEntry *)configurationEntry;
|
||||
- (KdbEntry *)createConfigurationEntry;
|
||||
|
||||
@end
|
||||
69
MacPass/MPDocumentQueryService.m
Normal file
69
MacPass/MPDocumentQueryService.m
Normal file
@@ -0,0 +1,69 @@
|
||||
//
|
||||
// MPDocumentQueryService.m
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 17.06.13.
|
||||
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MPDocumentQueryService.h"
|
||||
#import "MPDocument.h"
|
||||
#import "UUID.h"
|
||||
|
||||
@interface MPDocumentQueryService () {
|
||||
@private
|
||||
UUID *rootUuid;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation MPDocumentQueryService
|
||||
|
||||
+ (MPDocumentQueryService *)defaultService {
|
||||
static id instance;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
instance = [[MPDocumentQueryService alloc] init];
|
||||
});
|
||||
return instance;
|
||||
}
|
||||
|
||||
- (id)init {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
static const Byte uuidBytes[] = {
|
||||
0x34, 0x69, 0x7a, 0x40, 0x8a, 0x5b, 0x41, 0xc0,
|
||||
0x9f, 0x36, 0x89, 0x7d, 0x62, 0x3e, 0xcb, 0x31
|
||||
};
|
||||
NSData *data = [NSData dataWithBytes:uuidBytes length:16];
|
||||
rootUuid = [[UUID alloc] initWithData:data];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[rootUuid release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (KdbEntry *)configurationEntry {
|
||||
/*
|
||||
We are looking in all document,
|
||||
but only store the key in one.
|
||||
*/
|
||||
NSArray *documents = [[NSDocumentController sharedDocumentController] documents];
|
||||
for(MPDocument *document in documents) {
|
||||
KdbEntry *entry = [document findEntry:rootUuid];
|
||||
if(entry) {
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (KdbEntry *)createConfigurationEntry {
|
||||
return nil;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -22,4 +22,6 @@ FOUNDATION_EXPORT NSString *const MPRequestTypeGeneratePassword;
|
||||
|
||||
+ (id<MPServerRequestHandler>)requestHandler:(NSString *)identifier;
|
||||
|
||||
+ (BOOL)validKeyProposal;
|
||||
|
||||
@end
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#import "MPRequestHandlerService.h"
|
||||
#import "MPServerRequestHandler.h"
|
||||
#import "MPAssociateRequestHandler.h"
|
||||
#import "MPTestAssociateRequestHanlder.h"
|
||||
#import "MPTestAssociateRequestHandler.h"
|
||||
|
||||
//NSString *const MPRequestTypeAssociate = @"associate";
|
||||
//NSString *const MPRequestTypeTestAssociate = @"test-associate";
|
||||
@@ -36,13 +36,18 @@ NSString *const MPRequestTypeGeneratePassword = @"generate-password";
|
||||
|
||||
+ (NSDictionary *)_setupHandlerDictionary {
|
||||
MPAssociateRequestHandler *associateHandler = [[MPAssociateRequestHandler alloc] init];
|
||||
MPTestAssociateRequestHanlder *testAssociateHandler = [[MPTestAssociateRequestHanlder alloc] init];
|
||||
MPTestAssociateRequestHandler *testAssociateHandler = [[MPTestAssociateRequestHandler alloc] init];
|
||||
NSDictionary *handlerDict = @{
|
||||
[associateHandler identifier] : associateHandler,
|
||||
[testAssociateHandler identifier] : testAssociateHandler
|
||||
};
|
||||
[associateHandler release];
|
||||
[testAssociateHandler release];
|
||||
return handlerDict;
|
||||
}
|
||||
|
||||
+ (BOOL)validKeyProposal {
|
||||
return NO;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -9,6 +9,6 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "MPServerRequestHandler.h"
|
||||
|
||||
@interface MPTestAssociateRequestHanlder : NSObject <MPServerRequestHandler>
|
||||
@interface MPTestAssociateRequestHandler : NSObject <MPServerRequestHandler>
|
||||
|
||||
@end
|
||||
26
MacPass/MPTestAssociateRequestHandler.m
Normal file
26
MacPass/MPTestAssociateRequestHandler.m
Normal file
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// MPTestAssociateRequestHanlder.m
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 17.06.13.
|
||||
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MPTestAssociateRequestHandler.h"
|
||||
#import "MPDocumentQueryService.h"
|
||||
|
||||
@implementation MPTestAssociateRequestHandler
|
||||
|
||||
- (NSString *)identifier {
|
||||
return @"test-associate";
|
||||
}
|
||||
|
||||
- (void)respondTo:(NSDictionary *)data {
|
||||
MPDocumentQueryService *service = [MPDocumentQueryService defaultService];
|
||||
if(![service configurationEntry]) {
|
||||
return; //Nothing to do
|
||||
}
|
||||
//TestRequestedData
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -1,21 +0,0 @@
|
||||
//
|
||||
// MPTestAssociateRequestHanlder.m
|
||||
// MacPass
|
||||
//
|
||||
// Created by Michael Starke on 17.06.13.
|
||||
// Copyright (c) 2013 HicknHack Software GmbH. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MPTestAssociateRequestHanlder.h"
|
||||
|
||||
@implementation MPTestAssociateRequestHanlder
|
||||
|
||||
- (NSString *)identifier {
|
||||
return @"test-associate";
|
||||
}
|
||||
|
||||
- (void)respondTo:(NSDictionary *)data {
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -48,7 +48,7 @@
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>573</string>
|
||||
<string>579</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
|
||||
Reference in New Issue
Block a user