--- /dev/null
+// $Id$
+
+#include <NGObjWeb/SoComponent.h>
+
+@class EOAdaptorChannel;
+
+@interface DHostView : SoComponent
+{
+ EOAdaptorChannel *channel;
+ NSArray *userNames;
+ NSArray *databaseNames;
+ id item;
+}
+
+@end
+
+#include "DSoHost.h"
+#include "common.h"
+
+@interface EOAdaptorChannel(ModelFetching)
+- (NSArray *)describeUserNames;
+- (NSArray *)describeDatabaseNames;
+@end
+
+@implementation DHostView
+
+- (void)dealloc {
+ if ([self->channel isOpen])
+ [self->channel closeChannel];
+ [self->channel release];
+
+ [self->userNames release];
+ [self->databaseNames release];
+ [self->item release];
+ [super dealloc];
+}
+
+/* notifications */
+
+- (void)sleep {
+ if ([self->channel isOpen])
+ [self->channel closeChannel];
+
+ [super sleep];
+}
+
+/* DB things */
+
+- (EOAdaptor *)adaptor {
+ return [(DSoHost *)[self clientObject] adaptorInContext:[self context]];
+}
+
+- (EOAdaptorChannel *)channel {
+ EOAdaptorContext *ctx;
+
+ if (self->channel)
+ return self->channel;
+
+ ctx = [[self adaptor] createAdaptorContext];
+ self->channel = [[ctx createAdaptorChannel] retain];
+ if (![self->channel openChannel]) {
+ [self->channel release];
+ self->channel = nil;
+ }
+
+ return self->channel;
+}
+
+/* accessors */
+
+- (void)setItem:(id)_item {
+ ASSIGN(self->item, _item);
+}
+- (id)item {
+ return self->item;
+}
+
+- (NSArray *)userNames {
+ if (self->userNames == nil)
+ self->userNames = [[[self channel] describeUserNames] copy];
+ return self->userNames;
+}
+
+- (NSArray *)databaseNames {
+ if (self->databaseNames == nil)
+ self->databaseNames = [[[self channel] describeDatabaseNames] copy];
+ return self->databaseNames;
+}
+
+/* derived accessors */
+
+// Note: it suxx that we need to write code for that ...
+
+- (NSString *)dbLink {
+ return [@"Databases/" stringByAppendingString:[self item]];
+}
+- (NSString *)userLink {
+ return [@"Users/" stringByAppendingString:[self item]];
+}
+
+@end /* DHostView */
--- /dev/null
+<?xml version='1.0' standalone='yes'?>
+<var:component className="Frame"
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:var="http://www.skyrix.com/od/binding"
+ xmlns:const="http://www.skyrix.com/od/constant"
+>
+
+Host: <var:string value="clientObject.hostName"/><br />
+Port: <var:string value="clientObject.port"/><br />
+
+<h4>Databases</h4>
+<var:foreach list="databaseNames" item="item">
+ <li><a var:href="dbLink"><var:string value="item" /></a></li>
+</var:foreach>
+
+<h4>Users</h4>
+<var:foreach list="userNames" item="item">
+ <li><a var:href="userLink"><var:string value="item" /></a></li>
+</var:foreach>
+
+</var:component>
--- /dev/null
+/*
+ Copyright (C) 2004 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.
+*/
+// $Id$
+
+#ifndef __dbd_DSoAuthenticator_H__
+#define __dbd_DSoAuthenticator_H__
+
+#include <NGObjWeb/SoHTTPAuthenticator.h>
+
+/*
+ DSoAuthenticator
+
+ Authenticator based on PostgreSQL authentication.
+*/
+
+@interface DSoAuthenticator : SoHTTPAuthenticator
+{
+ NSString *hostname;
+ int port;
+ NSString *dbname;
+}
+
++ (id)authenticatorWithHostName:(NSString *)_hostname port:(int)_port;
++ (id)authenticatorWithHostName:(NSString *)_hostname port:(int)_port
+ databaseName:(NSString *)_dbname;
+
+@end
+
+#endif /* __dbd_DSoAuthenticator_H__ */
--- /dev/null
+/*
+ Copyright (C) 2004 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.
+*/
+// $Id$
+
+#include "DSoAuthenticator.h"
+#include "common.h"
+#include <GDLAccess/GDLAccess.h>
+
+/*
+ Things to note:
+ - authenticators themselves are _not_ bound to a context or a SOPE
+ traversal path
+ - because of that we need to duplicate some stuff
+ => or use a separate layer which handles uniquing
+*/
+
+@implementation DSoAuthenticator
+
+// TODO: might want to cache authenticator objects ...
+
+- (id)initWithHostName:(NSString *)_hostname port:(int)_port
+ databaseName:(NSString *)_dbname
+{
+ if ((self = [super init])) {
+ self->hostname = [_hostname copy];
+ self->port = _port;
+ self->dbname = [_dbname copy];
+ }
+ return self;
+}
+
++ (id)authenticatorWithHostName:(NSString *)_hostname port:(int)_port {
+ return [[[self alloc] initWithHostName:_hostname port:_port
+ databaseName:nil] autorelease];
+}
++ (id)authenticatorWithHostName:(NSString *)_hostname port:(int)_port
+ databaseName:(NSString *)_dbname
+{
+ return [[[self alloc] initWithHostName:_hostname port:_port
+ databaseName:_dbname] autorelease];
+}
+
+- (void)dealloc {
+ [self->hostname release];
+ [self->dbname release];
+ [super dealloc];
+}
+
+/* realm */
+
+- (NSString *)authRealm {
+ /*
+ the HTTP authentication realm, we use the database info (default is the
+ application name, but in our case we can be more specific)
+ */
+ if (self->dbname == nil)
+ return self->hostname;
+
+ return [[self->dbname stringByAppendingString:@"@"]
+ stringByAppendingString:self->hostname];
+}
+
+/* adaptor setup */
+
+- (NSString *)defaultDatabase {
+ /* template1 is supposed to exist always (#postgresql channel ;-) */
+ return @"template1";
+}
+
+- (EOAdaptor *)adaptorForLogin:(NSString *)_login password:(NSString *)_pwd {
+ EOAdaptor *adaptor;
+ NSDictionary *condict;
+ NSString *dbn;
+
+ if ((adaptor = [EOAdaptor adaptorWithName:@"PostgreSQL72"]) == nil)
+ return nil;
+
+ if (![_login isNotNull]) _login = @"";
+ if (![_pwd isNotNull]) _pwd = @"";
+
+ dbn = [self->dbname isNotNull] ? self->dbname : [self defaultDatabase];
+
+ // TODO: ignores port
+ condict = [[NSDictionary alloc] initWithObjectsAndKeys:
+ self->hostname, @"hostName",
+ _login, @"userName",
+ _pwd, @"password",
+ dbn, @"databaseName",
+ nil];
+ [adaptor setConnectionDictionary:condict];
+ [condict release];
+ return adaptor;
+}
+
+/* check credentials */
+
+- (BOOL)checkLogin:(NSString *)_login password:(NSString *)_pwd {
+ EOAdaptor *adaptor;
+ EOAdaptorContext *adctx;
+ EOAdaptorChannel *adch;
+ BOOL ok;
+
+ [self logWithFormat:@"check login: %@", _login];
+
+ /* create all necessary objects */
+
+ adaptor = [self adaptorForLogin:_login password:_pwd];
+ adctx = [adaptor createAdaptorContext];
+ adch = [adctx createAdaptorChannel];
+
+ [self logWithFormat:@" channel: %@", adch];
+
+ /* open channel to check whether credentials are valid */
+
+ if ((ok = [adch openChannel]))
+ [adch closeChannel];
+
+ return ok;
+}
+
+@end /* DSoAuthenticator */
--- /dev/null
+/*
+ Copyright (C) 2004 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.
+*/
+// $Id$
+
+#ifndef __dbd_DSoDatabase_H__
+#define __dbd_DSoDatabase_H__
+
+#include "DSoObject.h"
+
+@interface DSoDatabase : DSoObject
+{
+ NSString *hostName;
+ int port;
+ NSString *databaseName;
+}
+
+- (id)initWithHostName:(NSString *)_hostname port:(int)_port
+ databaseName:(NSString *)_dbname;
+
+@end
+
+#endif /* __dbd_DSoDatabase_H__ */
--- /dev/null
+/*
+ Copyright (C) 2004 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.
+*/
+// $Id$
+
+#include "DSoDatabase.h"
+#include "DSoAuthenticator.h"
+#include "common.h"
+
+@implementation DSoDatabase
+
+- (id)initWithHostName:(NSString *)_hostname port:(int)_port
+ databaseName:(NSString *)_dbname
+{
+ if ((self = [super init])) {
+ self->hostName = [_hostname copy];
+ self->databaseName = [_dbname copy];
+ self->port = _port > 0 ? _port : 5432;
+ }
+ return self;
+}
+
+- (void)dealloc {
+ [self->databaseName release];
+ [self->hostName release];
+ [super dealloc];
+}
+
+/* accessors */
+
+- (NSString *)hostName {
+ return self->hostName;
+}
+- (int)port {
+ return self->port;
+}
+
+- (NSString *)databaseName {
+ return self->databaseName;
+}
+
+/* authentication */
+
+- (id)authenticatorInContext:(id)_ctx {
+ return [DSoAuthenticator authenticatorWithHostName:[self hostName]
+ port:[self port] databaseName:[self databaseName]];
+}
+
+@end /* DSoDatabase */
--- /dev/null
+/*
+ Copyright (C) 2004 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.
+*/
+// $Id$
+
+#ifndef __dbd_DSoDatabaseManager_H__
+#define __dbd_DSoDatabaseManager_H__
+
+#include "DSoObject.h"
+
+@class DSoHost;
+
+@interface DSoDatabaseManager : DSoObject
+{
+ DSoHost *host;
+}
+
+- (id)initWithContainer:(DSoHost *)_container;
+
+@end
+
+#endif /* __dbd_DSoDatabaseManager_H__ */
--- /dev/null
+/*
+ Copyright (C) 2004 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.
+*/
+// $Id$
+
+#include "DSoDatabaseManager.h"
+#include "DSoHost.h"
+#include "common.h"
+
+@implementation DSoDatabaseManager
+
+- (id)initWithContainer:(DSoHost *)_container {
+ if ((self = [super init])) {
+ self->host = [_container retain];
+ }
+ return self;
+}
+- (id)init {
+ return [self initWithContainer:nil];
+}
+
+- (void)dealloc {
+ [self->host release];
+ [super dealloc];
+}
+
+/* name lookup */
+
+- (id)lookupName:(NSString *)_key inContext:(id)_ctx acquire:(BOOL)_flag {
+ id obj;
+
+ if ((obj = [super lookupName:_key inContext:_ctx acquire:_flag]))
+ return obj;
+
+ // TODO: create DSoDatabase object
+
+ return nil;
+}
+
+@end /* DSoDatabaseManager */
--- /dev/null
+/*
+ Copyright (C) 2004 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.
+*/
+// $Id$
+
+#ifndef __dbd_DSoField_H__
+#define __dbd_DSoField_H__
+
+#include "DSoObject.h"
+
+@interface DSoField : DSoObject
+{
+}
+
+@end
+
+#endif /* __dbd_DSoField_H__ */
--- /dev/null
+/*
+ Copyright (C) 2004 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.
+*/
+// $Id$
+
+#include "DSoField.h"
+#include "common.h"
+
+@implementation DSoField
+
+- (void)dealloc {
+ [super dealloc];
+}
+
+@end /* DSoField */
--- /dev/null
+/*
+ Copyright (C) 2004 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.
+*/
+// $Id$
+
+#ifndef __dbd_DSoHost_H__
+#define __dbd_DSoHost_H__
+
+#include "DSoObject.h"
+
+@class NSString;
+
+@interface DSoHost : DSoObject
+{
+ NSString *hostName;
+ int port;
+}
+
++ (id)dHostWithName:(NSString *)_key port:(int)_port;
+- (id)initWithHostName:(NSString *)_key port:(int)_port;
+
+/* accessors */
+
+- (NSString *)hostName;
+- (int)port;
+
+/* support */
+
+- (EOAdaptor *)adaptorInContext:(WOContext *)_ctx;
+
+@end
+
+#endif /* __dbd_DSoHost_H__ */
--- /dev/null
+/*
+ Copyright (C) 2004 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.
+*/
+// $Id$
+
+#include "DSoHost.h"
+#include "DSoAuthenticator.h"
+#include "DSoDatabaseManager.h"
+#include "DSoUserManager.h"
+#include "common.h"
+
+@implementation DSoHost
+
++ (id)dHostWithName:(NSString *)_key port:(int)_port {
+ return [[[self alloc] initWithHostName:_key port:_port] autorelease];
+}
+- (id)initWithHostName:(NSString *)_key port:(int)_port {
+ if ((self = [super init])) {
+ self->hostName = [_key copy];
+ self->port = _port > 0 ? _port : 5432;
+ }
+ return self;
+}
+
+- (void)dealloc {
+ [self->hostName release];
+ [super dealloc];
+}
+
+/* accessors */
+
+- (NSString *)hostName {
+ return self->hostName;
+}
+- (int)port {
+ return self->port;
+}
+
+/* support */
+
+- (EOAdaptor *)adaptorInContext:(WOContext *)_ctx {
+ return [self adaptorForHostName:[self hostName] port:[self port]
+ databaseName:nil inContext:_ctx];
+}
+
+/* authentication */
+
+- (id)authenticatorInContext:(id)_ctx {
+ return [DSoAuthenticator authenticatorWithHostName:[self hostName]
+ port:[self port]];
+}
+
+/* names */
+
+- (id)lookupName:(NSString *)_key inContext:(id)_ctx acquire:(BOOL)_flag {
+ /* We only need to deal with two fix keys here :-) */
+ if ([_key isEqualToString:@"Databases"])
+ return [[[DSoDatabaseManager alloc] initWithContainer:self] autorelease];
+ if ([_key isEqualToString:@"Users"])
+ return [[[DSoUserManager alloc] initWithContainer:self] autorelease];
+
+ return [super lookupName:_key inContext:_ctx acquire:_flag];
+}
+
+@end /* DSoHost */
--- /dev/null
+/*
+ Copyright (C) 2004 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.
+*/
+// $Id$
+
+#ifndef __dbd_DSoObject_H__
+#define __dbd_DSoObject_H__
+
+#import <Foundation/NSObject.h>
+
+@class NSString;
+@class EOAdaptor;
+@class WOContext;
+
+@interface DSoObject : NSObject
+{
+}
+
+- (EOAdaptor *)adaptorForHostName:(NSString *)_hname port:(int)_port
+ databaseName:(NSString *)_dbname inContext:(WOContext *)_ctx;
+
+@end
+
+#endif /* __dbd_DSoObject_H__ */
--- /dev/null
+/*
+ Copyright (C) 2004 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.
+*/
+// $Id$
+
+#include "DSoObject.h"
+#include "common.h"
+#include <NGObjWeb/SoHTTPAuthenticator.h>
+#include <GDLAccess/GDLAccess.h>
+
+@implementation DSoObject
+
+- (void)dealloc {
+ [super dealloc];
+}
+
+/* common methods */
+
+- (NSString *)defaultDatabase {
+ /* template1 is supposed to exist always (#postgresql channel ;-) */
+ return @"template1";
+}
+
+- (EOAdaptor *)adaptorForHostName:(NSString *)_hname port:(int)_port
+ databaseName:(NSString *)_dbname inContext:(WOContext *)_ctx
+{
+ EOAdaptor *adaptor;
+ NSDictionary *condict;
+ NSString *login = nil, *pwd = nil, *auth;
+ NSArray *creds;
+
+ if ((adaptor = [EOAdaptor adaptorWithName:@"PostgreSQL72"]) == nil) {
+ [self logWithFormat:@"missing PostgreSQL72 adaptor"];
+ return nil;
+ }
+
+ /* extract login/password */
+
+ if ((auth = [[_ctx request] headerForKey:@"authorization"]) == nil) {
+ [self logWithFormat:@"missing 'authorization' .."];
+ return nil;
+ }
+ creds = [SoHTTPAuthenticator parseCredentials:auth];
+ if ([creds count] < 2) {
+ [self logWithFormat:@"cannot use credentials: %@", creds];
+ return nil;
+ }
+ login = [creds objectAtIndex:0];
+ pwd = [creds objectAtIndex:1];
+
+ /* create adaptor */
+
+ _dbname = [_dbname isNotNull] ? _dbname : [self defaultDatabase];
+
+ // TODO: ignores port
+ condict = [[NSDictionary alloc] initWithObjectsAndKeys:
+ _hname, @"hostName",
+ login, @"userName",
+ pwd, @"password",
+ _dbname, @"databaseName",
+ nil];
+ [adaptor setConnectionDictionary:condict];
+ [condict release];
+ return adaptor;
+}
+
+#if 0
+- (id)GETAction:(id)_ctx {
+ /* per default, return nothing ... */
+ WOResponse *r = [(WOContext *)_ctx response];
+ NSString *defName;
+
+ if ((defName = [self defaultMethodNameInContext:_ctx])) {
+ [r setStatus:302 /* moved */];
+ [r setHeader:[[self baseURL] stringByAppendingPathComponent:defName]
+ forKey:@"location"];
+ return r;
+ }
+
+ [r setStatus:200 /* Ok */];
+ [self logWithFormat:@"GET on folder, just saying OK"];
+ return r;
+}
+#endif
+
+@end /* DSoObject */
--- /dev/null
+/*
+ Copyright (C) 2004 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.
+*/
+// $Id$
+
+#ifndef __dbd_DSoTable_H__
+#define __dbd_DSoTable_H__
+
+#include "DSoObject.h"
+
+@interface DSoTable : DSoObject
+{
+}
+
+@end
+
+#endif /* __dbd_DSoTable_H__ */
--- /dev/null
+/*
+ Copyright (C) 2004 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.
+*/
+// $Id$
+
+#include "DSoTable.h"
+#include "common.h"
+
+@implementation DSoTable
+
+- (void)dealloc {
+ [super dealloc];
+}
+
+@end /* DSoTable */
--- /dev/null
+/*
+ Copyright (C) 2004 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.
+*/
+// $Id$
+
+#ifndef __dbd_DSoUser_H__
+#define __dbd_DSoUser_H__
+
+#include "DSoObject.h"
+
+@interface DSoUser : DSoObject
+{
+}
+
+@end
+
+#endif /* __dbd_DSoUser_H__ */
--- /dev/null
+/*
+ Copyright (C) 2004 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.
+*/
+// $Id$
+
+#include "DSoUser.h"
+#include "common.h"
+
+@implementation DSoUser
+
+- (void)dealloc {
+ [super dealloc];
+}
+
+@end /* DSoUser */
--- /dev/null
+/*
+ Copyright (C) 2004 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.
+*/
+// $Id$
+
+#ifndef __dbd_DSoUserManager_H__
+#define __dbd_DSoUserManager_H__
+
+#include "DSoObject.h"
+
+@class DSoHost;
+
+@interface DSoUserManager : DSoObject
+{
+ DSoHost *host;
+}
+
+- (id)initWithContainer:(DSoHost *)_container;
+
+@end
+
+#endif /* __dbd_DSoUserManager_H__ */
--- /dev/null
+/*
+ Copyright (C) 2004 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.
+*/
+// $Id$
+
+#include "DSoUserManager.h"
+#include "DSoHost.h"
+#include "common.h"
+
+@implementation DSoUserManager
+
+- (id)initWithContainer:(DSoHost *)_container {
+ if ((self = [super init])) {
+ self->host = [_container retain];
+ }
+ return self;
+}
+- (id)init {
+ return [self initWithContainer:nil];
+}
+
+- (void)dealloc {
+ [self->host release];
+ [super dealloc];
+}
+
+/* name lookup */
+
+- (id)lookupName:(NSString *)_key inContext:(id)_ctx acquire:(BOOL)_flag {
+ id obj;
+
+ if ((obj = [super lookupName:_key inContext:_ctx acquire:_flag]))
+ return obj;
+
+ // TODO: create DSoUser object
+
+ return nil;
+}
+
+@end /* DSoUserManager */
--- /dev/null
+// $Id$
+
+#include <NGObjWeb/SoComponent.h>
+
+@interface Frame : SoComponent
+@end
+
+#include "common.h"
+
+@implementation Frame
+@end /* Frame */
--- /dev/null
+<?xml version='1.0' standalone='yes'?>
+<!-- $Id$ -->
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:var="http://www.skyrix.com/od/binding"
+ xmlns:const="http://www.skyrix.com/od/constant"
+ xmlns:rsrc="OGo:url"
+>
+ <head>
+ <title>DB Testdaemon (<var:string value="context.page.name"/>)</title>
+ <meta name="description" content="OGo DB Testdaemon Web Interface" />
+ <meta name="author" content="SKYRIX Software AG" />
+ <meta name="robots" content="stop" />
+ <link href="mailto:feedback@opengroupware.org" rev="made" />
+ <link type="text/css" rel="stylesheet" rsrc:href="dbd.css" />
+ </head>
+
+ <body>
+ <var:component-content/>
+ </body>
+</html>
--- /dev/null
+# $Id: GNUmakefile,v 1.13 2004/06/08 11:41:13 helge Exp $
+
+include $(GNUSTEP_MAKEFILES)/common.make
+
+WOAPP_NAME = dbd
+
+dbd_OBJC_FILES += \
+ dbd.m \
+ \
+ Frame.m \
+ MainPage.m \
+ DSoAuthenticator.m \
+ \
+ DSoObject.m \
+ DSoHost.m \
+ DSoTable.m \
+ DSoDatabase.m \
+ DSoDatabaseManager.m \
+ DSoUser.m \
+ DSoUserManager.m \
+ DSoField.m \
+ \
+ DHostView.m \
+
+dbd_RESOURCE_FILES += \
+ Version \
+ product.plist \
+ \
+ Frame.wox \
+ MainPage.wox \
+ \
+ DHostView.wox \
+
+dbd_WEBSERVER_RESOURCE_FILES +=
+
+ADDITIONAL_TOOL_LIBS += -lGDLAccess
+
+-include GNUmakefile.preamble
+include $(GNUSTEP_MAKEFILES)/woapp.make
+-include GNUmakefile.postamble
--- /dev/null
+// $Id$
+
+#include <NGObjWeb/SoComponent.h>
+
+@interface MainPage : SoComponent
+{
+ NSString *hostName;
+ NSString *databaseName;
+}
+
+@end
+
+#include "common.h"
+
+@implementation MainPage
+
+- (id)initWithContext:(id)_ctx {
+ if ((self = [super initWithContext:_ctx])) {
+ self->hostName = @"localhost";
+ }
+ return self;
+}
+
+- (void)dealloc {
+ [self->hostName release];
+ [self->databaseName release];
+ [super dealloc];
+}
+
+/* accessors */
+
+- (void)setHostName:(NSString *)_value {
+ ASSIGNCOPY(self->hostName, _value);
+}
+- (NSString *)hostName {
+ return self->hostName;
+}
+
+- (void)setDatabaseName:(NSString *)_value {
+ ASSIGNCOPY(self->databaseName, _value);
+}
+- (NSString *)databaseName {
+ return self->databaseName;
+}
+
+/* actions */
+
+- (id)connectAction {
+ NSString *url;
+
+ [self takeFormValuesForKeys:@"databaseName", @"hostName", nil];
+
+ if ([[self hostName] length] == 0)
+ return nil;
+
+ url = [@"/" stringByAppendingString:[[self hostName] stringByEscapingURL]];
+ if ([[self databaseName] length] > 0) {
+ url = [url stringByAppendingString:@"/Databases/"];
+ url = [url stringByAppendingString:
+ [[self databaseName] stringByEscapingURL]];
+ }
+
+ url = [[self context] urlWithRequestHandlerKey:@"so"
+ path:url queryString:nil];
+ return [self redirectToLocation:url];
+}
+
+/* response generation */
+
+- (void)appendToResponse:(WOResponse *)_response inContext:(WOContext *)_ctx {
+ NSString *rhk;
+
+ 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"];
+ return;
+ }
+
+ [super appendToResponse:_response inContext:_ctx];
+}
+
+@end /* MainPage */
--- /dev/null
+<?xml version='1.0' standalone='yes'?>
+<var:component className="Frame"
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:var="http://www.skyrix.com/od/binding"
+ xmlns:const="http://www.skyrix.com/od/constant"
+>
+
+ ClientObject: <var:string value="context.clientObject" />
+
+ <form href="connect">
+ <table border="0">
+ <tr>
+ <td>Host:</td>
+ <td><input name="hostName" type="text" var:value="hostName" /></td>
+ </tr>
+ <tr>
+ <td>User:</td>
+ <td><input name="userName" type="text" var:value="userName" /></td>
+ </tr>
+ <tr>
+ <td>Database:</td>
+ <td><input name="databaseName" type="text"
+ var:value="databaseName" /></td>
+ </tr>
+
+ <tr>
+ <td></td>
+ <td><input name="submit" type="submit" value="connect"/></td>
+ </tr>
+ </table>
+ </form>
+
+</var:component>
--- /dev/null
+# $Id$
+
+PostgreSQL Browser
+==================
+
+Intention:
+- fix open SOPE issues
+- fix PostgreSQL issues, prepare low-level storage
+- work towards SOGo from a storage point of view (with UI-X coming down from a
+ UI point of view)
+
+SOPE Hierarchy
+- /DBHOST/Databases/MYDB/MYTABLE/MYFIELD
+- /DBHOST/Users/MYUSER
+
+Class Hierarchy
+ DSoObject
+ DSoHost "DBHOST"
+ DSoTable "MYTABLE"
+ DSoDatabase "MYDB"
+ DSoDatabaseManager "Database"
+ DSoUser "MYUSER"
+ DSoUserManager "Users"
+ DSoField "MYFIELD"
+
+Tricks used
+===========
+
+- small hack in MainPage.m to make a redirect to a "valid" WO URL if the
+ request-handler-key is missing
+ - should be made by SOPE itself?
+
+- own authenticator object
+ - two different authenticators (with dbname available and without)
+
+- a hack in the SoApplication -lookupName: to differentiate between
+ 'hostnames' and resources
+
+- in DSoObject we extract login/password from the basic auth
+ - SOPE does all the authentication for SOPE level objects, but if we
+ want to reuse passwords, we need to do that manually
+ - we reuse an HTTP parsing method from SoHTTPAuthenticator
+
+- could -sleep to tear down transient state (not used)
+ - -sleep is called by the SoObjectRequestHandler
+ - Note: also supports -_sleepWithContext:
+
+- note that the EOAdaptor is created by the object, but the channel is created
+ by the method (the component)
+ - the object itself is not really active, the methods should be active
+ - the distinction here is blur, in general I would avoid methods which would
+ require an [[WOApplication application] context]
+
+- we are not really clever with DSoUserManager and DSoDatabaseManager,
+ those two classes are basically identical
--- /dev/null
+# $Id: Version,v 1.1 2003/11/24 01:24:40 helge Exp $
+
+SUBMINOR_VERSION:=1
--- /dev/null
+/*
+ Copyright (C) 2002-2004 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.
+*/
+// $Id$
+
+#import <Foundation/Foundation.h>
+
+#if NeXT_Foundation_LIBRARY || COCOA_Foundation_LIBRARY
+# include <NGExtensions/NGObjectMacros.h>
+# include <NGExtensions/NSString+Ext.h>
+#endif
+
+#include <NGExtensions/NGExtensions.h>
+#include <NGObjWeb/NGObjWeb.h>
+#include <NGObjWeb/SoObjects.h>
+
+#include <GDLAccess/GDLAccess.h>
--- /dev/null
+/* dbd UI Stylesheet */
+
+body {
+ color: #000000;
+ font-family: Arial, Helvetica, Verdana, Geneva, Tahoma, sans-serif;
+ font-size: 10pt;
+ background-color: #FFFFFF;
+ margin: 0px;
+ margin-top: 0px;
+ margin-bottom: 0px;
+ margin-left: 0px;
+ margin-right: 0px;
+}
+
+a:link {
+ color: #0033CC;
+ font-family: Arial, Helvetica, Verdana, Geneva, Tahoma, sans-serif;
+ text-decoration: none;
+}
+a:visited {
+ color: #660066;
+ font-family: Arial, Helvetica, Verdana, Geneva, Tahoma, sans-serif;
+ text-decoration: none;
+}
+a:hover {
+ color: #FF0000;
+ font-family: Arial, Helvetica, Verdana, Geneva, Tahoma, sans-serif;
+ text-decoration: underline;
+}
--- /dev/null
+/*
+ Copyright (C) 2004 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.
+*/
+// $Id$
+
+#include <NGObjWeb/SoApplication.h>
+
+@interface DBDaemon : SoApplication
+{
+}
+
+@end
+
+#include "DSoHost.h"
+#include "common.h"
+
+@implementation DBDaemon
+
+- (id)init {
+ if ((self = [super init])) {
+ }
+ return self;
+}
+
+/* name lookup */
+
+- (id)lookupHost:(NSString *)_key inContext:(id)_ctx {
+ NSRange r;
+ NSString *hostName;
+ int port;
+
+ r = [_key rangeOfString:@":"];
+ if (r.length == 0) {
+ hostName = _key;
+ port = 5432;
+ }
+ else {
+ hostName = [_key substringToIndex:r.location];
+ port = [[_key substringFromIndex:(r.location + r.length)] intValue];
+ }
+ return [DSoHost dHostWithName:hostName port:port];
+}
+
+- (id)lookupName:(NSString *)_key inContext:(id)_ctx acquire:(BOOL)_flag {
+ NSRange r;
+ id obj;
+
+ /* first check attributes directly bound to the application */
+ if ((obj = [super lookupName:_key inContext:_ctx acquire:_flag]))
+ return obj;
+
+ /*
+ The problem is, that at this point we still get request for resources,
+ eg 'favicon.ico'.
+ The hack here is to check for a dot in the key, but we should find a way
+ to catch that in a more sensible way.
+
+ One way to check for a valid key would be to check whether the key is a
+ valid hostname, but I would like to avoid that for performance reasons.
+ */
+ r = [_key rangeOfString:@"."];
+ if (r.length == 0)
+ return [self lookupHost:_key inContext:_ctx];
+
+ return nil;
+}
+
+/* exception handling */
+
+- (WOResponse *)handleException:(NSException *)_exc
+ inContext:(WOContext *)_ctx
+{
+ printf("EXCEPTION: %s\n", [[_exc description] cString]);
+ abort();
+}
+
+@end /* DBDaemon */
+
+
+int main(int argc, char **argv, char **env) {
+ NSAutoreleasePool *pool;
+
+ pool = [[NSAutoreleasePool alloc] init];
+#if LIB_FOUNDATION_LIBRARY
+ [NSProcessInfo initializeWithArguments:argv count:argc environment:env];
+#endif
+ [NGBundleManager defaultBundleManager];
+
+ WOWatchDogApplicationMain(@"DBDaemon", argc, (void*)argv);
+
+ [pool release];
+ return 0;
+}
--- /dev/null
+{
+ publicResources = (
+ "dbd.css"
+ );
+
+ classes = {
+ DBDaemon = {
+ superclass = "SoApplication";
+ protectedBy = "View";
+ defaultAccess = "allow";
+ defaultRoles = {
+ "View" = "Anonymous";
+ "WebDAV Access" = "Authenticated";
+ };
+ methods = {
+ "index" = {
+ protectedBy = "View";
+ pageName = "MainPage";
+ };
+ "connect" = {
+ protectedBy = "View";
+ pageName = "MainPage";
+ actionName = "connect";
+ };
+ };
+ };
+
+ DSoObject = {
+ protectedBy = "View";
+ defaultAccess = "allow";
+ defaultRoles = {
+ "View" = "Authenticated";
+ "WebDAV Access" = "Authenticated";
+ };
+ methods = {
+ };
+ };
+
+ DSoHost = {
+ superclass = "DSoObject";
+ methods = {
+ "index" = {
+ protectedBy = "View";
+ pageName = "DHostView";
+ };
+ };
+ };
+ DSoTable = {
+ superclass = "DSoObject";
+ methods = {
+ };
+ };
+ DSoDatabase = {
+ superclass = "DSoObject";
+ methods = {
+ };
+ };
+ DSoDatabaseManager = {
+ superclass = "DSoObject";
+ methods = {
+ };
+ };
+ DSoUser = {
+ superclass = "DSoObject";
+ methods = {
+ };
+ };
+ DSoUserManager = {
+ superclass = "DSoObject";
+ methods = {
+ };
+ };
+ DSoField = {
+ superclass = "DSoObject";
+ methods = {
+ };
+ };
+ };
+}