package com.dbxml.db.common.security;
/*
* dbXML - Native XML Database
* Copyright (c) 1999-2006 The dbXML Group, L.L.C.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* $Id: SecurityManagerBase.java,v 1.3 2006/02/02 18:53:52 bradford Exp $
*/
import com.dbxml.db.core.Database;
import com.dbxml.db.core.FaultCodes;
import com.dbxml.db.core.security.SecurityException;
import com.dbxml.db.core.security.SecurityManager;
import com.dbxml.db.core.security.User;
import com.dbxml.db.core.security.UserStack;
import com.dbxml.util.SimpleConfigurable;
/**
* SecurityManagerBase
*/
public abstract class SecurityManagerBase extends SimpleConfigurable implements SecurityManager {
protected Database database;
protected UserStack userStack;
protected User magicUser;
public void setDatabase(Database database) {
this.database = database;
}
public void setMagicUser(User magicUser) throws SecurityException {
if ( this.magicUser == null )
this.magicUser = magicUser;
else
throw new SecurityException(FaultCodes.SEC_INVALID_ACCESS, "Can't overwrite Magic User");
}
public void setUserStack(UserStack userStack) throws SecurityException {
if ( this.userStack == null )
this.userStack = userStack;
else
throw new SecurityException(FaultCodes.SEC_INVALID_ACCESS, "Can't overwrite User Stack");
}
public String getCurrentUserID() {
User user = userStack.getCurrentUser();
if ( user != null )
return user.getId();
else
return null;
}
}