001 /*
002 *
003 * $Revision$ $Date$
004 *
005 * This file is part of *** M y C o R e ***
006 * See http://www.mycore.de/ for details.
007 *
008 * This program is free software; you can use it, redistribute it
009 * and / or modify it under the terms of the GNU General Public License
010 * (GPL) as published by the Free Software Foundation; either version 2
011 * of the License or (at your option) any later version.
012 *
013 * This program is distributed in the hope that it will be useful, but
014 * WITHOUT ANY WARRANTY; without even the implied warranty of
015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
016 * GNU General Public License for more details.
017 *
018 * You should have received a copy of the GNU General Public License
019 * along with this program, in a file called gpl.txt or license.txt.
020 * If not, write to the Free Software Foundation Inc.,
021 * 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA
022 */
023
024 package org.mycore.access.mcrimpl;
025
026 import org.apache.log4j.Logger;
027 import org.mycore.access.MCRAccessManager;
028 import org.mycore.frontend.cli.MCRAbstractCommands;
029 import org.mycore.frontend.cli.MCRCommand;
030
031 /**
032 * This class provides a set of commands for the org.mycore.access package which
033 * can be used by the command line interface. (creates sql tables, run queries
034 *
035 * @author Arne Seifert
036 */
037 public class MCRAccessCtrlCommands extends MCRAbstractCommands {
038 public static Logger logger = Logger.getLogger(MCRAccessCtrlCommands.class.getName());
039
040 /**
041 * constructor with commands.
042 */
043 public MCRAccessCtrlCommands() {
044 super();
045
046 MCRCommand com = null;
047
048 com = new MCRCommand("create accesstable", "org.mycore.access.MCRAccessCtrlCommands.createTables", "The command creates all tables for the Access Control System.");
049 command.add(com);
050
051 com = new MCRCommand("validate objectid {0} in pool {1}", "org.mycore.access.MCRAccessCtrlCommands.validate String String", "Validates access for given object and given permission");
052 command.add(com);
053 }
054
055 /**
056 * method creates sql tables
057 */
058 public static void createTables() {
059 MCRAccessStore.getInstance().createTables();
060 }
061
062 /**
063 * validates access for given object and given permission
064 *
065 * @param objid
066 * internal database ruleid
067 * @param permission
068 * the access permission for the rule
069 */
070 public static void validate(String objid, String permission) {
071 System.out.println("current user has access: " + MCRAccessManager.checkPermission(objid, permission));
072 }
073 }