Changeset 30
- Timestamp:
- 04/04/07 13:19:27 (2 years ago)
- Files:
-
- trunk/wp-infocard/class.infocard-basic.php (modified) (1 diff)
- trunk/wp-infocard/processing/class.infocard-processing.php (modified) (12 diffs)
- trunk/wp-infocard/processing/infocard-post-decrypt.php (modified) (1 diff)
- trunk/wp-infocard/processing/infocard-post-get-claims.php (modified) (2 diffs)
- trunk/wp-infocard/processing/infocard-post.php (modified) (3 diffs)
- trunk/wp-infocard/wp-infocard.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/wp-infocard/class.infocard-basic.php
r29 r30 166 166 } // end function describeGivenCert 167 167 168 function verifyTimeWindow (){169 170 // Verify that the token is being processed within the time window171 // 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 verifyTimeWindow188 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 }198 168 199 169 function printDebug( $content ) { trunk/wp-infocard/processing/class.infocard-processing.php
r29 r30 4 4 include_once("infocard-print-binary.php"); 5 5 require_once( ABSPATH . WPINC . '/registration-functions.php'); 6 include_once(dirname(__FILE__) . "/../pw-config.php"); 7 include_once(dirname(__FILE__) . "/../" . PW_PLUGIN . "/userdata.pw.php"); 8 include_once(dirname(__FILE__) . "/../" . PW_PLUGIN . "/utils.pw.php"); 6 9 7 10 class InfocardProcessing { … … 31 34 $identity_user_id = 0; 32 35 36 InfocardUtils::printDebug( '<br/>Evaluating Incoming Request:<br/>'); 37 33 38 if (!is_email($email)) { 34 39 $incominguser['status'] = "INVALIDEMAIL"; … … 37 42 38 43 //$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 ); 47 58 48 59 $mail_user_id = 0; … … 105 116 } // end of function evaluateIncomingRequest 106 117 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(" Inserted record # $user_ID<br>");116 return $user_ID;117 } else {118 InfocardUtils::printDebug(" Error - new user not created<br/>");119 return FALSE;120 }121 122 } // end function createNewAccount123 118 124 119 function sendAccountValidation( $clickbackID, $user_email, $relocationUrl ) { … … 132 127 // Message, you would customize this function. 133 128 134 $clickbackUrl = PW_PLUGINURL 135 . "/login/infocard-clickback.php?" . $clickbackID; 129 $clickbackUrl = PW_PLUGINURL . "/login/infocard-clickback.php?" . $clickbackID; 136 130 137 131 $message = sprintf(__('Please complete your registration at %s by opening the link below.'), get_settings('blogname')) . "\r\n\r\n"; … … 142 136 InfocardUtils::printDebug( "<br/><br/>Account Validation is required.<br/>" 143 137 . "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/>" 145 139 . "Message would be: <pre>$message</pre>" 146 140 ); 147 141 148 142 } // end of function sendAccountValidation 149 150 function dataCompare($db_item, $token_item, $item_name)151 // Function: dataCompare152 // Purpose: to compare the value of a given piece of user data between153 // 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(" $item_name: matches ($db_item)<br/>");158 return (TRUE);159 }160 else161 {162 Infocardutils::printDebug(" $item_name: DB: $db_item TOKEN: $token_item<br/>");163 return (FALSE);164 }165 } //end function dataCompare166 143 167 144 function updateUserData( $ID, $user_login, $user_pass, $user_email, $user_nicename, $user_url, $display_name, $first_name, $last_name, $nickname, $user_ppid ) … … 207 184 else 208 185 { 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'); 217 194 } 218 195 } … … 223 200 224 201 // 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 ) 227 205 { 228 206 InfocardUtils::printDebug ( ' Updating Card Identifier<br/>' ); … … 230 208 } 231 209 232 if ( InfocardProcessing::dataCompare($extra_data['ppid'], $user_ppid, 'PPID') == FALSE )210 if ( pw_utils::dataCompare($extra_data['ppid'], $user_ppid, 'PPID') == FALSE ) 233 211 { 234 212 InfocardUtils::printDebug ( ' Updating PPID<br/>' ); … … 236 214 } 237 215 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 ) 239 217 { 240 218 // no WP function to update LoginID because it is never … … 251 229 } // end function updateUserData 252 230 253 function writeToAudit( $ip, $modulus, $email, $error) {254 // writeToAudit puts information into the infocard_audit table255 // in mySQL. Currently this function opens its own database256 // connections (that's how Kim wrote it) but it would be nice257 // to leverage the already open connection.258 259 // set up the SQL connection260 $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 writeToAudit277 231 278 232 function setLoginCookies( $user_login, $user_pass, $user_nicename, $user_email, $user_url ) { … … 298 252 function createChallenge( $data ) { 299 253 //$clickback_salt = get_settings('clickback_salt'); 300 $clickback_salt = pw_a ttributes::get_attr('pw_clickback_salt');254 $clickback_salt = pw_admin::getOption('pw_clickback_salt'); 301 255 302 256 InfocardUtils::printDebug("Clickback: Challenge Created. <br/>" trunk/wp-infocard/processing/infocard-post-decrypt.php
r29 r30 21 21 do { 22 22 23 $private_key_cipher = pw_a ttributes::get_attr('infocard_key');24 $private_key_passphrase = pw_a ttributes::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'); 25 25 if ($private_key_cipher == NULL) 26 26 { trunk/wp-infocard/processing/infocard-post-get-claims.php
r29 r30 3 3 include_once("infocard-pkey-get-public.php"); 4 4 include_once( dirname(__FILE__) . "/../class.infocard-basic.php"); 5 include_once( dirname(__FILE__) . "/../pw-config.php"); 6 include_once( dirname(__FILE__) . "/../" . PW_PLUGIN . "/utils.pw.php"); 5 7 6 8 define("INFO_IGNORE", 0); … … 138 140 // Verify that the token is being processed within the time window 139 141 // 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(" 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 } 158 157 159 158 // Make sure assertion id has not been used before within the window trunk/wp-infocard/processing/infocard-post.php
r29 r30 8 8 include_once("infocard-post-get-claims.php"); 9 9 include_once("class.infocard-processing.php"); 10 include_once( dirname(__FILE__) . "/../pw-config.php"); 11 include_once( dirname(__FILE__) . "/../" . PW_PLUGIN . "/admin.pw.php"); 12 include_once( dirname(__FILE__) . "/../" . PW_PLUGIN . "/audit.pw.php"); 10 13 if (version_compare($wp_version, '2.1', '>=')) 11 14 { … … 135 138 136 139 // 137 // note that a user only evaluates to "new-user" the first138 // time they come through. When they come through for the139 // 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. 140 143 // 141 144 $accountValidationRequired = TRUE; 142 145 $relocationUrl = PW_SITEMESGURL . '?new-user'; 143 146 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 ); 145 148 if (!$user_ID) 146 149 { … … 206 209 } while (0); 207 210 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 ); 209 212 210 213 if (strlen($error) > 0) trunk/wp-infocard/wp-infocard.php
r29 r30 17 17 } 18 18 19 $wpInfocard = new pw_ admin();19 $wpInfocard = new pw_infocard(); 20 20 21 21 // Define when we want to run the tracking: on shutdown (see wordpress codex) … … 39 39 40 40 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 }49 41 50 42 … … 89 81 <?php _e('PHP Version 5 or greater installed', 'wp-infocard'); ?> 90 82 </td><td valign="bottom"> 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', '>=')); ?>"/> 92 84 93 85 <a href="help/help.php?topic=php"><?php _e('More Information', 'wp-infocard');?></a> … … 96 88 <?php _e('Mcrypt PHP Libraries Installed', 'wp-infocard'); ?> 97 89 </td><td valign="bottom"> 98 <img src="<?php print checklist_icon($mcrypt_loaded); ?>"/>90 <img src="<?php print pw_admin::checklist_icon($mcrypt_loaded); ?>"/> 99 91 <a href="help/help.php?topic=mcrypt"><?php _e('More Information', 'wp-infocard');?></a> 100 92 </td></tr> … … 103 95 <?php _e('Rijndael 128 Algorithm Available', 'wp-infocard'); ?> 104 96 </td><td valign="bottom"> 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)); ?>"/> 106 98 <a href="help/help.php?topic=rijndael"><?php _e('More Information', 'wp-infocard');?></a> 107 99 </td></tr> … … 110 102 <?php _e('OpenSSL Enabled', 'wp-infocard'); ?> 111 103 </td><td valign="bottom"> 112 <img src="<?php print checklist_icon($openssl_loaded); ?>"/>104 <img src="<?php print pw_admin::checklist_icon($openssl_loaded); ?>"/> 113 105 <a href="help/help.php?topic=openssl"><?php _e('More Information', 'wp-infocard');?></a> 114 106 </td></tr> … … 116 108 <?php _e('SSL Connection to Secure Site URL Works', 'wp-infocard'); ?> 117 109 </td><td valign="bottom"> 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)); ?>"/> 119 111 <a href="help/help.php?topic=cert"><?php _e('More Information', 'wp-infocard');?></a> 120 112 </td></tr> … … 122 114 <?php _e('Private Key Validly Formatted', 'wp-infocard'); ?> 123 115 </td><td valign="bottom"> 124 <img src="<?php print checklist_icon($key_works); ?>"/>116 <img src="<?php print pw_admin::checklist_icon($key_works); ?>"/> 125 117 <a href="help/help.php?topic=privatekey"><?php _e('More Information', 'wp-infocard');?></a> 126 118 </td></tr>
