initial import
commit
743f6ce8fd
@ -0,0 +1,5 @@
|
||||
~$
|
||||
\.DS_Store$
|
||||
sftp-config\.json$
|
||||
\.sublime-workspace$
|
||||
\.sublime-project$
|
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
function fulcrm_crypto_admin_form_submit( $form, &$form_state ) {
|
||||
}
|
||||
|
||||
function fulcrm_crypto_admin_form( $form, &$form_state ) {
|
||||
$form[ 'title' ] = array( '#type' => 'item',
|
||||
'#title' => 'fulcrm Cryptography Settings',
|
||||
'#description' => '',
|
||||
);
|
||||
|
||||
$form[ 'actions' ] = array( '#type' => 'actions' );
|
||||
$form[ 'actions' ][ 'save' ] = array( '#type' => 'submit',
|
||||
'#value' => t('Save'),
|
||||
'#submit' => array( 'fulcrm_crypto_admin_form_submit' ),
|
||||
);
|
||||
return $form;
|
||||
}
|
||||
|
||||
function fulcrm_crypto_admin() {
|
||||
return drupal_get_form( 'fulcrm_crypto_admin_form' );
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
name = fulcrm cryptography
|
||||
description = fulcrm cryptography
|
||||
core = 7.x
|
||||
package = fulcrm
|
||||
;files[] = fulcrm_crypto.admin.inc
|
||||
configure = admin/config/services/fulcrm/crypto
|
@ -0,0 +1 @@
|
||||
<?php /* -*- php -*- */
|
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
function fulcrm_crypto_permission() {
|
||||
return array( 'administer fulcrm crypto' => array( 'title' => t('Administer fulcrm cryptography'),
|
||||
'description' => t('Perform main installation/administration tasks for fulcrm cryptography.'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
function fulcrm_crypto_menu() {
|
||||
/*
|
||||
$items[ 'admin/config/services/fulcrm' ] = array( 'page callback' => 'system_admin_menu_block_page',
|
||||
'file' => 'system.admin.inc',
|
||||
'file path' => drupal_get_path('module', 'system'),
|
||||
'title' => 'fulcrm',
|
||||
'description' => 'Configuration integration with fulcrm.org.',
|
||||
'position' => 'right',
|
||||
'access callback' => 'user_access',
|
||||
'access arguments' => array('access administration pages'),
|
||||
);
|
||||
*/
|
||||
$items[ 'admin/config/services/fulcrm/crypto' ] = array( 'page callback' => 'fulcrm_crypto_admin',
|
||||
'file' => 'fulcrm_crypto.admin.inc',
|
||||
'title' => 'fulcrm cryptography',
|
||||
'description' => 'Settings for fulcrm.org cryptography.',
|
||||
'access callback' => 'user_access',
|
||||
'access arguments' => array('administer fulcrm crypto'),
|
||||
);
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
function fulcrm_crypto_object_id_hmac( $object_type, $object_id ) {
|
||||
return drupal_hmac_base64( 'fulcrm:' . strval( $object_id ) . ':' . $object_type, session_id() . drupal_get_hash_salt() );
|
||||
}
|
||||
|
||||
function fulcrm_crypto_object_id_form_value( $object_type, $object_id ) {
|
||||
return $object_id . ':' . fulcrm_crypto_object_id_hmac( $object_type, $object_id );
|
||||
}
|
||||
|
||||
function fulcrm_crypto_get_object_id_form_value( $object_type, $form_value ) {
|
||||
$bits = explode( ':', $form_value );
|
||||
if ( count( $bits ) == 2 ) {
|
||||
$object_id = $bits[ 0 ];
|
||||
$hmac = $bits[ 1 ];
|
||||
$real_hmac = fulcrm_crypto_object_id_hmac( $object_type, $object_id );
|
||||
|
||||
if ( hash_equals( $real_hmac, $hmac ) )
|
||||
return $object_id;
|
||||
}
|
||||
return NULL;
|
||||
}
|
Loading…
Reference in New Issue