diff --git a/Main/SOGo.m b/Main/SOGo.m index 646fe90af..289974af5 100644 --- a/Main/SOGo.m +++ b/Main/SOGo.m @@ -370,9 +370,11 @@ static BOOL debugLeaks; id userFolder; NSData *decodedLogin; NSString *login; - - login = [SOGoUser getDecryptedUsernameIfNeeded: _key]; - + WORequest *request; + + request = [_ctx request]; + login = [SOGoUser getDecryptedUsernameIfNeeded: _key request: request]; + user = [SOGoUser userWithLogin: login roles: nil]; if (user) userFolder = [$(@"SOGoUserFolder") objectWithName: login diff --git a/SoObjects/SOGo/SOGoObject.m b/SoObjects/SOGo/SOGoObject.m index 6435f932c..bd61ac156 100644 --- a/SoObjects/SOGo/SOGoObject.m +++ b/SoObjects/SOGo/SOGoObject.m @@ -980,7 +980,7 @@ if ([[[path objectAtIndex: i] lowercaseString] isEqualToString:@"dav"]) { if ([path count] > (i + 1)) { [path replaceObjectAtIndex: (i +1) - withObject: [SOGoUser getDecryptedUsernameIfNeeded: [path objectAtIndex: (i + 1)]]]; + withObject: [SOGoUser getDecryptedUsernameIfNeeded: [path objectAtIndex: (i + 1)] request: [context request]]]; } } } diff --git a/SoObjects/SOGo/SOGoUser.h b/SoObjects/SOGo/SOGoUser.h index a15e2d0e3..ab43832a5 100644 --- a/SoObjects/SOGo/SOGoUser.h +++ b/SoObjects/SOGo/SOGoUser.h @@ -41,6 +41,7 @@ @class NSString; @class WOContext; +@class WORequest; @class SOGoAppointmentFolder; @class SOGoAppointmentFolders; @@ -136,8 +137,8 @@ - (SOGoContactFolder *) personalContactsFolderInContext: (WOContext *) context; /* Encryption */ -+ (NSString *)getEncryptedUsernameIfNeeded:(NSString *)username; -+ (NSString *)getDecryptedUsernameIfNeeded:(NSString *)username; ++ (NSString *)getEncryptedUsernameIfNeeded:(NSString *)username request:(WORequest *)request; ++ (NSString *)getDecryptedUsernameIfNeeded:(NSString *)username request:(WORequest *)request; @end diff --git a/SoObjects/SOGo/SOGoUser.m b/SoObjects/SOGo/SOGoUser.m index 1c2a3142d..52a8c507b 100644 --- a/SoObjects/SOGo/SOGoUser.m +++ b/SoObjects/SOGo/SOGoUser.m @@ -1296,13 +1296,13 @@ static const NSString *kEncryptedUserNamePrefix = @"uenc"; } /* Encryption */ -+ (NSString *) getEncryptedUsernameIfNeeded:(NSString *)username ++ (NSString *) getEncryptedUsernameIfNeeded:(NSString *)username request: (WORequest *)request { NSException *exception; NSString *tmp, *cacheKey; SOGoCache *cache; - if (![[SOGoSystemDefaults sharedSystemDefaults] isURLEncryptionEnabled] || [username isEqualToString: @"anonymous"]) + if (![[SOGoSystemDefaults sharedSystemDefaults] isURLEncryptionEnabled] || [username isEqualToString: @"anonymous"] || [[request requestHandlerKey] isEqualToString:@"dav"]) return username; cache = [SOGoCache sharedCache]; @@ -1331,13 +1331,13 @@ static const NSString *kEncryptedUserNamePrefix = @"uenc"; } } -+ (NSString *) getDecryptedUsernameIfNeeded:(NSString *)username ++ (NSString *) getDecryptedUsernameIfNeeded:(NSString *)username request: (WORequest *)request { NSException *exception; NSString *tmp, *cacheKey; SOGoCache *cache; - if (![[SOGoSystemDefaults sharedSystemDefaults] isURLEncryptionEnabled] || [username isEqualToString: @"anonymous"]) + if (![[SOGoSystemDefaults sharedSystemDefaults] isURLEncryptionEnabled] || [username isEqualToString: @"anonymous"] || [[request requestHandlerKey] isEqualToString:@"dav"]) return username; cache = [SOGoCache sharedCache]; diff --git a/SoObjects/SOGo/SOGoUserFolder.m b/SoObjects/SOGo/SOGoUserFolder.m index 57f3b46b3..f953d1a9c 100644 --- a/SoObjects/SOGo/SOGoUserFolder.m +++ b/SoObjects/SOGo/SOGoUserFolder.m @@ -87,7 +87,7 @@ } - (NSString *) nameInContainer { - return [SOGoUser getEncryptedUsernameIfNeeded: [super nameInContainer]]; + return [SOGoUser getEncryptedUsernameIfNeeded: [super nameInContainer] request: [context request]]; } /* ownership */ diff --git a/UI/MainUI/SOGoRootPage.m b/UI/MainUI/SOGoRootPage.m index 6782e01ec..afa686586 100644 --- a/UI/MainUI/SOGoRootPage.m +++ b/UI/MainUI/SOGoRootPage.m @@ -344,7 +344,7 @@ static const NSString *kJwtKey = @"jwt"; forKey: @"expire"]; [json setObject: [NSNumber numberWithInt: grace] forKey: @"grace"]; - [json setObject: [SOGoUser getEncryptedUsernameIfNeeded: username] + [json setObject: [SOGoUser getEncryptedUsernameIfNeeded: username request: request] forKey: @"username"]; response = [self responseWithStatus: 200 @@ -575,7 +575,7 @@ static const NSString *kJwtKey = @"jwt"; response = [self redirectToLocation: [NSString stringWithFormat: @"%@%@", oldLocation, - [[SOGoUser getEncryptedUsernameIfNeeded:login] stringByEscapingURL]]]; + [[SOGoUser getEncryptedUsernameIfNeeded:login request: [context request]] stringByEscapingURL]]]; } else { @@ -791,7 +791,7 @@ static const NSString *kJwtKey = @"jwt"; } response = [self responseWithStatus: 200 andJSONRepresentation: - [NSDictionary dictionaryWithObjectsAndKeys: [SOGoUser getEncryptedUsernameIfNeeded:username], @"username", nil]]; + [NSDictionary dictionaryWithObjectsAndKeys: [SOGoUser getEncryptedUsernameIfNeeded:username request: request], @"username", nil]]; if (!passwordRecovery) { authCookie = [auth cookieWithUsername: username