Merge branch 'fix/cas-service-names'

pull/12/head
Jean Raby 2013-06-18 16:44:05 -04:00
commit f24e65b6d8
5 changed files with 39 additions and 23 deletions

View File

@ -51,7 +51,7 @@
} }
- (BOOL) checkLogin: (NSString *) _login - (BOOL) checkLogin: (NSString *) _login
password: (NSString *) _pwd password: (NSString *) _pwd
{ {
NSString *domain; NSString *domain;
SOGoSystemDefaults *sd; SOGoSystemDefaults *sd;
@ -66,7 +66,7 @@
checkLogin: [_login stringByReplacingString: @"%40" checkLogin: [_login stringByReplacingString: @"%40"
withString: @"@"] withString: @"@"]
password: _pwd password: _pwd
domain: &domain domain: &domain
perr: &perr perr: &perr
expire: &expire expire: &expire
grace: &grace] grace: &grace]
@ -99,7 +99,7 @@
{ {
creds = [self parseCredentials: auth]; creds = [self parseCredentials: auth];
if ([creds count] > 1) if ([creds count] > 1)
password = [creds objectAtIndex: 1]; password = [creds objectAtIndex: 1];
} }
return password; return password;
@ -122,17 +122,19 @@
session = [SOGoCASSession CASSessionWithTicket: password session = [SOGoCASSession CASSessionWithTicket: password
fromProxy: YES]; fromProxy: YES];
// We must NOT assume the scheme exists // We must NOT assume the scheme exists
scheme = [server scheme]; scheme = [server scheme];
if (!scheme) if (!scheme)
scheme = @"imap"; scheme = @"imap";
service = [NSString stringWithFormat: @"%@://%@", scheme, [server host]]; service = [NSString stringWithFormat: @"%@://%@", scheme, [server host]];
if (renew) if (renew)
[session invalidateTicketForService: service]; [session invalidateTicketForService: service];
password = [session ticketForService: service]; password = [session ticketForService: service];
if ([password length] || renew) if ([password length] || renew)
[session updateCache]; [session updateCache];
} }

View File

@ -43,6 +43,7 @@
- (NSString *) mailDomain; - (NSString *) mailDomain;
- (NSString *) imapServer; - (NSString *) imapServer;
- (NSString *) sieveServer; - (NSString *) sieveServer;
- (NSString *) imapCASServiceName;
- (NSString *) imapAclStyle; - (NSString *) imapAclStyle;
- (NSString *) imapAclGroupIdPrefix; - (NSString *) imapAclGroupIdPrefix;
- (NSString *) imapFolderSeparator; - (NSString *) imapFolderSeparator;

View File

@ -123,6 +123,11 @@
return [self stringForKey: @"SOGoSieveServer"]; return [self stringForKey: @"SOGoSieveServer"];
} }
- (NSString *) imapCASServiceName
{
return [self objectForKey: @"SOGoIMAPCASServiceName"];
}
#warning should be removed when we make use of imap namespace #warning should be removed when we make use of imap namespace
- (NSString *) imapAclStyle - (NSString *) imapAclStyle
{ {

View File

@ -49,7 +49,7 @@
} }
- (BOOL) checkLogin: (NSString *) _login - (BOOL) checkLogin: (NSString *) _login
password: (NSString *) _pwd password: (NSString *) _pwd
{ {
return YES; return YES;
} }

View File

@ -74,7 +74,7 @@
} }
- (BOOL) checkLogin: (NSString *) _login - (BOOL) checkLogin: (NSString *) _login
password: (NSString *) _pwd password: (NSString *) _pwd
{ {
NSString *username, *password, *domain, *value; NSString *username, *password, *domain, *value;
SOGoPasswordPolicyError perr; SOGoPasswordPolicyError perr;
@ -168,7 +168,7 @@
perr: _perr perr: _perr
expire: _expire expire: _expire
grace: _grace grace: _grace
useCache: _useCache]; useCache: _useCache];
//[self logWithFormat: @"Checked login with ppolicy enabled: %d %d %d", *_perr, *_expire, *_grace]; //[self logWithFormat: @"Checked login with ppolicy enabled: %d %d %d", *_perr, *_expire, *_grace];
@ -269,12 +269,13 @@
forceRenew: (BOOL) renew forceRenew: (BOOL) renew
{ {
NSString *authType, *password; NSString *authType, *password;
SOGoSystemDefaults *sd;
password = [self passwordInContext: context]; password = [self passwordInContext: context];
if ([password length]) if ([password length])
{ {
authType = [[SOGoSystemDefaults sharedSystemDefaults] sd = [SOGoSystemDefaults sharedSystemDefaults];
authenticationType]; authType = [sd authenticationType];
if ([authType isEqualToString: @"cas"]) if ([authType isEqualToString: @"cas"])
{ {
SOGoCASSession *session; SOGoCASSession *session;
@ -283,17 +284,24 @@
session = [SOGoCASSession CASSessionWithIdentifier: password session = [SOGoCASSession CASSessionWithIdentifier: password
fromProxy: NO]; fromProxy: NO];
// We must NOT assume the scheme exists service = [sd imapCASServiceName]; // try configured service first
scheme = [server scheme]; if (!service)
{
// We must NOT assume the scheme exists
scheme = [server scheme];
if (!scheme) if (!scheme)
scheme = @"imap"; scheme = @"imap";
service = [NSString stringWithFormat: @"%@://%@", scheme, [server host]]; service = [NSString stringWithFormat: @"%@://%@",
scheme, [server host]];
}
if (renew) if (renew)
[session invalidateTicketForService: service]; [session invalidateTicketForService: service];
password = [session ticketForService: service]; password = [session ticketForService: service];
if ([password length] || renew) if ([password length] || renew)
[session updateCache]; [session updateCache];
} }
@ -322,8 +330,8 @@
/* create SOGoUser */ /* create SOGoUser */
- (SOGoUser *) userWithLogin: (NSString *) login - (SOGoUser *) userWithLogin: (NSString *) login
andRoles: (NSArray *) roles andRoles: (NSArray *) roles
inContext: (WOContext *) ctx inContext: (WOContext *) ctx
{ {
/* the actual factory method */ /* the actual factory method */
return [SOGoUser userWithLogin: login roles: roles]; return [SOGoUser userWithLogin: login roles: roles];
@ -339,7 +347,7 @@
NSString *auth; NSString *auth;
auth = [[context request] auth = [[context request]
cookieValueForKey: [self cookieNameInContext:context]]; cookieValueForKey: [self cookieNameInContext:context]];
if ([auth isEqualToString: @"discard"]) if ([auth isEqualToString: @"discard"])
{ {
[context setObject: [NSArray arrayWithObject: SoRole_Anonymous] [context setObject: [NSArray arrayWithObject: SoRole_Anonymous]
@ -353,8 +361,8 @@
} }
- (void) setupAuthFailResponse: (WOResponse *) response - (void) setupAuthFailResponse: (WOResponse *) response
withReason: (NSString *) reason withReason: (NSString *) reason
inContext: (WOContext *) context inContext: (WOContext *) context
{ {
WOComponent *page; WOComponent *page;
WORequest *request; WORequest *request;