Monotone-Parent: 7f9eeda74d55829371d1c66f2c2545473af168ff

Monotone-Revision: e36214d6c44a28c81a60a0867712c70d3e3a1651

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2007-09-04T15:00:44
Monotone-Branch: ca.inverse.sogo
maint-2.0.2
Wolfgang Sourdeau 2007-09-04 15:00:44 +00:00
parent d78f807510
commit 310b567c67
5 changed files with 212 additions and 91 deletions

View File

@ -0,0 +1,35 @@
/* SOGoRootPage.h - this file is part of SOGo
*
* Copyright (C) 2007 Inverse groupe conseil
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This file 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef SOGOROOTPAGE_H
#define SOGOROOTPAGE_H
#import <UI/Common/UIxPageFrame.h>
@interface SOGoRootPage : UIxPageFrame
{
NSString *userName;
}
@end
#endif /* SOGOROOTPAGE_H */

View File

@ -19,87 +19,58 @@
02111-1307, USA.
*/
#import <Foundation/NSUserDefaults.h>
#import <NGObjWeb/SoComponent.h>
#import <NGObjWeb/SoObject.h>
#import <NGObjWeb/WOApplication.h>
#import <NGObjWeb/WOContext.h>
#import <NGObjWeb/WOCookie.h>
#import <NGObjWeb/WORequest.h>
#import <NGObjWeb/WOResponse.h>
#import <NGExtensions/NSNull+misc.h>
#import <NGExtensions/NSObject+Logs.h>
#import <NGExtensions/NSString+misc.h>
#import <SOGo/SOGoAuthenticator.h>
#import <SOGo/SOGoUser.h>
#import <NGExtensions/NSObject+Logs.h>
@interface SOGoRootPage : SoComponent
{
NSString *userName;
}
#import <SoObjects/SOGo/SOGoAuthenticator.h>
#import <SoObjects/SOGo/SOGoUser.h>
@end
#import "SOGoRootPage.h"
@implementation SOGoRootPage
static BOOL doNotRedirect = NO;
+ (void)initialize {
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
if ((doNotRedirect = [ud boolForKey:@"SOGoDoNotRedirectRootPage"]))
NSLog(@"SOGoRootPage: home-page redirect is disabled.");
}
- (void)dealloc {
[self->userName release];
- (void) dealloc
{
[userName release];
[super dealloc];
}
/* accessors */
- (void)setUserName:(NSString *)_value {
ASSIGNCOPY(self->userName, _value);
- (void) setUserName: (NSString *) _value
{
ASSIGNCOPY (userName, _value);
}
- (NSString *)userName {
return self->userName;
- (NSString *) userName
{
return userName;
}
/* actions */
- (id)connectAction {
NSString *url;
[self takeFormValuesForKeys:@"userName", nil];
if ([[self userName] length] == 0)
return nil;
url = [@"/" stringByAppendingString:[[self userName] stringByEscapingURL]];
if (![url hasSuffix:@"/"])
url = [url stringByAppendingString:@"/"];
url = [[self context] urlWithRequestHandlerKey:@"so"
path:url queryString:nil];
return [self redirectToLocation:url];
}
- (id<WOActionResults>)defaultAction {
- (id <WOActionResults>) defaultAction
{
WOResponse *r;
NSString *login, *rhk;
id auth, user;
id home, base;
SOGoAuthenticator *auth;
SOGoUser *user;
SOGoUserFolder *home;
WOApplication *base;
if (doNotRedirect)
return self;
/*
Note: ctx.activeUser is NOT set here. Don't know why, so we retrieve
the user from the authenticator.
*/
auth = [[self clientObject] authenticatorInContext:[self context]];
user = [auth userInContext:[self context]];
auth = [[self clientObject] authenticatorInContext: context];
user = [auth userInContext: context];
login = [user login];
if ([login isEqualToString:@"anonymous"]) {
@ -108,11 +79,11 @@ static BOOL doNotRedirect = NO;
}
/* check base */
base = [self application];
rhk = [[[self context] request] requestHandlerKey];
rhk = [[context request] requestHandlerKey];
if (([rhk length] == 0) || ([base requestHandlerForKey:rhk] == nil)) {
base = [base lookupName:@"so" inContext:[self context] acquire:NO];
base = [base lookupName: @"so" inContext: context acquire: NO];
if (![base isNotNull] || [base isKindOfClass:[NSException class]]) {
/* use root page if home could not be found */
@ -123,7 +94,7 @@ static BOOL doNotRedirect = NO;
/* lookup home-page */
home = [base lookupName:login inContext:[self context] acquire:NO];
home = [base lookupName: login inContext: context acquire: NO];
if (![home isNotNull] || [home isKindOfClass:[NSException class]]) {
/* use root page if home could not be found */
return self;
@ -131,33 +102,40 @@ static BOOL doNotRedirect = NO;
/* redirect to home-page */
r = [[self context] response];
[r setStatus:302 /* moved */];
[r setHeader:[home baseURLInContext:[self context]] forKey:@"location"];
r = [context response];
[r setStatus: 302 /* moved */];
[r setHeader: [home baseURLInContext: context]
forKey: @"location"];
return r;
}
/* response generation */
- (void)appendToResponse:(WOResponse *)_response inContext:(WOContext *)_ctx {
- (void) appendToResponse: (WOResponse *) response
inContext: (WOContext *) ctx
{
NSString *rhk;
// TODO: we might also want to look into the HTTP basic-auth to redirect to
// the login URL!
rhk = [[_ctx request] requestHandlerKey];
if ([rhk length]==0 || [[self application] requestHandlerForKey:rhk]==nil) {
/* a small hack to redirect to a valid URL */
NSString *url;
rhk = [[ctx request] requestHandlerKey];
if ([rhk length] == 0
|| [[self application] requestHandlerForKey: rhk] == nil)
{
/* a small hack to redirect to a valid URL */
NSString *url;
url = [_ctx urlWithRequestHandlerKey:@"so" path:@"/" queryString:nil];
[_response setStatus:302 /* moved */];
[_response setHeader:url forKey:@"location"];
[self logWithFormat:@"URL: %@", url];
return;
}
[super appendToResponse:_response inContext:_ctx];
url = [ctx urlWithRequestHandlerKey: @"so" path: @"/" queryString: nil];
[response setStatus: 302 /* moved */];
[response setHeader: url forKey: @"location"];
[self logWithFormat: @"URL: %@", url];
return;
}
[response setHeader: @"text/html" forKey: @"content-type"];
[super appendToResponse: response inContext: ctx];
}
@end /* SOGoRootPage */

View File

@ -1,24 +1,81 @@
<?xml version='1.0' standalone='yes'?>
<html
<?xml version="1.0" standalone="yes"?>
<!DOCTYPE container>
<container
xmlns="http://www.w3.org/1999/xhtml"
xmlns:var="http://www.skyrix.com/od/binding"
xmlns:const="http://www.skyrix.com/od/constant"
>
<head>
<title>Scalable OGo Homepage</title>
</head>
xmlns:rsrc="OGo:url"
xmlns:label="OGo:label"
><var:string var:value="doctype" const:escapeHTML="NO" />
<html>
<head>
<title>
<var:string value="title"/>
</title>
<meta name="hideFrame" var:content="hideFrame" />
<meta name="description" content="SOGo Web Interface" />
<meta name="author" content="SKYRIX Software AG/Inverse groupe conseil" />
<meta name="robots" content="stop" />
<meta name="build" var:content="buildDate" />
<link href="mailto:support@inverse.ca" rev="made" />
<link rel="shortcut icon" rsrc:href="lori_16x16.ico" type="image/x-icon" />
<link type="text/css" rel="stylesheet" rsrc:href="generic.css" />
<link type="text/css" rel="stylesheet" rsrc:href="dtree.css" />
<var:if-ie
><link type="text/css" rel="stylesheet" rsrc:href="iefixes.css"
/></var:if-ie>
<link type="text/css" rel="stylesheet" rsrc:href="SOGoRootPage.css" />
</head>
<body>
<h3>Scalable OGo Homepage</h3>
<body class="loginPage">
<script type="text/javascript">
var ResourcesURL = '/SOGo.woa/WebServerResources';
</script>
<form href="connect">
Login:
<input name="userName" type="text" var:value="userName" />
<input name="submit" type="submit" value="connect" />
</form>
<!--
<hr />
Current locale: <pre><var:string value="context.locale" /></pre>
-->
</body>
</html>
<script type="text/javascript" rsrc:src="_IEtoW3C.js"><!-- space required --></script>
<script type="text/javascript" rsrc:src="events.js"><!-- space required --></script>
<script type="text/javascript" rsrc:src="prototype.js"><!-- space required --></script>
<script type="text/javascript" rsrc:src="JavascriptAPIExtensions.js"><!-- space required --></script>
<script type="text/javascript" rsrc:src="HTMLElement.js"><!-- space required --></script>
<script type="text/javascript" rsrc:src="HTMLInputElement.js"><!-- space required --></script>
<script type="text/javascript" rsrc:src="HTMLTableElement.js"><!-- space required --></script>
<script type="text/javascript" rsrc:src="HTMLUListElement.js"><!-- space required --></script>
<script type="text/javascript" rsrc:src="generic.js"><!-- space required --></script>
<script type="text/javascript" rsrc:src="SOGoDragAndDrop.js"><!-- space required --></script>
<script type="text/javascript" rsrc:src="SOGoDragHandles.js"><!-- space required --></script>
<script type="text/javascript" rsrc:src="SOGoRootPage.js"><!-- space required --></script>
<!-- var:js-stringtable
var:framework="productFrameworkName"
const:identifier="labels" -->
<!-- var:js-stringtable
const:identifier="clabels" -->
<div class="pageContent">
<form href="view">
<div id="loginScreen">
<img rsrc:src="lori-login.jpg"/><br/><br/>
<label><var:string label:value="Login:"/><br/>
<input class="textField" id="userName" name="userName"
type="text" var:value="userName" /></label><br/>
<label><var:string label:value="Password:"/><br/>
<input class="textField" id="password"
name="password" type="password" var:value="password" /><br/></label>
<div id="loginButton">
<input class="button" id="submit" name="submit" type="submit" label:value="Connect" />
</div>
</div>
</form>
</div>
<noscript>
<div class="javascriptPopupBackground">
</div>
<div class="javascriptMessagePseudoWindow noJavascriptErrorMessage">
<var:string label:value="noJavascriptError"
/><br /><br
/><a class="button" var:href="page.context.uri"
><var:string label:value="noJavascriptRetry"
/></a>
</div>
</noscript>
</body>
</html>
</container>

View File

@ -0,0 +1,36 @@
BODY
{ background-color: #999; }
DIV#loginScreen
{
background-color: #d4d0c8;
margin: 0px auto;
margin-top: 5em;
padding: 10px;
border: 2px solid transparent;
width: 158px;
height: 250px;
-moz-border-top-colors: #efebe7 #fff;
-moz-border-left-colors: #efebe7 #fff;
-moz-border-right-colors: #000 #9c9a94 transparent;
-moz-border-bottom-colors: #000 #9c9a94 transparent;
}
DIV#loginScreen IMG
{ border: 1px solid #999; }
DIV#loginScreen INPUT
{ width: 100%; }
DIV#loginButton
{ text-align: right; }
DIV#loginButton INPUT
{ width: auto;
margin-top: 5px; }
DIV#loginButton IMG#progressIndicator
{ float: left;
border: 0px none;
margin-top: 5px;
margin-left: 5px; }

View File

@ -0,0 +1,15 @@
function initLogin() {
var submit = $("submit");
var userName = $("userName");
userName.focus();
Event.observe(submit, "click", onLoginClick);
}
function onLoginClick(event) {
startAnimation($("loginButton"), $("submit"));
var loginString = $("userName").value + ":" + $("password").value;
document.cookie = "0xHIGHFLYxSOGo-0.9 = basic" + loginString.base64encode();
}
addEvent(window, 'load', initLogin);