All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.kawanfw.sql.servlet.SqlConfiguratorCall Maven / Gradle / Ivy

/*
 * This file is part of AceQL. 
 * AceQL: Remote JDBC access over HTTP.                                     
 * Copyright (C) 2015,  KawanSoft SAS
 * (http://www.kawansoft.com). All rights reserved.                                
 *                                                                               
 * AceQL 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.1 of the License, or (at your option) any later version.            
 *                                                                               
 * AceQL 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 this library; if not, write to the Free Software           
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  
 * 02110-1301  USA
 *
 * Any modifications to this file must keep this entire header
 * intact.
 */
package org.kawanfw.sql.servlet;

import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

import org.kawanfw.sql.api.server.SqlConfigurator;

/**
 * 
 * Calls SqlConfigurator methods using reflection
 * 
 * @author Nicolas de Pomereu
 * 
 */

public class SqlConfiguratorCall {

    /**
     * Returns the result of SqlConfigurator.allowExecute
     * 
     * @param sqlConfigurator
     *            the SqlConfigurator instance
     * @param username
     *            the client username
     * @param connection
     *            The JDBC Connection
     * @return the result of SqlConfigurator.allowExecute
     * @throws IOException
     * @throws SQLException
     */
    public static boolean allowExecute(SqlConfigurator sqlConfigurator,
	    String username, Connection connection) throws IOException,
	    SQLException {
	return sqlConfigurator.allowExecute(username, connection);
    }

    /**
     * Returns the result of SqlConfigurator.allowExecuteUpdate
     * 
     * @param sqlConfigurator
     *            the SqlConfigurator instance
     * @param username
     *            the client username
     * @param connection
     *            The JDBC Connection
     * @return the result of SqlConfigurator.allowExecuteUpdate
     * @throws IOException
     * @throws SQLException
     */
    public static boolean allowExecuteUpdate(SqlConfigurator sqlConfigurator,
	    String username, Connection connection) throws IOException,
	    SQLException {
	return sqlConfigurator.allowExecuteUpdate(username, connection);
    }

    /**
     * Returns the result of SqlConfigurator.allowStatementClass
     * 
     * @param sqlConfigurator
     *            the SqlConfigurator instance
     * @param username
     *            the client username
     * @param connection
     *            The JDBC Connection
     * @return the result of SqlConfigurator.allowStatementClass
     * @throws IOException
     * @throws SQLException
     */
    public static boolean allowStatementClass(SqlConfigurator sqlConfigurator,
	    String username, Connection connection) throws IOException,
	    SQLException {
	return sqlConfigurator.allowStatementClass(username, connection);
    }

    /**
     * Returns the result of SqlConfigurator.allowGetMetaData
     * 
     * @param sqlConfigurator
     *            the SqlConfigurator instance
     * @param username
     *            the client username
     * @param connection
     *            The JDBC Connection
     * @return the result of SqlConfigurator.allowGetMetaData
     * @throws IOException
     * @throws SQLException
     */
    public static boolean allowGetMetaData(SqlConfigurator sqlConfigurator,
	    String username, Connection connection) throws IOException,
	    SQLException {
	return sqlConfigurator.allowGetMetaData(username, connection);
    }

    /**
     * Returns the result of SqlConfigurator.allowResultSetGetMetaData
     * 
     * @param sqlConfigurator
     *            the SqlConfigurator instance
     * @param username
     *            the client username
     * @param connection
     *            The JDBC Connection
     * @return the result of SqlConfigurator.allowResultSetGetMetaData
     * @throws IOException
     * @throws SQLException
     */
    public static boolean allowResultSetGetMetaData(
	    SqlConfigurator sqlConfigurator, String username,
	    Connection connection) throws IOException, SQLException {
	return sqlConfigurator.allowResultSetGetMetaData(username, connection);
    }

    /*
     * public void runIfStatementRefused(String username, Connection connection,
     * String ipAddress, String sql, List parameterValues) throws
     * IOException, SQLException;
     */

    /**
     * Runs SqlConfigurator.runIfStatementRefused
     * 
     * @param sqlConfigurator
     *            the SqlConfigurator instance
     * @param username
     *            the client username
     * @param connection
     *            The JDBC Connection
     * @throws IOException
     * @throws SQLException
     */
    public static void runIfStatementRefused(SqlConfigurator sqlConfigurator,
	    String username, Connection connection, String ipAddress,
	    String sql, List parameterValues) throws IOException,
	    SQLException {
	sqlConfigurator.runIfStatementRefused(username, connection, ipAddress,
		sql, parameterValues);
    }

    /**
     * Return the result of getMaxRowsToReturn method of SqlConfigurator, if
     * it's implemented, else 0.
     * 
     * @param sqlConfigurator
     *            the SqlConfigurator instance
     * @return the result of getMaxRowsToReturn of SqlConfigurator, if it's
     *         implemented, else 0;
     * 
     * @throws IOException
     * @throws SQLException
     */
    public static int getMaxRowsToReturn(SqlConfigurator sqlConfigurator)
	    throws IOException, SQLException {
	return sqlConfigurator.getMaxRowsToReturn();
    }

    /**
     * Return the result of encryptResultSet method of SqlConfigurator, if it's
     * implemented, else false.
     * 
     * @param sqlConfigurator
     *            the SqlConfigurator instance
     * @return the result of getMaxRowsToReturn of SqlConfigurator, if it's
     *         implemented, else fase;
     * 
     * @throws IOException
     * @throws SQLException
     */
    public static boolean encryptResultSet(SqlConfigurator sqlConfigurator)
	    throws IOException, SQLException {
	return sqlConfigurator.encryptResultSet();
    }

}