diff --git a/ChangeLog b/ChangeLog index 988949c41..b058a15b6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2010-06-10 Wolfgang Sourdeau + * UI/MainUI/SOGoUserHomePage.m (-logoffAction): split method in + smaller submethods for the sake of clarity. Also, we provide as + "CAS" mode where the redirection is made to the CAS logout page. + * SoObjects/SOGo/SOGoCASSession.m (+CASSessionWithTicket:fromProxy:): added a new "fromProxy" parameter. (+CASSessionWithIdentifier:fromProxy:): idem. diff --git a/UI/MainUI/SOGoUserHomePage.m b/UI/MainUI/SOGoUserHomePage.m index d8b3c9ba4..da1808fe7 100644 --- a/UI/MainUI/SOGoUserHomePage.m +++ b/UI/MainUI/SOGoUserHomePage.m @@ -35,11 +35,13 @@ #import #import +#import #import #import #import #import #import +#import #import #import #import @@ -228,41 +230,67 @@ return response; } +- (NSString *) _logoutRedirectURL +{ + NSString *redirectURL; + SOGoSystemDefaults *sd; + id container; + + sd = [SOGoSystemDefaults sharedSystemDefaults]; + if ([[sd authenticationType] isEqualToString: @"cas"]) + redirectURL = [SOGoCASSession CASURLWithAction: @"logout" + andParameters: nil]; + else + { + container = [[self clientObject] container]; + redirectURL = [container baseURLInContext: context]; + } + + return redirectURL; +} + +- (WOCookie *) _logoutCookieWithDate: (NSCalendarDate *) date +{ + SOGoWebAuthenticator *auth; + NSString *cookieName, *appName; + WOCookie *cookie; + + cookie = nil; + + auth = [[self clientObject] authenticatorInContext: context]; + if ([auth respondsToSelector: @selector (cookieNameInContext:)]) + { + cookieName = [auth cookieNameInContext: context]; + if ([cookieName length]) + { + cookie = [WOCookie cookieWithName: cookieName value: @"discard"]; + appName = [[context request] applicationName]; + [cookie setPath: [NSString stringWithFormat: @"/%@/", appName]]; + [cookie setExpires: [date yesterday]]; + } + } + + return cookie; +} + - (id ) logoffAction { WOResponse *response; WOCookie *cookie; - SOGoWebAuthenticator *auth; - id container; NSCalendarDate *date; - NSString *userName, *cookieName, *appName; - - container = [[self clientObject] container]; + NSString *userName; userName = [[context activeUser] login]; [self logWithFormat: @"user '%@' logged off", userName]; - response = [context response]; - [response setStatus: 302]; - [response setHeader: [container baseURLInContext: context] - forKey: @"location"]; + response = [self redirectToLocation: [self _logoutRedirectURL]]; date = [NSCalendarDate calendarDate]; [date setTimeZone: [NSTimeZone timeZoneWithAbbreviation: @"GMT"]]; - auth = [[self clientObject] authenticatorInContext: context]; - if ([auth respondsToSelector: @selector (cookieNameInContext:)]) - cookieName = [auth cookieNameInContext: context]; - else - cookieName = nil; - if ([cookieName length]) - { - cookie = [WOCookie cookieWithName: cookieName value: @"discard"]; - appName = [[context request] applicationName]; - [cookie setPath: [NSString stringWithFormat: @"/%@/", appName]]; - [cookie setExpires: [date yesterday]]; - [response addCookie: cookie]; - } + cookie = [self _logoutCookieWithDate: date]; + if (cookie) + [response addCookie: cookie]; [response setHeader: [date rfc822DateString] forKey: @"Last-Modified"]; [response setHeader: @"no-store, no-cache, must-revalidate,"