diff --git a/ChangeLog b/ChangeLog index bb013f7ff..017826ab3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2010-04-12 Wolfgang Sourdeau + * SoObjects/SOGo/SOGoProxyAuthenticator.m (-passwordInContext:): + use the "authorization" header to determine the password of the + user, if any. + * SoObjects/Appointments/SOGoAptMailReceipt.m (-getSubject) (-getBody): taken methods from old version of SOGoAptMailNotification, to avoid a crash regarding a lock of diff --git a/SoObjects/SOGo/SOGoProxyAuthenticator.m b/SoObjects/SOGo/SOGoProxyAuthenticator.m index a3c50c3bb..4036d416d 100644 --- a/SoObjects/SOGo/SOGoProxyAuthenticator.m +++ b/SoObjects/SOGo/SOGoProxyAuthenticator.m @@ -28,6 +28,7 @@ #import #import +#import #import #import "SOGoPermissions.h" @@ -100,14 +101,46 @@ - (NSString *) passwordInContext: (WOContext *) context { - return @""; + NSString *password, *authType, *authorization, *pair, *pairStart; + WORequest *rq; + + password = @""; + + rq = [context request]; + authType = [rq headerForKey: @"x-webobjects-auth-type"]; + if ([authType isEqualToString: @"Basic"]) + { + authorization = [rq headerForKey: @"authorization"]; + if ([authorization hasPrefix: @"Basic "]) + { + pair = [[authorization substringFromIndex: 6] + stringByDecodingBase64]; + pairStart = [NSString stringWithFormat: @"%@:", + [self checkCredentialsInContext: context]]; + if ([pair hasPrefix: pairStart]) + password = [pair substringFromIndex: [pairStart length]]; + else + [self errorWithFormat: @"the username in the 'authorization'" + @" header does not have the expected value"]; + } + else + [self errorWithFormat: + @"'authorization' header does not have the expected value"]; + } + else if (authType) + [self errorWithFormat: @"unrecognized authentication type: '%@'", + authType]; + else + [self warnWithFormat: @"no authentication type found, skipped"]; + + return password; } - (NSString *) imapPasswordInContext: (WOContext *) context forServer: (NSString *) imapServer forceRenew: (BOOL) renew { - return (renew ? nil : @""); + return (renew ? nil : [self passwordInContext: context]); } - (WOResponse *) preprocessCredentialsInContext: (WOContext *) context