mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-10-11 23:07:12 +00:00
Monotone-Parent: 41d1207879302957d2bb9e04793e78a7966863a0
Monotone-Revision: dc11ca564098f1f86ef07bafa645a1bc433e3cd7 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-06-14T21:23:14 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
1 parent
2cc3f8684d
commit
777a7f75e7
12 files changed
+62
-257
No files matched your search
@@ -31,7 +31,6 @@ libSOGo_HEADER_FILES = \
|
||||
LDAPUserManager.h \
|
||||
LDAPSource.h \
|
||||
SOGoPermissions.h \
|
||||
SOGoLRUCache.h \
|
||||
WOContext+Agenor.h \
|
||||
SOGoDAVRendererTypes.h \
|
||||
NSArray+Utilities.h \
|
||||
@@ -57,7 +56,6 @@ libSOGo_OBJC_FILES = \
|
||||
SOGoCustomGroupFolder.m \
|
||||
\
|
||||
SOGoPermissions.m \
|
||||
SOGoLRUCache.m \
|
||||
LDAPUserManager.m \
|
||||
LDAPSource.m \
|
||||
WOContext+Agenor.m \
|
||||
|
||||
@@ -38,17 +38,12 @@
|
||||
|
||||
@interface SOGoAuthenticator : SoHTTPAuthenticator
|
||||
{
|
||||
NSUserDefaults *ud;
|
||||
NSString *authMethod;
|
||||
NSString *LDAPBaseDN;
|
||||
NSString *LDAPHost;
|
||||
int LDAPPort;
|
||||
}
|
||||
|
||||
+ (id) sharedSOGoAuthenticator;
|
||||
|
||||
- (BOOL) LDAPCheckLogin: (NSString *) _login password: (NSString *) _pwd;
|
||||
|
||||
- (SOGoUser *) userInContext: (WOContext *) _ctx;
|
||||
|
||||
@end
|
||||
|
||||
@@ -30,32 +30,25 @@
|
||||
|
||||
@implementation SOGoAuthenticator
|
||||
|
||||
static SOGoAuthenticator *auth = nil;
|
||||
|
||||
+ (id) sharedSOGoAuthenticator
|
||||
{
|
||||
if (auth == nil)
|
||||
auth = [[self alloc] init];
|
||||
static SOGoAuthenticator *auth = nil;
|
||||
|
||||
if (!auth)
|
||||
auth = [self new];
|
||||
|
||||
return auth;
|
||||
}
|
||||
|
||||
- (id) init
|
||||
{
|
||||
NSUserDefaults *ud;
|
||||
|
||||
if ((self = [super init]))
|
||||
{
|
||||
ud = [NSUserDefaults standardUserDefaults];
|
||||
|
||||
LDAPBaseDN = nil;
|
||||
LDAPHost = nil;
|
||||
LDAPPort = -1;
|
||||
|
||||
authMethod = [[ud stringForKey:@"AuthentificationMethod"] retain];
|
||||
if ([authMethod isEqualToString: @"LDAP"])
|
||||
{
|
||||
// LDAPBaseDN = [[ud stringForKey:@"LDAPRootDN"] retain];
|
||||
// LDAPHost = [[ud stringForKey:@"LDAPHost"] retain];
|
||||
// LDAPPort = [ud integerForKey:@"LDAPPort"];
|
||||
}
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -63,10 +56,6 @@ static SOGoAuthenticator *auth = nil;
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
if (LDAPBaseDN)
|
||||
[LDAPBaseDN release];
|
||||
if (LDAPHost)
|
||||
[LDAPHost release];
|
||||
[authMethod release];
|
||||
[super dealloc];
|
||||
}
|
||||
@@ -75,25 +64,19 @@ static SOGoAuthenticator *auth = nil;
|
||||
password: (NSString *) _pwd
|
||||
{
|
||||
BOOL accept;
|
||||
LDAPUserManager *um;
|
||||
|
||||
if ([authMethod isEqualToString: @"LDAP"])
|
||||
accept = [self LDAPCheckLogin: _login password: _pwd];
|
||||
{
|
||||
um = [LDAPUserManager sharedUserManager];
|
||||
accept = [um checkLogin: _login andPassword: _pwd];
|
||||
}
|
||||
else
|
||||
accept = ([_login length] > 0);
|
||||
|
||||
return (([_login isEqualToString: @"freebusy"]
|
||||
&& [_pwd isEqualToString: @"freebusy"])
|
||||
|| accept);
|
||||
}
|
||||
|
||||
- (BOOL) LDAPCheckLogin: (NSString *) _login
|
||||
password: (NSString *) _pwd
|
||||
{
|
||||
LDAPUserManager *um;
|
||||
|
||||
um = [LDAPUserManager sharedUserManager];
|
||||
|
||||
return [um checkLogin: _login andPassword: _pwd];
|
||||
return (accept
|
||||
|| ([_login isEqualToString: @"freebusy"]
|
||||
&& [_pwd isEqualToString: @"freebusy"]));
|
||||
}
|
||||
|
||||
/* create SOGoUser */
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2000-2004 SKYRIX Software AG
|
||||
|
||||
This file is part of OGo
|
||||
|
||||
OGo is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU Lesser General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
OGo is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with OGo; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||
02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __SOGoLRUCache_H_
|
||||
#define __SOGoLRUCache_H_
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface SOGoLRUCache : NSObject
|
||||
{
|
||||
unsigned size;
|
||||
NSMutableDictionary *entries;
|
||||
}
|
||||
|
||||
- (id)initWithCacheSize:(unsigned)_size;
|
||||
|
||||
- (void)addObject:(id)_obj forKey:(id)_key;
|
||||
- (id)objectForKey:(id)_key;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* __SOGoLRUCache_H_ */
|
||||
@@ -1,112 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2000-2004 SKYRIX Software AG
|
||||
|
||||
This file is part of OGo
|
||||
|
||||
OGo is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU Lesser General Public License as published by the
|
||||
Free Software Foundation; either version 2, or (at your option) any
|
||||
later version.
|
||||
|
||||
OGo is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with OGo; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
||||
02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "SOGoLRUCache.h"
|
||||
#include "common.h"
|
||||
|
||||
@interface SOGoLRUCacheItem : NSObject
|
||||
{
|
||||
id object;
|
||||
unsigned useCount;
|
||||
}
|
||||
|
||||
- (id)initWithObject:(id)_obj;
|
||||
- (id)object;
|
||||
|
||||
- (unsigned)useCount;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SOGoLRUCacheItem
|
||||
|
||||
- (id)initWithObject:(id)_obj {
|
||||
self = [super init];
|
||||
if(self) {
|
||||
ASSIGN(self->object, _obj);
|
||||
self->useCount = 1;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)object {
|
||||
self->useCount++;
|
||||
return self->object;
|
||||
}
|
||||
|
||||
- (unsigned)useCount {
|
||||
return self->useCount;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation SOGoLRUCache
|
||||
|
||||
- (id)initWithCacheSize:(unsigned)_size {
|
||||
self = [super init];
|
||||
if(self) {
|
||||
self->size = _size;
|
||||
self->entries = [[NSMutableDictionary alloc] initWithCapacity:_size];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
[self->entries release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void)addObject:(id)_obj forKey:(id)_key {
|
||||
SOGoLRUCacheItem *item;
|
||||
|
||||
NSAssert(_obj, @"Attempt to insert nil object!");
|
||||
|
||||
if([self->entries count] >= self->size) {
|
||||
/* need to find minimum and get rid of it */
|
||||
NSEnumerator *keyEnum;
|
||||
SOGoLRUCacheItem *item;
|
||||
id key, leastUsedItemKey;
|
||||
unsigned minimumUseCount = INT_MAX;
|
||||
|
||||
keyEnum = [self->entries keyEnumerator];
|
||||
while((key = [keyEnum nextObject])) {
|
||||
item = [self->entries objectForKey:key];
|
||||
if([item useCount] < minimumUseCount) {
|
||||
minimumUseCount = [item useCount];
|
||||
leastUsedItemKey = key;
|
||||
}
|
||||
}
|
||||
[self->entries removeObjectForKey:leastUsedItemKey];
|
||||
}
|
||||
item = [[SOGoLRUCacheItem alloc] initWithObject:_obj];
|
||||
[self->entries setObject:item forKey:_key];
|
||||
[item release];
|
||||
}
|
||||
|
||||
- (id)objectForKey:(id)_key {
|
||||
SOGoLRUCacheItem *item;
|
||||
|
||||
item = [self->entries objectForKey:_key];
|
||||
if(!item)
|
||||
return nil;
|
||||
return [item object];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -19,8 +19,8 @@
|
||||
02111-1307, USA.
|
||||
*/
|
||||
|
||||
#import "WOContext+Agenor.h"
|
||||
#import "common.h"
|
||||
|
||||
#import "SOGoUser.h"
|
||||
|
||||
#import "Appointments/SOGoAppointmentFolder.h"
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
*/
|
||||
// $Id: common.h 96 2004-06-30 08:35:34Z helge $
|
||||
|
||||
#warning importing common is baaad
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#if NeXT_Foundation_LIBRARY || COCOA_Foundation_LIBRARY
|
||||
|
||||
Reference in new issue
Block a user