home | career | drupal | java | mac | mysql | perl | php | scala | uml | unix

Drupal example source code file (openid.install)

This example Drupal source code file (openid.install) is included in the DevDaily.com "Drupal Source Code Warehouse" project. The intent of this project is to help you "Learn Drupal by Example".

PHP - Drupal tags/keywords

255, array, association, description, function, length, of, openid, php, the, type, url, varchar

The openid.install Drupal example source code

<?php
// $Id: openid.install,v 1.13 2011/01/02 17:26:39 webchick Exp $

/**
 * @file
 * Install, update and uninstall functions for the openid module.
 */

/**
 * Implements hook_schema().
 */
function openid_schema() {
  $schema['openid_association'] = array(
    'description' => 'Stores temporary shared key association information for OpenID authentication.',
    'fields' => array(
      'idp_endpoint_uri' => array(
        'type' => 'varchar',
        'length' => 255,
        'description' => 'URI of the OpenID Provider endpoint.',
      ),
      'assoc_handle' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'description' => 'Primary Key: Used to refer to this association in subsequent messages.',
      ),
      'assoc_type' => array(
        'type' => 'varchar',
        'length' => 32,
        'description' => 'The signature algorithm used: one of HMAC-SHA1 or HMAC-SHA256.',
      ),
      'session_type' => array(
        'type' => 'varchar',
        'length' => 32,
        'description' => 'Valid association session types: "no-encryption", "DH-SHA1", and "DH-SHA256".',
      ),
      'mac_key' => array(
        'type' => 'varchar',
        'length' => 255,
        'description' => 'The MAC key (shared secret) for this association.',
      ),
      'created' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'UNIX timestamp for when the association was created.',
      ),
      'expires_in' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'The lifetime, in seconds, of this association.',
      ),
    ),
    'primary key' => array('assoc_handle'),
  );

  $schema['openid_nonce'] = array(
    'description' => 'Stores received openid.response_nonce per OpenID endpoint URL to prevent replay attacks.',
    'fields' => array(
      'idp_endpoint_uri' => array(
        'type' => 'varchar',
        'length' => 255,
        'description' => 'URI of the OpenID Provider endpoint.',
      ),
      'nonce' => array(
        'type' => 'varchar',
        'length' => 255,
        'description' => 'The value of openid.response_nonce.',
      ),
      'expires' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'A Unix timestamp indicating when the entry should expire.',
      ),
    ),
    'indexes' => array(
      'nonce' => array('nonce'),
      'expires' => array('expires'),
    ),
  );

  return $schema;
}

/**
 * Implements hook_requirements().
 */
function openid_requirements($phase) {
  $requirements = array();

  if ($phase == 'runtime') {
    // Check for the PHP BC Math library.
    if (!function_exists('bcadd')) {
      $requirements['bcmath'] = array(
        'value' => t('Not installed'),
        'severity' => REQUIREMENT_ERROR,
        'description' => t('OpenID requires the BC Math library for PHP which is missing or outdated. Check the <a href="@url">PHP BC Math Library documentation</a> for information on how to correct this.', array('@url' => 'http://www.php.net/manual/en/book.bc.php')),
      );
    }
    else {
      $requirements['bcmath'] = array(
        'value' => t('Installed'),
        'severity' => REQUIREMENT_OK,
      );
    }
    $requirements['bcmath']['title'] = t('BC Math library');
  }

  return $requirements;
}

/**
 * @addtogroup updates-6.x-to-7.x
 * @{
 */

/**
 * Add a table to store nonces.
 */
function openid_update_6000() {
  $schema['openid_nonce'] = array(
    'description' => 'Stores received openid.response_nonce per OpenID endpoint URL to prevent replay attacks.',
    'fields' => array(
      'idp_endpoint_uri' => array(
        'type' => 'varchar',
        'length' => 255,
        'description' => 'URI of the OpenID Provider endpoint.',
      ),
      'nonce' => array(
        'type' => 'varchar',
        'length' => 255,
        'description' => 'The value of openid.response_nonce'
        ),
      'expires' => array(
        'type' => 'int',
        'not null' => TRUE,
        'default' => 0,
        'description' => 'A Unix timestamp indicating when the entry should expire.',
        ),
      ),
    'indexes' => array(
      'nonce' => array('nonce'),
      'expires' => array('expires'),
    ),
  );

  db_create_table('openid_nonce', $schema['openid_nonce']);
}

/**
 * @} End of "addtogroup updates-6.x-to-7.x"
 */

Other Drupal examples (source code examples)

Here is a short list of links related to this Drupal openid.install source code file:

new blog posts

"Drupal" is a registered trademark of Dries Buytaert.

my drupal tutorials and examples  

Copyright 1998-2016 Alvin Alexander, alvinalexander.com
All Rights Reserved.

Beginning in 2016, a portion of the proceeds from pages under the '/drupal-code-examples/' URI will be donated to charity.