diff options
Diffstat (limited to 'actions/suck.php')
-rw-r--r-- | actions/suck.php | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/actions/suck.php b/actions/suck.php new file mode 100644 index 000000000..fd801e2de --- /dev/null +++ b/actions/suck.php @@ -0,0 +1,56 @@ +<?php + +//require_once("config.php"); +global $CONFIG; +require_once($CONFIG->pluginspath."foafssl/lib/Authentication.php"); + +$config = array('db_name'=>'arc','db_user'=>'arc','db_pwd'=>'chjdladhsjk34!arcarc','store_name'=>'arc_tests'); +if ($_SERVER['SSL_CLIENT_CERT']) { + error_log("going to add"); + $cert = $_SERVER['SSL_CLIENT_CERT']; + $res = openssl_x509_read($cert); + $cert_data = openssl_x509_parse($cert); + $uid = $cert_data["subject"]["UID"]; + $altName = $cert_data["extensions"]["subjectAltName"]; + $pubKey = openssl_pkey_get_public($res); + $keyData = openssl_pkey_get_details($pubKey); + + //Remove certificate armour + $unpacked_n = unpack("H*",$keyData['rsa']['n']); + $modulus = strtoupper($unpacked_n[1]); + $unpacked_e = unpack("H*",$keyData['rsa']['e']); + $exponent = hexdec($unpacked_e[1]); + set_input("name",$cert_data["subject"]["CN"]); + set_input("webid",$altName); + set_input("modulus",$modulus); + set_input("exponent",$exponent); + include($CONFIG->pluginspath."foafssl/actions/add.php"); +} + + +/* +$auth = new Authentication_FoafSSLARC($config); +//$auth = new Authentication_AgentARC($config, $webId); +//var_dump($auth); +//if ($auth->agentId !== $auth->agentURI) { +if ($auth->isAuthenticated()) { + //print "Hello : $auth->webid<br/>"; + $base_url = $CONFIG->wwwroot."pg/profile/"; + if (strpos($auth->webid, $base_url) == 0) { + $root_len = strlen($base_url); + $username = substr($auth->webid, $root_len, strlen($auth->webid)-$root_len-strlen("?view=foaf")); + $user = get_user_by_username($username); + login($user, true); + system_message(elgg_echo("you logged in successfully with your certificate!")); + forward(); + + } +} +else { + print "Sorry you are not logged in<br/>"; + print $auth->authnDiagnostic; +} +*/ +//$auth->logout(); + +?> |