<commit_before><?php

/**
 Added by <NAME>.
Replaced all the MySQL queries with Oracle SPs. (ref: OAuthStoreSQL.php)
<EMAIL>

 * Storage container for the oauth credentials, both server and consumer side.
 * Based on Oracle
 * 
 
 * 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.



 */


require_once dirname(__FILE__) . '/OAuthStoreAbstract.class.php';

abstract class OAuthStoreOracle extends OAuthStoreAbstract {
    /**
     * Maximum delta a timestamp may be off from a previous timestamp.
     * Allows multiple consumers with some clock skew to work with the same token.
     * Unit is seconds, default max skew is 10 minutes.
     */
    protected $max_timestamp_skew = MAX_TIMESTAMP_SKEW;

    /**
     * Default ttl for request tokens
     */
    protected $max_request_token_ttl = MAX_REQUEST_TOKEN_TIME;


    /**
     * Construct the OAuthStoreMySQL.
     * In the options you have to supply either:
     * - server, username, password and database (for a mysql_connect)
     * - conn (for the connection to be used)
     *
     * @param array options
     */
    function __construct ( $options = array() ) {
        if (isset($options['conn'])) {
            $this->conn = $options['conn'];
        }
        else {
            $this->conn=oci_connect(DBUSER,DBPASSWORD,DBHOST);

            if ($this->conn === false) {
                throw new OAuthException2('Could not connect to database');
            }

            $this->query('set character set utf8');
        }
    }

	/**
	 * Find stored credentials for the consumer key and token. Used by an OAuth server
	 * when verifying an OAuth request.
	 * 
	 * @param string consumer_key
	 * @param string token
	 * @param string token_type		false, 'request' or 'access'
	 * @exception OAuthException2 when no secrets where found
	 * @return array	assoc (consumer_secret, token_secret, osr_id, ost_id, user_id)
	 */
	public function getSecretsForVerify ($consumer_key, $token, $token_type = 'access' ) {
            $sql = "BEGIN SP_GET_SECRETS_FOR_VERIFY(:P_CONSUMER_KEY, :P_TOKEN, :P_TOKEN_TYPE, :P_ROWS, :P_RESULT); END;";

            // parse sql
            $stmt = oci_parse($this->conn, $sql) or die ('Can not parse query');
            
            // Bind In and Out Variables
            oci_bind_by_name($stmt, ':P_CONSUMER_KEY', $consumer_key, 255);
            oci_bind_by_name($stmt, ':P_TOKEN', $token, 255);
            oci_bind_by_name($stmt, ':P_TOKEN_TYPE', $token_type, 255);
            oci_bind_by_name($stmt, ':P_RESULT', $result, 20);<commit_msg>Minor fixes.<commit_after><?php

/**
 * Added by <NAME>.
 * Replaced all the MySQL queries with Oracle SPs. (ref: OAuthStoreSQL.php)
 * <EMAIL>
 *
 * Storage container for the oauth credentials, both server and consumer side.
 * Based on Oracle
 *
 * @author <NAME> <<EMAIL>>
 * @date  Aug 6, 2010
 * 
 * The MIT License
 * 
 * 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.
 */

require_once dirname(__FILE__) . '/OAuthStoreAbstract.class.php';

abstract class OAuthStoreOracle extends OAuthStoreAbstract {
    /**
     * Maximum delta a timestamp may be off from a previous timestamp.
     * Allows multiple consumers with some clock skew to work with the same token.
     * Unit is seconds, default max skew is 10 minutes.
     */
    protected $max_timestamp_skew = MAX_TIMESTAMP_SKEW;

    /**
     * Default ttl for request tokens
     */
    protected $max_request_token_ttl = MAX_REQUEST_TOKEN_TIME;


    /**
     * Construct the OAuthStoreMySQL.
     * In the options you have to supply either:
     * - server, username, password and database (for a mysql_connect)
     * - conn (for the connection to be used)
     *
     * @param array options
     */
    function __construct ( $options = array() ) {
        if (isset($options['conn'])) {
            $this->conn = $options['conn'];
        }
        else {
            $this->conn=oci_connect(DBUSER,DBPASSWORD,DBHOST);

            if ($this->conn === false) {
                throw new OAuthException2('Could not connect to database');
            }

            // $this->query('set character set utf8');
        }
    }

	/**
	 * Find stored credentials for the consumer key and token. Used by an OAuth server
	 * when verifying an OAuth request.
	 * 
	 * @param string consumer_key
	 * @param string token
	 * @param string token_type		false, 'request' or 'access'
	 * @exception OAuthException2 when no secrets where found
	 * @return array	assoc (consumer_secret, token_secret, osr_id, ost_id, user_id)
	 */
	public function getSecretsForVerify ($consumer_key, $token, $token_type = 'access' ) {
            $sql = "BEGIN SP_GET_SECRETS_FOR_VERIFY(:P_CONSUMER_KEY, :P_TOKEN, :P_TOKEN_TYPE, :P_ROWS, :P_RESULT); END;";

            // parse sql
            $stmt = oci_parse($this->conn, $sql) or die ('Can not parse query');
            
            // Bind In and Out Variables
            oci_bind_by_name($stmt, ':P_CONSUMER_KEY', $consumer_key, 255);
            oci_bind_by_name($stmt, ':P_TOKEN', $token, 255);
            oci_bind_by_name($stmt, ':P_TOKEN_TYPE', $token_type, 255);
            oci_bind_by_name($stmt, ':P_RESULT', $result, 20);
{'fraction_non_alphanumeric': 0.09276520195295163, 'fraction_numerical': 0.0054741825713862996, 'mean_word_length': 2.9811542991755005, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4421050', 'n_tokens_mistral': 2017, 'n_tokens_neox': 1881, 'n_words': 724}