Monotone-Parent: 995b68ade85d0d884cdf8f6fc87e55f0c376a80c

Monotone-Revision: 61fe02b6c3bc4f0aa3797d661d014d8c256b0de9

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2011-12-30T20:39:07
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau
2011-12-30 20:39:07 +00:00
parent 486f0f7ad1
commit 4ba4c622bc
39 changed files with 2041 additions and 1540 deletions
+2
View File
@@ -28,6 +28,7 @@ SOGo_HEADER_FILES = \
\
SOGoUserManager.h \
LDAPSource.h \
LDAPSourceSchema.h \
SQLSource.h \
SOGoUserProfile.h \
SOGoDateFormatter.h \
@@ -97,6 +98,7 @@ SOGo_OBJC_FILES = \
SOGoStartupLogger.m \
SOGoUserManager.m \
LDAPSource.m \
LDAPSourceSchema.m \
SQLSource.m \
SOGoUserProfile.m \
SOGoSQLUserProfile.m \
+13
View File
@@ -30,6 +30,7 @@
#include "SOGoSource.h"
#include "SOGoConstants.h"
@class LDAPSourceSchema;
@class NSDictionary;
@class NSString;
@class NGLdapConnection;
@@ -52,6 +53,7 @@
NSString *_scope;
NSString *baseDN;
LDAPSourceSchema *schema;
NSString *IDField; // the first part of a user DN
NSString *CNField;
NSString *UIDField;
@@ -63,6 +65,9 @@
NSString *domain;
NSString *contactInfoAttribute;
NSDictionary *contactMapping;
NSArray *contactObjectClasses;
NSDictionary *modulesConstraints;
NSMutableArray *searchAttributes;
@@ -74,6 +79,9 @@
/* resources handling */
NSString *kindField;
NSString *multipleBookingsField;
/* ACL */
NSArray *modifiers;
}
- (void) setBindDN: (NSString *) newBindDN
@@ -95,6 +103,11 @@
kindField: (NSString *) newKindField
andMultipleBookingsField: (NSString *) newMultipleBookingsField;
/* This enable the convertion of a contact entry with inetOrgPerson and mozillaAbPerson
to and from an LDAP record */
- (void) setContactMapping: (NSDictionary *) newMapping
andObjectClasses: (NSArray *) newObjectClasses;
- (NGLdapEntry *) lookupGroupEntryByUID: (NSString *) theUID;
- (NGLdapEntry *) lookupGroupEntryByEmail: (NSString *) theEmail;
- (NGLdapEntry *) lookupGroupEntryByAttribute: (NSString *) theAttribute
File diff suppressed because it is too large Load Diff
+1 -2
View File
@@ -35,8 +35,7 @@
- (NSString *) jsonRepresentation;
- (NSString *) keysWithFormat: (NSString *) keyFormat;
// LDIF methods
- (NSString *) userRecordAsLDIFEntry;
- (NSComparisonResult) caseInsensitiveDisplayNameCompare: (NSDictionary *) theDictionary;
@end
-82
View File
@@ -26,12 +26,8 @@
#import <Foundation/NSException.h>
#import <Foundation/NSNull.h>
#import <Foundation/NSString.h>
#import <Foundation/NSCharacterSet.h>
#import <NGExtensions/NGBase64Coding.h>
#import "NSArray+Utilities.h"
#import "NSObject+Utilities.h"
#import "NSString+Utilities.h"
#import "NSDictionary+Utilities.h"
@@ -109,84 +105,6 @@
return [[self objectForKey: @"cn"] caseInsensitiveCompare: [theDictionary objectForKey: @"cn"]];
}
// LDIF Methods
#warning We might want to support more than just strings here
- (void) _appendLDIFKey: (NSString *) key
value: (NSString *) value
toString: (NSMutableString *) ldifString
{
if ([value isKindOfClass: [NSString class]])
{
if ([value _isLDIFSafe])
[ldifString appendFormat: @"%@: %@\n", key, value];
else
[ldifString appendFormat: @"%@:: %@\n",
key, [value stringByEncodingBase64]];
}
}
- (void) _appendLDIFKey: (NSString *) key
toString: (NSMutableString *) ldifString
{
id value;
int count, max;
value = [self objectForKey: key];
if ([value isKindOfClass: [NSArray class]])
{
max = [value count];
for (count = 0; count < max; count++)
[self _appendLDIFKey: key value: [value objectAtIndex: count]
toString: ldifString];
}
else
[self _appendLDIFKey: key value: [self objectForKey: key]
toString: ldifString];
}
- (void) _appendObjectClassesToString: (NSMutableString *) ldifString
{
NSEnumerator *classes;
NSString *currentClass;
classes = [[self objectForKey: @"objectClasses"] objectEnumerator];
while ((currentClass = [classes nextObject]))
[self _appendLDIFKey: @"objectClass" value: currentClass
toString: ldifString];
}
- (NSString *) userRecordAsLDIFEntry
{
NSMutableString *ldifString;
NSEnumerator *keys;
NSString *currentKey;
// {CalendarAccess = YES; MailAccess = YES; c_cn = "Wolfgang Sourdeau"; c_emails = ("wolfgang@test.com"); c_name = "wolfgang@test.com"; c_uid = "wolfgang@test.com"; cn = "wolfgang@test.com"; displayName = "Wolfgang Sourdeau"; dn = "cn=wolfgang@test.com,ou=evariste,o=inverse.ca"; givenName = Wolfgang; mail = "wolfgang@test.com"; objectClass = organizationalPerson; sn = Sourdeau; }
ldifString = [NSMutableString string];
[self _appendLDIFKey: @"dn" toString: ldifString];
[self _appendObjectClassesToString: ldifString];
keys = [[self allKeys] objectEnumerator];
while ((currentKey = [keys nextObject]))
{
if (!([currentKey isEqualToString: @"CalendarAccess"]
|| [currentKey isEqualToString: @"MailAccess"]
|| [currentKey isEqualToString: @"ContactAccess"]
|| [currentKey hasPrefix: @"objectClass"]
|| [currentKey hasPrefix: @"c_"]
|| [currentKey isEqualToString: @"dn"]
|| [currentKey isEqualToString: @"isGroup"]
|| [currentKey isEqualToString: @"isResource"]
|| [currentKey isEqualToString: @"numberOfSimultaneousBookings"]
|| [currentKey isEqualToString: @"canAuthenticate"]))
[self _appendLDIFKey: currentKey toString: ldifString];
}
return ldifString;
}
@end
@implementation NSMutableDictionary (SOGoDictionaryUtilities)
-2
View File
@@ -62,8 +62,6 @@
- (int) timeValue;
- (BOOL) _isLDIFSafe;
- (BOOL) isJSONString;
- (id) objectFromJSONString;
-38
View File
@@ -486,44 +486,6 @@ static int cssEscapingCount;
return time;
}
static NSMutableCharacterSet *safeLDIFChars = nil;
static NSMutableCharacterSet *safeLDIFStartChars = nil;
- (void) _initSafeLDIFChars
{
safeLDIFChars = [NSMutableCharacterSet new];
[safeLDIFChars addCharactersInRange: NSMakeRange (0x01, 9)];
[safeLDIFChars addCharactersInRange: NSMakeRange (0x0b, 2)];
[safeLDIFChars addCharactersInRange: NSMakeRange (0x0e, 114)];
safeLDIFStartChars = [safeLDIFChars mutableCopy];
[safeLDIFStartChars removeCharactersInString: @" :<"];
}
- (BOOL) _isLDIFSafe
{
int count, max;
BOOL rc;
if (!safeLDIFChars)
[self _initSafeLDIFChars];
rc = YES;
max = [self length];
if (max > 0)
{
if ([safeLDIFStartChars characterIsMember: [self characterAtIndex: 0]])
for (count = 1; rc && count < max; count++)
rc = [safeLDIFChars
characterIsMember: [self characterAtIndex: count]];
else
rc = NO;
}
return rc;
}
- (BOOL) isJSONString
{
NSDictionary *jsonData;
+8 -1
View File
@@ -28,9 +28,10 @@
#import "SOGoConstants.h"
@class NSDictionary;
@class NSException;
@class NSString;
@protocol SOGoSource
@protocol SOGoSource <NSObject>
+ (id) sourceFromUDSource: (NSDictionary *) udSource
inDomain: (NSString *) domain;
@@ -57,6 +58,12 @@
- (NSArray *) allEntryIDs;
- (NSArray *) fetchContactsMatching: (NSString *) filter;
- (NSString *) sourceID;
- (NSArray *) modifiers;
- (NSException *) addContactEntry: (NSDictionary *) roLdifRecord
withID: (NSString *) aId;
- (NSException *) updateContactEntry: (NSDictionary *) ldifRecord;
- (NSException *) removeContactEntryWithID: (NSString *) aId;
@end
+58 -1
View File
@@ -22,8 +22,9 @@
*/
#import <Foundation/NSArray.h>
#import <Foundation/NSObject.h>
#import <Foundation/NSDictionary.h>
#import <Foundation/NSException.h>
#import <Foundation/NSObject.h>
#import <Foundation/NSString.h>
#import <Foundation/NSValue.h>
#import <Foundation/NSURL.h>
@@ -379,6 +380,7 @@
{
NSMutableDictionary *response;
NSMutableArray *qualifiers;
NSArray *fieldNames;
EOAdaptorChannel *channel;
EOQualifier *loginQualifier, *qualifier;
GCSChannelManager *cm;
@@ -463,6 +465,16 @@
[response autorelease];
[channel cancelFetch];
/* Convert all c_ fields to obtain their ldif equivalent */
fieldNames = [response allKeys];
for (i = 0; i < [fieldNames count]; i++)
{
field = [fieldNames objectAtIndex: i];
if ([field hasPrefix: @"c_"])
[response setObject: [response objectForKey: field]
forKey: [field substringFromIndex: 2]];
}
// We have to do this here since we do not manage modules
// constraints right now over a SQL backend.
[response setObject: [NSNumber numberWithBool: YES] forKey: @"CalendarAccess"];
@@ -684,4 +696,49 @@
return _sourceID;
}
- (NSArray *) modifiers
{
return nil;
}
- (NSException *) addContactEntry: (NSDictionary *) roLdifRecord
withID: (NSString *) aId
{
NSString *reason;
reason = [NSString stringWithFormat: @"method '%@' is not available"
@" for class '%@'", NSStringFromSelector (_cmd),
NSStringFromClass (isa)];
return [NSException exceptionWithName: @"SQLSourceIOException"
reason: reason
userInfo: nil];
}
- (NSException *) updateContactEntry: (NSDictionary *) roLdifRecord
{
NSString *reason;
reason = [NSString stringWithFormat: @"method '%@' is not available"
@" for class '%@'", NSStringFromSelector (_cmd),
NSStringFromClass (isa)];
return [NSException exceptionWithName: @"SQLSourceIOException"
reason: reason
userInfo: nil];
}
- (NSException *) removeContactEntryWithID: (NSString *) aId
{
NSString *reason;
reason = [NSString stringWithFormat: @"method '%@' is not available"
@" for class '%@'", NSStringFromSelector (_cmd),
NSStringFromClass (isa)];
return [NSException exceptionWithName: @"SQLSourceIOException"
reason: reason
userInfo: nil];
}
@end