/* permCustom.java This file is a management class for Role records in Ganymede. Created: 21 January 1998 Module By: Jonathan Abbey, jonabbey@arlut.utexas.edu ----------------------------------------------------------------------- Ganymede Directory Management System Copyright (C) 1996 - 2013 The University of Texas at Austin Ganymede is a registered trademark of The University of Texas at Austin Contact information Author Email: ganymede_author@arlut.utexas.edu Email mailing list: ganymede@arlut.utexas.edu US Mail: Computer Science Division Applied Research Laboratories The University of Texas at Austin PO Box 8029, Austin TX 78713-8029 Telephone: (512) 835-3200 This program 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 of the License, or (at your option) any later version. This program 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. If not, see <http://www.gnu.org/licenses/>. */ package arlut.csd.ganymede.server; import java.rmi.RemoteException; import arlut.csd.ganymede.common.Invid; import arlut.csd.ganymede.common.SchemaConstants; /*------------------------------------------------------------------------------ class permCustom ------------------------------------------------------------------------------*/ /** * * This file is a management class for Role records in Ganymede. * */ public class permCustom extends DBEditObject implements SchemaConstants { /** * * Customization Constructor * */ public permCustom(DBObjectBase objectBase) throws RemoteException { super(objectBase); } /** * * Create new object constructor * */ public permCustom(DBObjectBase objectBase, Invid invid, DBEditSet editset) throws RemoteException { super(objectBase, invid, editset); } /** * * Check-out constructor, used by DBObject.createShadow() * to pull out an object for editing. * */ public permCustom(DBObject original, DBEditSet editset) throws RemoteException { super(original, editset); } /** * <p>This method provides a hook that can be used to indicate whether * a field that is defined in this object's field dictionary * should be newly instantiated in this particular object.</p> * * <p>This method does not affect those fields which are actually present * in a previously existing object's record in the * {@link arlut.csd.ganymede.server.DBStore DBStore}. What this method allows * you to do is have a subclass decide whether it wants to instantiate * a potential field (one that is declared in the field dictionary for * this object, but which doesn't happen to be presently defined in * this object) in this particular object.</p> * * <p>A concrete example will help here. The Permissions Object type * (base number SchemaConstants.PermBase) holds a permission * matrix, a descriptive title, and a list of admin personae that hold * those permissions for objects they own.</p> * * <p>There are a few specific instances of SchemaConstants.PermBase * that don't properly need the list of admin personae, as their * object invids are hard-coded into the Ganymede security system, and * their permission matrices are automatically consulted in certain * situations. In order to support this, we're going to want to have * a DBEditObject subclass for managing permission objects. In that * subclass, we'll define instantiateNewField() so that it will return * false if the fieldID corresponds to the admin personae list if the * object's ID is that of one of these special objects. As a result, * when the objects are viewed by an administrator, the admin personae * list will not be seen.</p> * * <p>To be overridden on necessity in DBEditObject subclasses.</p> */ @Override public boolean instantiateNewField(short fieldID) { if (fieldID == SchemaConstants.RolePersonae) { if (getID() == SchemaConstants.RoleDefaultObj) { return false; } } return true; } /** * <p>Customization method to verify whether the user should be able to * see a specific field in a given object. Instances of * {@link arlut.csd.ganymede.server.DBField DBField} will * wind up calling up to here to let us override the normal visibility * process.</p> * * <p>Note that it is permissible for session to be null, in which case * this method will always return the default visiblity for the field * in question.</p> * * <p>If field is not from an object of the same base as this DBEditObject, * an exception will be thrown.</p> * * <p>To be overridden on necessity in DBEditObject subclasses.</p> * * <p><b>*PSEUDOSTATIC*</b></p> */ @Override public boolean canSeeField(DBSession session, DBField field) { // since the default permission object is always delegatable, we // won't show the checkbox in this case. if (field.getFieldDef().base() != this.objectBase) { throw new IllegalArgumentException("field/object mismatch"); } if ((field.getID() == SchemaConstants.RoleDelegatable) && (field.getOwner().getID() == SchemaConstants.RoleDefaultObj)) { return false; } return super.canSeeField(session, field); } }