Changeset 30

Show
Ignore:
Timestamp:
04/04/07 13:19:27 (2 years ago)
Author:
pdingle
Message:

More big changes

Files:

Legend:

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

    r29 r30  
    166166        } // end function describeGivenCert 
    167167 
    168         function verifyTimeWindow (){ 
    169  
    170                 // Verify that the token is being processed within the time window 
    171                 // specified by the Identity Provider (we could further restrict this) 
    172                 $currentTime = mktime() + PW_VALIDITY_WINDOW; 
    173                 $adjustedTimeText = substr(gmdate("c",$currentTime), 0, 19)."Z"; 
    174                 if ($adjustedTimeText < $NotBefore){ 
    175                         InfocardGeneral::errorPageRedirect('TIMEAHEAD'); 
    176                         //$error = "Adjusted current time ($adjustedTimeText) is too far ahead of the start of the validity window ($NotBefore)"; 
    177                         break; 
    178                 } 
    179  
    180                 $currentTime = mktime() - PW_VALIDITY_WINDOW; 
    181                 $adjustedTimeText = substr(gmdate("c",$currentTime), 0, 19)."Z"; 
    182                 if ($adjustedTimeText > $NotOnOrAfter){ 
    183                         InfocardGeneral::errorPageRedirect('TIMEBEHIND'); 
    184                         //$error = "Adjusted current time ($adjustedTimeText) is after the end of validity window ($NotOnOrAfter)"; 
    185                         break; 
    186                 } 
    187         } // end function verifyTimeWindow 
    188  
    189         function printUserMessage( $mesg_type, $lang='en-us' ){ 
    190                 $message_file = bloginfo('home') . PW_PLUGINPATH . "/site-messages/$lang" . "/$mesg_type.html"; 
    191  
    192                 if ( file_exists( $message_file ) ) { 
    193                         include_once( $message_file ); 
    194                 } else { 
    195                         InfocardGeneral::errorPageRedirect('BADMESSAGE'); 
    196                 } 
    197         } 
    198168 
    199169        function printDebug( $content ) { 
  • trunk/wp-infocard/processing/class.infocard-processing.php

    r29 r30  
    44include_once("infocard-print-binary.php"); 
    55require_once( ABSPATH . WPINC . '/registration-functions.php'); 
     6include_once(dirname(__FILE__) . "/../pw-config.php"); 
     7include_once(dirname(__FILE__) . "/../" . PW_PLUGIN . "/userdata.pw.php"); 
     8include_once(dirname(__FILE__) . "/../" . PW_PLUGIN . "/utils.pw.php"); 
    69 
    710class InfocardProcessing { 
     
    3134                $identity_user_id = 0; 
    3235 
     36                InfocardUtils::printDebug( '<br/>Evaluating Incoming Request:<br/>'); 
     37 
    3338                if (!is_email($email)) { 
    3439                        $incominguser['status'] = "INVALIDEMAIL"; 
     
    3742 
    3843                //$sql = "SELECT user_id FROM wp_usermeta WHERE meta_key LIKE 'identity' AND meta_value LIKE '$modulusHash'";    
    39                 $sql = "SELECT a.user_id, a.meta_value as identity, " 
    40                 . "b.meta_value as ppid FROM wp_usermeta a, " 
    41                 . "wp_usermeta b WHERE a.meta_key = 'identity' " 
    42                 . "AND b.meta_key = 'ppid' AND a.meta_value LIKE '" 
    43                 . $modulusHash . "' AND b.meta_value LIKE '" 
    44                 . $ppid . "' AND a.user_id = b.user_id"; 
    45                 InfocardUtils::printDebug($sql); 
    46                 $identity_user_id = $wpdb->get_var( $sql); 
     44                //$sql = "SELECT a.user_id, a.meta_value as identity, " 
     45                //. "b.meta_value as ppid FROM wp_usermeta a, " 
     46                //. "wp_usermeta b WHERE a.meta_key = 'identity' " 
     47                //. "AND b.meta_key = 'ppid' AND a.meta_value LIKE '" 
     48                //. $modulusHash . "' AND b.meta_value LIKE '" 
     49                //. $ppid . "' AND a.user_id = b.user_id"; 
     50                 
     51                $query = "SELECT * FROM `wp_infocard_identities` WHERE modulusHash = '$modulusHash' " 
     52                        . "AND ppid = '$ppid'"; 
     53                $identity_info = $wpdb->get_results( $query, OBJECT ); 
     54                if (count($identity_info) == 1) 
     55                        $identity_user_id = $identity_info[0]->accountid; 
     56 
     57                pw_utils::printDebug('Identity_user_id: ' . $identity_user_id );         
    4758                 
    4859                $mail_user_id = 0; 
     
    105116        } // end of function evaluateIncomingRequest 
    106117 
    107         function createNewAccount( $user_login, $user_pass, $user_email, $user_nicename, $user_url, $user_firstname, $user_lastname ) { 
    108  
    109                 InfocardUtils::printDebug("<br/>Action: createNewAccount<br>"); 
    110                 $display_name = $user_nicename; 
    111                 $userdata = compact('user_login', 'user_pass', 'user_email', 'user_nicename', 'user_url', 'display_name', 'user_firstname', 'user_lastname'); 
    112                 $user_ID = wp_insert_user($userdata); 
    113  
    114                 if ($user_ID) { 
    115                         InfocardUtils::printDebug("&nbsp;Inserted record # $user_ID<br>"); 
    116                         return $user_ID; 
    117                 } else { 
    118                         InfocardUtils::printDebug("&nbsp;Error - new user not created<br/>"); 
    119                         return FALSE; 
    120                 } 
    121  
    122         } // end function createNewAccount 
    123118 
    124119        function sendAccountValidation( $clickbackID, $user_email, $relocationUrl ) { 
     
    132127                //      Message, you would customize this function. 
    133128 
    134                 $clickbackUrl = PW_PLUGINURL     
    135                         . "/login/infocard-clickback.php?" . $clickbackID; 
     129                $clickbackUrl = PW_PLUGINURL . "/login/infocard-clickback.php?" . $clickbackID; 
    136130 
    137131                $message  = sprintf(__('Please complete your registration at %s by opening the link below.'), get_settings('blogname')) . "\r\n\r\n"; 
     
    142136                InfocardUtils::printDebug( "<br/><br/>Account Validation is required.<br/>" 
    143137                        . "Emailing Registration info to: $user_email<br/>" 
    144                         . "User would be redirected to:  <a href=\"$relocationUrl\">$relocationUrl</a><br/>" 
     138                        . "User would be redirected to:  <a href=\"$clickbackUrl\">$clickbackUrl</a><br/>" 
    145139                        . "Message would be:  <pre>$message</pre>" 
    146140                ); 
    147141          
    148142        } // end of function sendAccountValidation 
    149  
    150         function dataCompare($db_item, $token_item, $item_name) 
    151         // Function:    dataCompare 
    152         // Purpose:     to compare the value of a given piece of user data between 
    153         //              what came from the database and what was supplied in the token. 
    154         { 
    155                 if (strcmp($db_item, $token_item) == 0)  
    156                 { 
    157                         Infocardutils::printDebug("&nbsp; $item_name: matches ($db_item)<br/>");  
    158                         return (TRUE); 
    159                 } 
    160                 else 
    161                 {  
    162                         Infocardutils::printDebug("&nbsp; $item_name:&nbsp;DB: $db_item &nbsp;&nbsp;TOKEN: $token_item<br/>");  
    163                         return (FALSE); 
    164                 }  
    165         } //end function dataCompare 
    166143 
    167144        function updateUserData( $ID, $user_login, $user_pass, $user_email, $user_nicename, $user_url, $display_name, $first_name, $last_name, $nickname, $user_ppid )  
     
    207184                        else 
    208185                        { 
    209                                 InfocardProcessing::dataCompare($user_row['user_email'], $user_email, 'Email'); 
    210                                 InfocardProcessing::dataCompare($user_row['user_pass'], MD5($user_pass), 'Password'); 
    211                                 InfocardProcessing::dataCompare($user_row['user_nicename'], $user_nicename, 'NiceName'); 
    212                                 InfocardProcessing::dataCompare($user_row['user_url'], $user_url, 'WebPage'); 
    213                                 InfocardProcessing::dataCompare($user_row['display_name'], $display_name, 'DisplayName'); 
    214                                 InfocardProcessing::dataCompare($user_row['first_name'], $first_name, 'FirstName'); 
    215                                 InfocardProcessing::dataCompare($user_row['last_name'], $last_name, 'LastName'); 
    216                                 InfocardProcessing::dataCompare($user_row['nickname'], $nickname, 'Meta-Nickname'); 
     186                                pw_utils::dataCompare($user_row['user_email'], $user_email, 'Email'); 
     187                                pw_utils::dataCompare($user_row['user_pass'], MD5($user_pass), 'Password'); 
     188                                pw_utils::dataCompare($user_row['user_nicename'], $user_nicename, 'NiceName'); 
     189                                pw_utils::dataCompare($user_row['user_url'], $user_url, 'WebPage'); 
     190                                pw_utils::dataCompare($user_row['display_name'], $display_name, 'DisplayName'); 
     191                                pw_utils::dataCompare($user_row['first_name'], $first_name, 'FirstName'); 
     192                                pw_utils::dataCompare($user_row['last_name'], $last_name, 'LastName'); 
     193                                pw_utils::dataCompare($user_row['nickname'], $nickname, 'Meta-Nickname'); 
    217194                        } 
    218195                } 
     
    223200 
    224201                // Take care of the items that wp_update_user doesn't handle 
    225  
    226                 if ( InfocardProcessing::dataCompare($extra_data['identity'], $user_pass, 'Identity') == FALSE ) 
     202                pw_userdata::updateIdentityData($ID, $user_pass, $user_ppid); 
     203 
     204                if ( pw_utils::dataCompare($extra_data['identity'], $user_pass, 'Identity') == FALSE ) 
    227205                { 
    228206                        InfocardUtils::printDebug ( '&nbsp;Updating Card Identifier<br/>' ); 
     
    230208                } 
    231209 
    232                 if ( InfocardProcessing::dataCompare($extra_data['ppid'], $user_ppid, 'PPID') == FALSE ) 
     210                if ( pw_utils::dataCompare($extra_data['ppid'], $user_ppid, 'PPID') == FALSE ) 
    233211                { 
    234212                        InfocardUtils::printDebug ( '&nbsp;Updating PPID<br/>' ); 
     
    236214                } 
    237215 
    238                 if ( InfocardProcessing::dataCompare($extra_data['user_login'], $user_login, 'LoginID') == FALSE ) 
     216                if ( pw_utils::dataCompare($extra_data['user_login'], $user_login, 'LoginID') == FALSE ) 
    239217                { 
    240218                        // no WP function to update LoginID because it is never 
     
    251229        } // end function updateUserData 
    252230 
    253         function writeToAudit( $ip, $modulus, $email, $error) { 
    254                 //  writeToAudit puts information into the infocard_audit table 
    255                 //  in mySQL.  Currently this function opens its own database  
    256                 //  connections (that's how Kim wrote it) but it would be nice 
    257                 //  to leverage the already open connection. 
    258  
    259                         // set up the SQL connection 
    260                 $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) or die('Could not connect: ' . mysql_error()); 
    261  
    262                 mysql_select_db(DB_NAME) or die('Could not select database'); 
    263  
    264                 if ($link) 
    265                 { 
    266                         $today = date('Y-m-d H-i-s'); 
    267                         $sql = "INSERT INTO `infocard_audit` "  
    268                         . "(`modulusHash`,`email`,`time`,`IP`,`status`) " 
    269                         . "VALUES ('$modulus','$email','$today','$ip','$error')"; 
    270                         if (mysql_query( $sql , $link) == FALSE){ 
    271                                 InfocardUtils::printDebug("Error ".mysql_errno($link)."with mysql_query update (".mysql_error($link).")<br/>"); 
    272                         } 
    273                         mysql_close($link); 
    274                 } 
    275          
    276         } // end function writeToAudit 
    277231 
    278232        function setLoginCookies( $user_login, $user_pass, $user_nicename, $user_email, $user_url ) { 
     
    298252        function createChallenge( $data ) { 
    299253                //$clickback_salt = get_settings('clickback_salt'); 
    300                 $clickback_salt = pw_attributes::get_attr('pw_clickback_salt'); 
     254                $clickback_salt = pw_admin::getOption('pw_clickback_salt'); 
    301255 
    302256                InfocardUtils::printDebug("Clickback: Challenge Created. <br/>" 
  • trunk/wp-infocard/processing/infocard-post-decrypt.php

    r29 r30  
    2121do { 
    2222 
    23     $private_key_cipher = pw_attributes::get_attr('infocard_key'); 
    24     $private_key_passphrase = pw_attributes::get_attr('pw_infocard_opener'); 
     23    $private_key_cipher = pw_admin::getOption('pw_infocard_key'); 
     24    $private_key_passphrase = pw_admin::getOption('pw_infocard_opener'); 
    2525    if ($private_key_cipher == NULL) 
    2626    { 
  • trunk/wp-infocard/processing/infocard-post-get-claims.php

    r29 r30  
    33include_once("infocard-pkey-get-public.php"); 
    44include_once( dirname(__FILE__) . "/../class.infocard-basic.php"); 
     5include_once( dirname(__FILE__) . "/../pw-config.php"); 
     6include_once( dirname(__FILE__) . "/../" . PW_PLUGIN . "/utils.pw.php"); 
    57 
    68define("INFO_IGNORE",          0); 
     
    138140        // Verify that the token is being processed within the time window 
    139141        // specified by the Identity Provider (we could further restrict this) 
    140         $realTime = mktime(); 
    141  
    142         $realTimeText = substr(gmdate("c",$realTime), 0, 19)."Z"; 
    143         InfocardUtils::printDebug("&nbsp;Current RP Server Time: $realTimeText<br/>"  ); 
    144         $currentTime = $realTime + PW_VALIDITY_WINDOW; 
    145         $adjustedTimeText = substr(gmdate("c",$currentTime), 0, 19)."Z"; 
    146         if ($adjustedTimeText < $NotBefore){ 
    147             $error = "Adjusted current time ($adjustedTimeText) is too far ahead of the start of the validity window ($NotBefore). Margin of error: " . PW_VALIDITY_WINDOW . " seconds."; 
    148             break; 
    149         } 
    150  
    151         $currentTime = mktime() - ID_VALIDITY_WINDOW; 
    152         $adjustedTimeText = substr(gmdate("c",$currentTime), 0, 19)."Z"; 
    153         if ($adjustedTimeText > $NotOnOrAfter){ 
    154             $error = "Adjusted current time ($adjustedTimeText) is after 
    155 the end of validity window ($NotOnOrAfter). Margin of error: " . PW_VALIDITY_WINDOW . " seconds."; 
    156             break; 
    157         } 
     142        $error_detail = pw_utils::checkTimeAhead( $NotBefore ); 
     143 
     144        if ($error_detail) 
     145        { 
     146                $error="TIMEAHEAD"; 
     147                break; 
     148        } 
     149 
     150        $error_detail = pw_utils::checkTimeBehind( $NotOnOrAfter ); 
     151 
     152        if ($error_detail) 
     153        { 
     154                $error="TIMEBEHIND"; 
     155                break; 
     156        } 
    158157 
    159158        // Make sure assertion id has not been used before within the window 
  • trunk/wp-infocard/processing/infocard-post.php

    r29 r30  
    88include_once("infocard-post-get-claims.php"); 
    99include_once("class.infocard-processing.php"); 
     10include_once( dirname(__FILE__) . "/../pw-config.php"); 
     11include_once( dirname(__FILE__) . "/../" . PW_PLUGIN . "/admin.pw.php"); 
     12include_once( dirname(__FILE__) . "/../" . PW_PLUGIN . "/audit.pw.php"); 
    1013if (version_compare($wp_version, '2.1', '>=')) 
    1114{ 
     
    135138 
    136139                        // 
    137                         // note that a user only evaluates to "new-user" the first  
    138                         // time they come through.  When they come through for the 
    139                         // clickback, they evaluate as new-card. 
     140                        // note that a user only evaluates to "new-user" the  
     141                        // first time they come through.  When they come  
     142                        // through for the clickback, they evaluate as new-card. 
    140143                        // 
    141144                        $accountValidationRequired = TRUE; 
    142145                        $relocationUrl = PW_SITEMESGURL . '?new-user';  
    143146 
    144                         $user_ID = InfocardProcessing::createNewAccount($user_email, $modulusHash, $user_email, $user_nicename, $user_url, $user_firstname, $user_lastname ); 
     147                        $user_ID = pw_admin::createNewAccount($user_email, $modulusHash, $user_email, $user_url, $user_firstname, $user_lastname ); 
    145148                        if (!$user_ID)  
    146149                        { 
     
    206209    } while (0); 
    207210 
    208     InfocardProcessing::writeToAudit( $_SERVER['REMOTE_ADDR'], $pass2rounds, $user_email, $error ); 
     211    pw_audit::writeToAudit( $_SERVER['REMOTE_ADDR'], $pass2rounds, $user_ppid, $user_email, $error, $user_ID ); 
    209212 
    210213    if (strlen($error) > 0) 
  • trunk/wp-infocard/wp-infocard.php

    r29 r30  
    1717} 
    1818 
    19 $wpInfocard = new pw_admin(); 
     19$wpInfocard = new pw_infocard(); 
    2020 
    2121// Define when we want to run the tracking: on shutdown (see wordpress codex) 
     
    3939 
    4040                add_action('admin_menu', 'infocard_admin_menu'); 
    41  
    42                 function checklist_icon( $value ){ 
    43                         if ($value) { 
    44                                 return IC_IMGURL . "/yes.gif"; 
    45                         } else { 
    46                                 return IC_IMGURL . "/no.gif"; 
    47                         } 
    48                 } 
    4941 
    5042 
     
    8981                                <?php _e('PHP Version 5 or greater installed', 'wp-infocard'); ?> 
    9082                        </td><td valign="bottom">&nbsp; 
    91                                 <img src="<?php print checklist_icon(version_compare(phpversion(), '5.0', '>=')); ?>"/>                                 
     83                                <img src="<?php print pw_admin::checklist_icon(version_compare(phpversion(), '5.0', '>=')); ?>"/>                                 
    9284                                 
    9385                                <a href="help/help.php?topic=php"><?php _e('More Information', 'wp-infocard');?></a> 
     
    9688                                <?php _e('Mcrypt PHP Libraries Installed', 'wp-infocard'); ?> 
    9789                        </td><td valign="bottom">&nbsp; 
    98                                 <img src="<?php print checklist_icon($mcrypt_loaded); ?>"/> 
     90                                <img src="<?php print pw_admin::checklist_icon($mcrypt_loaded); ?>"/> 
    9991                                <a href="help/help.php?topic=mcrypt"><?php _e('More Information', 'wp-infocard');?></a> 
    10092                        </td></tr>   
     
    10395                                <?php _e('Rijndael 128 Algorithm Available', 'wp-infocard'); ?> 
    10496                        </td><td valign="bottom">&nbsp; 
    105                                 <img src="<?php print checklist_icon(mcrypt_module_self_test(MCRYPT_RIJNDAEL_128)); ?>"/> 
     97                                <img src="<?php print pw_admin::checklist_icon(mcrypt_module_self_test(MCRYPT_RIJNDAEL_128)); ?>"/> 
    10698                                <a href="help/help.php?topic=rijndael"><?php _e('More Information', 'wp-infocard');?></a> 
    10799                        </td></tr> 
     
    110102                                <?php _e('OpenSSL Enabled', 'wp-infocard'); ?> 
    111103                        </td><td valign="bottom">&nbsp; 
    112                                 <img src="<?php print checklist_icon($openssl_loaded); ?>"/> 
     104                                <img src="<?php print pw_admin::checklist_icon($openssl_loaded); ?>"/> 
    113105                                <a href="help/help.php?topic=openssl"><?php _e('More Information', 'wp-infocard');?></a> 
    114106                        </td></tr> 
     
    116108                                <?php _e('SSL Connection to Secure Site URL Works', 'wp-infocard'); ?> 
    117109                        </td><td valign="bottom">&nbsp; 
    118                                 <img src="<?php print checklist_icon(pw_admin::verifySSLURL($new_secureurl)); ?>"/>    
     110                                <img src="<?php print pw_admin::checklist_icon(pw_admin::verifySSLURL($new_secureurl)); ?>"/>  
    119111                                <a href="help/help.php?topic=cert"><?php _e('More Information', 'wp-infocard');?></a> 
    120112                        </td></tr> 
     
    122114                                <?php _e('Private Key Validly Formatted', 'wp-infocard'); ?> 
    123115                        </td><td valign="bottom">&nbsp; 
    124                                 <img src="<?php print checklist_icon($key_works); ?>"/> 
     116                                <img src="<?php print pw_admin::checklist_icon($key_works); ?>"/> 
    125117                                <a href="help/help.php?topic=privatekey"><?php _e('More Information', 'wp-infocard');?></a> 
    126118                        </td></tr>