Changeset 100

Show
Ignore:
Timestamp:
08/06/07 23:08:06 (1 year ago)
Author:
pdingle
Message:

revamped infocard_identities table to add date information and a cardhash (no more ppid & modululs). Updated all the surrounding code. Algorithms for generating the cardhash and the card handle are placeholders.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-infocard/wp-infocard.php

    r77 r100  
    11<?php 
    22/* 
    3 Plugin Name: Information Card Login 
    4 Plugin URI: http://pamelaproject.com/wp-infocard 
     3Plugin Name: PamelaWare Information Card Login 
     4Plugin URI: http://code.pamelaproject.com/wiki/PWwordpress 
    55Description: This plugin adds functionality to register and login with "information cards", part of the Identity Metasystem web services framework.  Once it is activated, go to the "Options" menu and click on "Information Card Options" to see what to do next. 
    6 Version: b2 
    7 Author: K. Cameron, P. Dingle 
    8 Author URI: http://www.pamelaproject.com/wp-infocard/contributors 
     6Version: b3 
     7Author: K. Cameron, P. Dingle, and more 
     8Author URI: https://pamelaproject.com/svn/pw/pwcommon/legal/CONTRIBUTORS 
    99*/ 
    1010include_once( dirname(__FILE__) . '/pw-config.php' ); 
  • trunk/wp-infocard/wp/admin.pw.php

    r87 r100  
    33include_once( dirname(__FILE__) . '/../pw-config.php'); 
    44include_once( dirname(__FILE__) . '/../pwlib/admin.pwlib.php'); 
     5include_once( dirname(__FILE__) . '/processing.pw.php'); 
    56//require_once( ABSPATH . WPINC . '/registration-functions.php'); 
    67/* 
     
    9697            global $wpdb; 
    9798 
     99                /* -- old format 
    98100                $myTableIdentityQuery = 
    99101                        "CREATE TABLE `$this->table_identity` ( 
     
    101103                                `ppid` varchar(128) NOT NULL default '', 
    102104                                `accountid` bigint(20) unsigned 
     105                        ) ENGINE = MYISAM"; 
     106                */ 
     107                $myTableIdentityQuery = 
     108                        "CREATE TABLE `$this->table_identity` ( 
     109                                `cardhash` text default '', 
     110                                `accountid` bigint(20) unsigned, 
     111                                `cardhandle` varchar(128) NOT NULL default '', 
     112                                `startdate` varchar(128) NOT NULL default '', 
     113                                `lastused` varchar(128) NOT NULL default '' 
    103114                        ) ENGINE = MYISAM"; 
    104115 
     
    256267                global $current_user; 
    257268 
    258                 $ppid = pw_userdata::getUserPPID( $current_user->ID ); 
    259  
    260                 if ( $ppid ) 
     269                $cardcount = pw_processing::getUserCardCount( $current_user->ID ); 
     270                $handle = pw_processing::getCardHandle( $current_user->ID ); 
     271 
     272                if ( $cardcount > 0 ) 
    261273                { 
    262274?> 
    263275                        <p> 
    264                                 <img src="<?php echo PW_IMGURL; ?>/ic-logo/ic-logo-blue-icon.png"/> <?php pw_utils::screenPrint('Information Card ID: '); ?> 
     276                                <img src="<?php echo PW_IMGURL; ?>/ic-logo/ic-logo-blue-icon.png"/> <?php pw_utils::screenPrint('Information Card ID: ' . $handle); ?> 
    265277                        </p> 
    266278 
  • trunk/wp-infocard/wp/audit.pw.php

    r69 r100  
    2222                 
    2323                $today = date('Y-m-d H-i-s'); 
    24                 $query = "INSERT INTO `wp_infocard_audit` " 
     24                $query = "INSERT INTO `" . PW_TABLE_PREFIX . "infocard_audit` " 
    2525                . "(`modulusHash`, `ppid`, `accountid`, `email`,`time`,`IP`,`status`) " 
    2626                . "VALUES ('$modulus', '$ppid', '$acct', '$email','$today','$ip','$error')"; 
  • trunk/wp-infocard/wp/processing.pw.php

    r98 r100  
    4747 
    4848        } // end function showProcessingSummary 
    49          
     49 
    5050} // end class pw_processing 
    5151?> 
  • trunk/wp-infocard/wp/pw-claimtypes.php

    r98 r100  
    102102        'return $' . 'claimslist[\'webpage\']->token_value;'); 
    103103 
     104$datamap['cardhash'] = new pw_mapping( 
     105        'Card Hash', 
     106        'cardhash', 
     107        PW_TABLE_PREFIX . 'infocard_identities', 
     108        'return pw_processing::getCardHash();', 
     109        'Calculates a card hash from the PPID and the issuer modulus'); 
     110 
     111$datamap['cardhandle'] = new pw_mapping( 
     112        'Card Handle', 
     113        'cardhandle', 
     114        PW_TABLE_PREFIX . 'infocard_identities', 
     115        'return pw_processing::calculateCardHandle();', 
     116        'Calculates a card handle from the PPID and the issuer modulus'); 
     117 
    104118// Map any custom claims 
    105119if ( PW_CUSTOM_DATA ) 
  • trunk/wp-infocard/wp/userdata.pw.php

    r98 r100  
    1414class pw_userdata  
    1515{ 
    16  
    17         // Function:  evaluateIncomingRequest 
    18         // Description: decides what kind of user is connecting. 
    19         // Input: email, modulus, ppid from incoming request 
    20         // Output: An array of user information. With the 
    21         //      following indices: 
    22         //      array['status'] - contains 1 of these statuses: 
    23         //      1. valid-user - supplied email address exists 
    24         //           and belongs to same user as supplied modulus/ppid 
    25         //      2. new-user - email address & modulus/ppid are new 
    26         //      3. new-card - email address exists but modulus is new 
    27         //      4. new-email - modulus/ppid exists but email is new 
    28         //      5. an error code 
    29         // 
    30         //      array['id'] - contains the user id number (or 0 if the status  
    31         //            is anything other than valid-user 
    32         // Side-effects: none 
    33  
     16        /* 
     17               Function:  evaluateIncomingRequest 
     18               Description: decides what kind of user is connecting. 
     19               Input: email, modulus, ppid from incoming request 
     20               Output: An array of user information. With the 
     21                       following indices: 
     22                       array['status'] - contains 1 of these statuses: 
     23                       1. valid-user - supplied email address exists 
     24                       and belongs to same user as supplied modulus/ppid 
     25                       2. new-user - email address & modulus/ppid are new 
     26                       3. new-card - email address exists but modulus is new 
     27                       4. new-email - modulus/ppid exists but email is new 
     28                       5. an error code 
     29         
     30                       array['id'] - contains the user id number (or 0 if the status  
     31                      is anything other than valid-user 
     32               Side-effects: none 
     33        */ 
    3434        function evaluateIncomingRequest() 
    3535        { 
     
    3939                $identity_user_id = 0; 
    4040 
     41                $cardhash = pw_processing::getCardHash(); 
    4142                pw_utils::printDebug( '<br/>Evaluating Incoming Request:<br/>'); 
    4243 
     
    4546                        return $incominguser; 
    4647                } 
    47  
     48                 
    4849                $query = "SELECT * FROM `" . PW_TABLE_PREFIX  
    49                 . "infocard_identities` WHERE modulusHash = '" 
    50                         . substr_replace($claimslist['signerkeymodulus']->token_value, '', 128, -1) 
    51                         . "' AND ppid = '" 
    52                         . $claimslist['privatepersonalidentifier']->token_value 
    53                         . "'"; 
    54                 pw_utils::printDebug($query); 
     50                . "infocard_identities` WHERE cardhash = '" 
     51                        . $cardhash . "'"; 
    5552                $identity_info = $wpdb->get_results( $query, OBJECT ); 
    5653 
     
    6057                                // could be valid-user, or new-email 
    6158                                $identity_user_id = $identity_info[0]->accountid; 
    62                                  $datamap['modulusHash']->add_db_value($identity_info[0]->modulusHash); 
    63                                                                  $datamap['privatepersonalidentifier']->add_db_value($identity_info[0]->ppid); 
    64  
     59                                 $datamap['cardhash']->add_db_value($identity_info[0]->cardhash); 
    6560                        break; 
    6661 
     
    294289        // Output: none 
    295290        // Side effect: modifies table data 
    296         function updateIdentityData( $acct, $modulus, $ppid
     291        function updateIdentityData( $datamap
    297292        { 
    298293                global $wpdb; 
    299                  
    300                 $query = "SELECT * FROM wp_infocard_identities WHERE (ppid = '$ppid' " 
    301                 . "AND modulusHash = '$modulus') OR (accountid = '$acct')"; 
     294                $acct = $datamap['ID']->new_value; 
     295                $cardhash = $datamap['cardhash']->new_value; 
     296                $cardhandle =  $datamap['cardhandle']->new_value; 
     297                $today = date('Y-m-d H-i-s'); 
     298 
     299                //$query = "SELECT * FROM wp_infocard_identities WHERE (ppid = '$ppid' " 
     300                //. "AND modulusHash = '$modulus') OR (accountid = '$acct')"; 
     301 
     302                $query = "SELECT * FROM wp_infocard_identities WHERE cardHash = '$cardhash' " 
     303                . "OR accountid = '$acct'"; 
     304 
     305                pw_utils::printDebug($query); 
    302306                 
    303307                $results = $wpdb->get_results( $query, OBJECT ); 
     
    307311                { 
    308312                        case 0: 
     313                                // first card used for this account 
    309314                                pw_utils::printDebug( '&nbsp; New Entry<br/>' ); 
    310315                                $query = "INSERT INTO `wp_infocard_identities` " 
    311                                         . "( modulusHash, ppid, accountid ) VALUES " 
    312                                         . "( '$modulus', '$ppid', '$acct' )"; 
     316                                        . "( cardhash, cardhandle, accountid, startdate, lastused ) VALUES " 
     317                                        . "( '$cardhash', '$cardhandle', '$acct', '$today', '$today' )"; 
    313318                                $wpdb->query( $query ); 
    314319                        break; 
     
    317322                                if (!pw_utils::dataCompare($results[0]->accountid, $acct, 'Account ID'))  
    318323                                { 
    319                                         pw_utils::printDebug( '&nbsp; PPID/Modulus used for another account<br/>' );   
     324                                        pw_utils::printDebug( '&nbsp; Card used for another account<br/>' );   
    320325                                        return 'CARDINUSE'; 
    321326                         
    322327                                }  
    323                                 if ( (!pw_utils::dataCompare( $results[0]->modulusHash, $modulus, 'Modulus'))  
    324                                        || ( !pw_utils::dataCompare( $results[0]->ppid, $ppid, 'PPID' ))) 
     328 
     329                                if (!pw_utils::dataCompare( $results[0]->cardhash, $cardhash, 'Card Hash'))  
    325330                                {        
    326331                                        $query = "UPDATE `wp_infocard_identities` SET " 
    327                                         . "modulusHash  = '$modulus', ppid = '$ppid' " 
    328                                         . "WHERE accountid = '$acct'"; 
     332                                        . "cardhash  = '$cardhash', startdate = '$today', " 
     333                                        . "cardhandle  = '$cardhandle', " 
     334                                        . "lastused = '$today' WHERE accountid = '$acct'"; 
    329335                                        $wpdb->query( $query ); 
    330336                                        pw_utils::printDebug( '&nbsp; Updated Existing Entry<br/>' ); 
     
    346352        } // end function updateIdentityData 
    347353 
    348         function getUserPPID( $acct ) 
    349         { 
    350                 global $wpdb; 
    351                  
    352                 $query = "SELECT ppid FROM " . PW_TABLE_PREFIX . "infocard_identities WHERE accountid = '$acct' "; 
    353                  
    354                 return $wpdb->get_var( $query ); 
    355  
    356         } //end function getUserPPID 
    357          
    358354        /* 
    359355                Function:       Perform user login functions