mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-08-21 06:33:18 +00:00
Monotone-Parent: 775b7e4fea80568033b5c8bf9b7c5220c7d36041
Monotone-Revision: ff12d30f9bf1800bb0b1bcbefba9493cdeeeccaf Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2010-01-28T21:42:03 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -36,9 +36,11 @@
|
||||
|
||||
#import <MainUI/SOGoRootPage.h>
|
||||
|
||||
#import "SOGoUserManager.h"
|
||||
#import "SOGoCASSession.h"
|
||||
#import "SOGoPermissions.h"
|
||||
#import "SOGoSystemDefaults.h"
|
||||
#import "SOGoUser.h"
|
||||
#import "SOGoUserManager.h"
|
||||
|
||||
#import "SOGoWebAuthenticator.h"
|
||||
|
||||
@@ -57,8 +59,24 @@
|
||||
- (BOOL) checkLogin: (NSString *) _login
|
||||
password: (NSString *) _pwd
|
||||
{
|
||||
return [[SOGoUserManager sharedUserManager] checkLogin: _login
|
||||
SOGoSystemDefaults *sd;
|
||||
BOOL rc;
|
||||
SOGoCASSession *session;
|
||||
|
||||
sd = [SOGoSystemDefaults sharedSystemDefaults];
|
||||
if ([[sd authenticationType] isEqualToString: @"cas"])
|
||||
{
|
||||
session = [SOGoCASSession CASSessionWithIdentifier: _pwd];
|
||||
if (session)
|
||||
rc = [[session login] isEqualToString: _login];
|
||||
else
|
||||
rc = NO;
|
||||
}
|
||||
else
|
||||
rc = [[SOGoUserManager sharedUserManager] checkLogin: _login
|
||||
andPassword: _pwd];
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
- (SOGoUser *) userInContext: (WOContext *)_ctx
|
||||
@@ -83,7 +101,7 @@
|
||||
{
|
||||
NSArray *creds;
|
||||
NSString *auth, *password;
|
||||
|
||||
|
||||
auth = [[context request]
|
||||
cookieValueForKey: [self cookieNameInContext: context]];
|
||||
creds = [self parseCredentials: auth];
|
||||
@@ -95,6 +113,33 @@
|
||||
return password;
|
||||
}
|
||||
|
||||
- (NSString *) imapPasswordInContext: (WOContext *) context
|
||||
forServer: (NSString *) imapServer
|
||||
forceRenew: (BOOL) renew
|
||||
{
|
||||
SOGoSystemDefaults *sd;
|
||||
SOGoCASSession *session;
|
||||
NSString *password, *service;
|
||||
|
||||
password = [self passwordInContext: context];
|
||||
if ([password length])
|
||||
{
|
||||
sd = [SOGoSystemDefaults sharedSystemDefaults];
|
||||
if ([[sd authenticationType] isEqualToString: @"cas"])
|
||||
{
|
||||
session = [SOGoCASSession CASSessionWithIdentifier: password];
|
||||
service = [NSString stringWithFormat: @"imap://%@", imapServer];
|
||||
if (renew)
|
||||
[session invalidateTicketForService: service];
|
||||
password = [session ticketForService: service];
|
||||
if ([password length] || renew)
|
||||
[session updateCache];
|
||||
}
|
||||
}
|
||||
|
||||
return password;
|
||||
}
|
||||
|
||||
/* create SOGoUser */
|
||||
|
||||
- (SOGoUser *) userWithLogin: (NSString *) login
|
||||
@@ -113,7 +158,7 @@
|
||||
*/
|
||||
WOResponse *response;
|
||||
NSString *auth;
|
||||
|
||||
|
||||
auth = [[context request]
|
||||
cookieValueForKey: [self cookieNameInContext:context]];
|
||||
if ([auth isEqualToString: @"discard"])
|
||||
@@ -133,16 +178,20 @@
|
||||
inContext: (WOContext *) context
|
||||
{
|
||||
WOComponent *page;
|
||||
WORequest *request;
|
||||
WOCookie *authCookie;
|
||||
NSCalendarDate *date;
|
||||
NSString *appName;
|
||||
|
||||
request = [context request];
|
||||
page = [[WOApplication application] pageWithName: @"SOGoRootPage"
|
||||
forRequest: [context request]];
|
||||
[[SoDefaultRenderer sharedRenderer] renderObject: page
|
||||
forRequest: request];
|
||||
[[SoDefaultRenderer sharedRenderer] renderObject: [page defaultAction]
|
||||
inContext: context];
|
||||
authCookie = [WOCookie cookieWithName: [self cookieNameInContext: context]
|
||||
value: @"discard"];
|
||||
[authCookie setPath: @"/"];
|
||||
appName = [request applicationName];
|
||||
[authCookie setPath: [NSString stringWithFormat: @"/%@/", appName]];
|
||||
date = [NSCalendarDate calendarDate];
|
||||
[authCookie setExpires: [date yesterday]];
|
||||
[response addCookie: authCookie];
|
||||
|
||||
Reference in New Issue
Block a user