2006-06-15 21:34:10 +02:00
|
|
|
/*
|
|
|
|
Copyright (C) 2004-2005 SKYRIX Software AG
|
|
|
|
|
|
|
|
This file is part of OpenGroupware.org.
|
|
|
|
|
|
|
|
OGo is free software; you can redistribute it and/or modify it under
|
|
|
|
the terms of the GNU Lesser General Public License as published by the
|
|
|
|
Free Software Foundation; either version 2, or (at your option) any
|
|
|
|
later version.
|
|
|
|
|
|
|
|
OGo is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
|
|
|
License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with OGo; see the file COPYING. If not, write to the
|
|
|
|
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2007-12-13 20:26:47 +01:00
|
|
|
#import <Foundation/NSException.h>
|
2008-05-22 17:56:18 +02:00
|
|
|
#import <Foundation/NSUserDefaults.h>
|
2007-12-13 20:26:47 +01:00
|
|
|
|
2007-08-06 16:06:27 +02:00
|
|
|
#import <NGObjWeb/WOApplication.h>
|
|
|
|
#import <NGObjWeb/WOContext.h>
|
2007-09-04 17:00:44 +02:00
|
|
|
#import <NGObjWeb/WOCookie.h>
|
2007-08-06 16:06:27 +02:00
|
|
|
#import <NGObjWeb/WORequest.h>
|
|
|
|
#import <NGObjWeb/WOResponse.h>
|
2007-12-05 22:05:04 +01:00
|
|
|
|
2007-09-07 00:21:16 +02:00
|
|
|
#import <NGExtensions/NGBase64Coding.h>
|
2007-08-06 16:06:27 +02:00
|
|
|
#import <NGExtensions/NSNull+misc.h>
|
|
|
|
#import <NGExtensions/NSString+misc.h>
|
2007-09-04 17:00:44 +02:00
|
|
|
#import <NGExtensions/NSObject+Logs.h>
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2007-09-04 17:41:59 +02:00
|
|
|
#import <SoObjects/SOGo/SOGoWebAuthenticator.h>
|
2007-09-04 17:00:44 +02:00
|
|
|
#import <SoObjects/SOGo/SOGoUser.h>
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2007-09-04 17:00:44 +02:00
|
|
|
#import "SOGoRootPage.h"
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2007-12-13 20:26:47 +01:00
|
|
|
@interface SOGoRootPage (crashAdditions)
|
|
|
|
|
|
|
|
- (void) segfault;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
@implementation SOGoRootPage
|
|
|
|
|
2007-09-04 17:00:44 +02:00
|
|
|
- (void) dealloc
|
|
|
|
{
|
|
|
|
[userName release];
|
2006-06-15 21:34:10 +02:00
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* accessors */
|
|
|
|
|
2007-09-04 17:00:44 +02:00
|
|
|
- (void) setUserName: (NSString *) _value
|
|
|
|
{
|
|
|
|
ASSIGNCOPY (userName, _value);
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
2007-09-04 17:00:44 +02:00
|
|
|
|
|
|
|
- (NSString *) userName
|
|
|
|
{
|
|
|
|
return userName;
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2007-09-07 00:21:16 +02:00
|
|
|
- (NSString *) connectURL
|
|
|
|
{
|
|
|
|
return [NSString stringWithFormat: @"%@connect", [self applicationPath]];
|
|
|
|
}
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2007-09-07 00:21:16 +02:00
|
|
|
/* actions */
|
|
|
|
- (id <WOActionResults>) connectAction
|
2007-09-04 17:00:44 +02:00
|
|
|
{
|
2007-09-07 00:21:16 +02:00
|
|
|
WOResponse *response;
|
2007-11-21 17:42:58 +01:00
|
|
|
WORequest *request;
|
2007-09-07 00:21:16 +02:00
|
|
|
WOCookie *authCookie;
|
2007-09-04 17:41:59 +02:00
|
|
|
SOGoWebAuthenticator *auth;
|
2007-09-07 00:21:16 +02:00
|
|
|
NSString *cookieValue, *cookieString;
|
|
|
|
|
|
|
|
auth = [[WOApplication application]
|
|
|
|
authenticatorInContext: context];
|
2007-11-21 17:42:58 +01:00
|
|
|
request = [context request];
|
2007-09-11 21:36:40 +02:00
|
|
|
response = [self responseWith204];
|
2007-09-07 00:21:16 +02:00
|
|
|
cookieString = [NSString stringWithFormat: @"%@:%@",
|
2007-11-21 17:42:58 +01:00
|
|
|
[request formValueForKey: @"userName"],
|
|
|
|
[request formValueForKey: @"password"]];
|
2007-09-15 00:01:02 +02:00
|
|
|
cookieValue = [NSString stringWithFormat: @"basic %@",
|
2007-09-07 00:21:16 +02:00
|
|
|
[cookieString stringByEncodingBase64]];
|
|
|
|
authCookie = [WOCookie cookieWithName: [auth cookieNameInContext: context]
|
|
|
|
value: cookieValue];
|
|
|
|
[authCookie setPath: @"/"];
|
|
|
|
[response addCookie: authCookie];
|
|
|
|
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
|
2007-09-12 15:01:17 +02:00
|
|
|
- (id <WOActionResults>) defaultAction
|
|
|
|
{
|
|
|
|
id <WOActionResults> response;
|
|
|
|
NSString *login, *oldLocation;
|
|
|
|
|
|
|
|
login = [[context activeUser] login];
|
2007-10-19 00:48:44 +02:00
|
|
|
if (!login || [login isEqualToString: @"anonymous"])
|
2007-09-12 15:01:17 +02:00
|
|
|
response = self;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
oldLocation = [[self clientObject] baseURLInContext: context];
|
|
|
|
response
|
|
|
|
= [self redirectToLocation: [NSString stringWithFormat: @"%@/%@",
|
|
|
|
oldLocation, login]];
|
|
|
|
}
|
|
|
|
|
|
|
|
return response;
|
|
|
|
}
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2007-09-05 19:56:39 +02:00
|
|
|
- (BOOL) isPublicInContext: (WOContext *) localContext
|
|
|
|
{
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
2007-12-13 20:26:47 +01:00
|
|
|
- (id <WOActionResults>) crashAction
|
|
|
|
{
|
|
|
|
[self segfault];
|
|
|
|
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id <WOActionResults>) exceptionAction
|
|
|
|
{
|
|
|
|
return (id <WOActionResults>)
|
|
|
|
[NSException exceptionWithName: @"ExceptionAction"
|
|
|
|
reason: @"This exception is brought to you by SOGo"
|
|
|
|
userInfo: nil];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id <WOActionResults>) raisedExceptionAction
|
|
|
|
{
|
|
|
|
[NSException raise: @"ExceptionAction"
|
|
|
|
format: @"This exception is brought to you by SOGo"];
|
|
|
|
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
2008-05-22 17:56:18 +02:00
|
|
|
- (NSString *) loginSuffix
|
|
|
|
{
|
|
|
|
NSUserDefaults *ud;
|
|
|
|
|
|
|
|
ud = [NSUserDefaults standardUserDefaults];
|
|
|
|
|
|
|
|
return [ud stringForKey: @"SOGoLoginSuffix"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) hasLoginSuffix
|
|
|
|
{
|
|
|
|
return ([[self loginSuffix] length]);
|
|
|
|
}
|
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
@end /* SOGoRootPage */
|