From cc7cb9f2bbdb8710c4731c8129467d5f5de5f4b3 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Thu, 10 Jun 2010 21:29:55 +0000 Subject: [PATCH] Monotone-Parent: 47be4cd66ca07d4558d608a37376c91af1d0b863 Monotone-Revision: 85e21021232d18a3c2b1b1d16cf6d52237236f29 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2010-06-10T21:29:55 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 6 ++++++ SoObjects/SOGo/SOGoCASSession.h | 8 +++++--- SoObjects/SOGo/SOGoCASSession.m | 24 +++++++++++++++++++----- SoObjects/SOGo/SOGoWebAuthenticator.m | 5 +++-- UI/MainUI/SOGoRootPage.m | 3 ++- 5 files changed, 35 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index ed55cf21c..988949c41 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2010-06-10 Wolfgang Sourdeau + * SoObjects/SOGo/SOGoCASSession.m + (+CASSessionWithTicket:fromProxy:): added a new "fromProxy" parameter. + (+CASSessionWithIdentifier:fromProxy:): idem. + (-fetchData): if the session is used by a proxy client, we invoke + "proxyValidate" rather than "serviceValidate". + * SoObjects/SOGo/SOGoDAVAuthenticator.m (-userInContext:): reorganized method. diff --git a/SoObjects/SOGo/SOGoCASSession.h b/SoObjects/SOGo/SOGoCASSession.h index 0b77cb6a9..ee958b5a4 100644 --- a/SoObjects/SOGo/SOGoCASSession.h +++ b/SoObjects/SOGo/SOGoCASSession.h @@ -34,6 +34,7 @@ @interface SOGoCASSession : NSObject { NSString *ticket; + BOOL ticketFromProxy; NSString *login; NSString *pgt; NSString *identifier; @@ -45,12 +46,13 @@ + (NSString *) CASURLWithAction: (NSString *) casAction andParameters: (NSDictionary *) parameters; -+ (SOGoCASSession *) CASSessionWithTicket: (NSString *) newTicket; -+ (SOGoCASSession *) CASSessionWithIdentifier: (NSString *) newIdentifier; ++ (SOGoCASSession *) CASSessionWithTicket: (NSString *) newTicket + fromProxy: (BOOL) fromProxy; ++ (SOGoCASSession *) CASSessionWithIdentifier: (NSString *) newIdentifier + fromProxy: (BOOL) fromProxy; - (NSString *) identifier; -- (void) setTicket: (NSString *) newTicket; - (NSString *) ticket; - (NSString *) login; diff --git a/SoObjects/SOGo/SOGoCASSession.m b/SoObjects/SOGo/SOGoCASSession.m index acb94a041..9cf96e79e 100644 --- a/SoObjects/SOGo/SOGoCASSession.m +++ b/SoObjects/SOGo/SOGoCASSession.m @@ -43,6 +43,13 @@ #import "SOGoCASSession.h" +@interface SOGoCASSession (SOGoPrivate) + +- (void) setTicket: (NSString *) newTicket + fromProxy: (BOOL) fromProxy; + +@end + @implementation SOGoCASSession + (NSString *) CASURLWithAction: (NSString *) casAction @@ -68,6 +75,7 @@ } + (SOGoCASSession *) CASSessionWithTicket: (NSString *) newTicket + fromProxy: (BOOL) fromProxy { SOGoCASSession *newSession; @@ -75,7 +83,8 @@ { newSession = [self new]; [newSession autorelease]; - [newSession setTicket: newTicket]; + [newSession setTicket: newTicket + fromProxy: fromProxy]; } else newSession = nil; @@ -84,6 +93,7 @@ } + (SOGoCASSession *) CASSessionWithIdentifier: (NSString *) newIdentifier + fromProxy: (BOOL) fromProxy { SOGoCASSession *session; SOGoCache *cache; @@ -91,7 +101,7 @@ cache = [SOGoCache sharedCache]; casTicket = [cache CASTicketFromIdentifier: newIdentifier]; - session = [self CASSessionWithTicket: casTicket]; + session = [self CASSessionWithTicket: casTicket fromProxy: fromProxy]; return session; } @@ -101,6 +111,7 @@ if ((self = [super init])) { ticket = nil; + ticketFromProxy = NO; login = nil; pgt = nil; identifier = nil; @@ -163,8 +174,10 @@ } - (void) setTicket: (NSString *) newTicket + fromProxy: (BOOL) fromProxy { ASSIGN (ticket, newTicket); + ticketFromProxy = fromProxy; [self _loadSessionFromCache]; } @@ -355,8 +368,7 @@ application = [WOApplication application]; request = [[application context] request]; - pgtURL = [NSString stringWithFormat: - @"https://%@/%@/casProxy", + pgtURL = [NSString stringWithFormat: @"https://%@/%@/casProxy", [soURL host], [request applicationName]]; return pgtURL; @@ -375,7 +387,9 @@ ticket, @"ticket", serviceURL, @"service", [self _pgtUrlFromURL: soURL], @"pgtUrl", nil]; - [self _performCASRequestWithAction: @"serviceValidate" + [self _performCASRequestWithAction: (ticketFromProxy + ? @"proxyValidate" + : @"serviceValidate") andParameters: params]; identifier = [SOGoObject globallyUniqueObjectId]; [identifier retain]; diff --git a/SoObjects/SOGo/SOGoWebAuthenticator.m b/SoObjects/SOGo/SOGoWebAuthenticator.m index 70d9a71f0..adcd280a1 100644 --- a/SoObjects/SOGo/SOGoWebAuthenticator.m +++ b/SoObjects/SOGo/SOGoWebAuthenticator.m @@ -84,7 +84,7 @@ if ([[sd authenticationType] isEqualToString: @"cas"]) { - session = [SOGoCASSession CASSessionWithIdentifier: _pwd]; + session = [SOGoCASSession CASSessionWithIdentifier: _pwd fromProxy: NO]; if (session) rc = [[session login] isEqualToString: _login]; else @@ -152,7 +152,8 @@ sd = [SOGoSystemDefaults sharedSystemDefaults]; if ([[sd authenticationType] isEqualToString: @"cas"]) { - session = [SOGoCASSession CASSessionWithIdentifier: password]; + session = [SOGoCASSession CASSessionWithIdentifier: password + fromProxy: NO]; service = [NSString stringWithFormat: @"imap://%@", imapServer]; if (renew) [session invalidateTicketForService: service]; diff --git a/UI/MainUI/SOGoRootPage.m b/UI/MainUI/SOGoRootPage.m index 9d1255b5b..842da7402 100644 --- a/UI/MainUI/SOGoRootPage.m +++ b/UI/MainUI/SOGoRootPage.m @@ -248,7 +248,8 @@ ticket = [rq formValueForKey: @"ticket"]; if ([ticket length]) { - casSession = [SOGoCASSession CASSessionWithTicket: ticket]; + casSession = [SOGoCASSession CASSessionWithTicket: ticket + fromProxy: NO]; login = [casSession login]; if ([login length]) {