2 Copyright (C) 2004-2005 SKYRIX Software AG
4 This file is part of OpenGroupware.org.
6 OGo is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with OGo; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 #import <NGObjWeb/WOApplication.h>
23 #import <NGObjWeb/WOContext.h>
24 #import <NGObjWeb/WOCookie.h>
25 #import <NGObjWeb/WORequest.h>
26 #import <NGObjWeb/WOResponse.h>
27 #import <NGExtensions/NGBase64Coding.h>
28 #import <NGExtensions/NSNull+misc.h>
29 #import <NGExtensions/NSString+misc.h>
30 #import <NGExtensions/NSObject+Logs.h>
32 #import <SoObjects/SOGo/SOGoWebAuthenticator.h>
33 #import <SoObjects/SOGo/SOGoUser.h>
35 #import "SOGoRootPage.h"
37 @implementation SOGoRootPage
47 - (void) setUserName: (NSString *) _value
49 ASSIGNCOPY (userName, _value);
52 - (NSString *) userName
57 - (NSString *) connectURL
59 return [NSString stringWithFormat: @"%@connect", [self applicationPath]];
63 - (id <WOActionResults>) connectAction
67 SOGoWebAuthenticator *auth;
68 NSString *cookieValue, *cookieString;
70 auth = [[WOApplication application]
71 authenticatorInContext: context];
72 response = [context response];
73 cookieString = [NSString stringWithFormat: @"%@:%@",
74 [self queryParameterForKey: @"userName"],
75 [self queryParameterForKey: @"password"]];
76 cookieValue = [NSString stringWithFormat: @"basic%@",
77 [cookieString stringByEncodingBase64]];
78 authCookie = [WOCookie cookieWithName: [auth cookieNameInContext: context]
80 [authCookie setPath: @"/"];
81 [response setStatus: 204];
82 [response addCookie: authCookie];
87 // - (id <WOActionResults>) defaultAction
90 // NSString *login, *rhk;
91 // SOGoWebAuthenticator *auth;
93 // SOGoUserFolder *home;
94 // WOApplication *base;
97 // Note: ctx.activeUser is NOT set here. Don't know why, so we retrieve
98 // the user from the authenticator.
101 // auth = [[self clientObject] authenticatorInContext: context];
102 // user = [auth userInContext: context];
103 // login = [user login];
105 // if ([login isEqualToString:@"anonymous"]) {
106 // /* use root page for unauthenticated users */
112 // base = [self application];
113 // rhk = [[context request] requestHandlerKey];
114 // if (([rhk length] == 0) || ([base requestHandlerForKey:rhk] == nil)) {
115 // base = [base lookupName: @"so" inContext: context acquire: NO];
117 // if (![base isNotNull] || [base isKindOfClass:[NSException class]]) {
118 // /* use root page if home could not be found */
119 // [self errorWithFormat:@"Did not find 'so' request handler!"];
124 // /* lookup home-page */
126 // home = [base lookupName: login inContext: context acquire: NO];
127 // if (![home isNotNull] || [home isKindOfClass:[NSException class]]) {
128 // /* use root page if home could not be found */
132 // /* redirect to home-page */
134 // r = [context response];
135 // [r setStatus: 302 /* moved */];
136 // [r setHeader: [home baseURLInContext: context]
137 // forKey: @"location"];
142 /* response generation */
144 // - (void) appendToResponse: (WOResponse *) response
145 // inContext: (WOContext *) ctx
149 // // TODO: we might also want to look into the HTTP basic-auth to redirect to
152 // rhk = [[ctx request] requestHandlerKey];
153 // if ([rhk length] == 0
154 // || [[self application] requestHandlerForKey: rhk] == nil)
156 // /* a small hack to redirect to a valid URL */
159 // url = [ctx urlWithRequestHandlerKey: @"so" path: @"/" queryString: nil];
160 // [response setStatus: 302 /* moved */];
161 // [response setHeader: url forKey: @"location"];
162 // [self logWithFormat: @"URL: %@", url];
166 // [response setHeader: @"text/html" forKey: @"content-type"];
167 // [super appendToResponse: response inContext: ctx];
170 - (BOOL) isPublicInContext: (WOContext *) localContext
175 @end /* SOGoRootPage */