10 $serviceMinimal =
true;
11 $serviceShowInfo =
false;
12 $serviceLoadMenu =
false;
13 $serviceShowMenu =
false;
17 require_once(dirname(__FILE__) .
'/../library/hcuService.i');
18 require_once(dirname(__FILE__) .
'/../library/hcuDispFunctions.i');
19 require_once(dirname(__FILE__) .
'/../library/hcuAuthShared.i');
20 require_once(
'cutrusted.i');
21 setIncludeFiles(
false,
true,
'bootstrap',
true);
24 unset( $HB_ENV[
"MC"] );
28 "APPID" => array(
'filter' => FILTER_SANITIZE_STRING),
29 "DTSTART" => array(
'filter' => FILTER_SANITIZE_STRING),
30 "DTEND" => array(
'filter' => FILTER_SANITIZE_STRING),
31 "CRED2" => array(
'filter' => FILTER_SANITIZE_STRING),
32 "CRED3" => array(
'filter' => FILTER_SANITIZE_STRING),
33 "USERID" => array(
'filter' => FILTER_SANITIZE_STRING),
34 "USERPASS" => array(
'filter' => FILTER_SANITIZE_STRING),
35 "USERKEY" => array(
'filter' => FILTER_SANITIZE_STRING),
36 "MFABUNDLE" => array(
'filter' => FILTER_SANITIZE_STRING),
37 "MFAKEY" => array(
'filter' => FILTER_SANITIZE_STRING),
38 "cu" => array(
'filter' => FILTER_SANITIZE_STRING),
39 "URLQstr" => array(
'filter' => FILTER_SANITIZE_STRING),
40 "URLPassWith" => array(
'filter' => FILTER_SANITIZE_STRING),
41 "generate" => array(
'filter' => FILTER_SANITIZE_STRING),
42 "msg" => array(
'filter' => FILTER_SANITIZE_STRING),
43 "WWWSvr" => array(
'filter' => FILTER_SANITIZE_STRING),
44 "RQMODE" => array(
'filter' => FILTER_SANITIZE_STRING),
45 "FACCTID" => array(
'filter' => FILTER_SANITIZE_STRING),
46 "TACCTID" => array(
'filter' => FILTER_SANITIZE_STRING),
47 "AMOUNT" => array(
'filter' => FILTER_SANITIZE_NUMBER_INT),
48 "TRMEMO" => array(
'filter' => FILTER_SANITIZE_STRING),
49 "PASSTO" => array(
'filter' => FILTER_SANITIZE_STRING),
50 "PASSWITH" => array(
'filter' => FILTER_SANITIZE_STRING),
51 "KEYACCTID" => array(
'filter' => FILTER_SANITIZE_STRING),
52 "CFGFLAG" => array(
'filter' => FILTER_SANITIZE_STRING),
53 "UPDAWARE" => array(
'filter' => FILTER_SANITIZE_NUMBER_INT),
56 # CFGFLAG is to be used to capture the session flag settings as used in Fmsg_tx on the desktop. Should be used 57 # currently in TXLIST / TXPOST to control whether or not to query the core for txaccount authority. Not implemented 58 # completely yet, but added to the Load_HB_ENV function and calls 60 HCU_ImportVars( $inPost,
"", $varOk );
62 $msg=HCU_array_key_value(
'msg',$inPost);
63 $cu = HCU_array_key_value(
'cu',$inPost);
64 # look a little closer at that cu value -- 65 # ctype_alnum ensures not empty / null, and contains only letters / digits 66 if (!ctype_alnum($cu)) {
67 $msg .=
"Invalid Request CU";
70 $USERID=HCU_array_key_value(
'USERID',$inPost);
71 $USERPASS=HCU_array_key_value(
'USERPASS',$inPost);
72 $USERKEY=urldecode(HCU_array_key_value(
'USERKEY',$inPost));
73 $MFAKEY=HCU_array_key_value(
'MFAKEY',$inPost);
74 $MFABUNDLE=HCU_array_key_value(
'MFABUNDLE',$inPost);
75 $APPID=HCU_array_key_value(
'APPID',$inPost);
76 $CRED2=HCU_array_key_value(
'CRED2',$inPost);
77 $CRED3=HCU_array_key_value(
'CRED3',$inPost);
78 $URLQstr=HCU_array_key_value(
'URLQstr',$inPost);
79 $URLPassWith=HCU_array_key_value(
'URLPassWith',$inPost);
80 $golink=HCU_array_key_value(
'golink',$inPost);
81 $show=HCU_array_key_value(
'show',$inPost);
82 $generate=HCU_array_key_value(
'generate',$inPost);
83 $WWWSvr=HCU_array_key_value(
'WWWSvr',$inPost);
84 $UPDAWARE=(HCU_array_key_exists(
'UPDAWARE',$inPost) ? HCU_array_key_value(
'UPDAWARE',$inPost) : 1);
88 if (!empty($generate)) {
90 if (empty($USERID) && empty($USERKEY)) {
91 $msg .=
"Please enter User ID or User Key<br>\n";
96 $apptokenkey =
'Chahriv8pahvahsa';
97 $client_source_override =
'APP';
98 $appkey =
"yuiQu8laLux7bahx";
103 $apptokenkey =
'Chahriv8pahvahsa';
104 $client_source_override =
'ADA';
105 $appkey =
"Gai7Vain2pab5zae";
109 # 3rd Party inbound authentication for ElecTel Cooperative 110 $apptokenkey =
'Phoophohye4deiha';
111 $client_source_override =
'OVA';
112 $appkey =
"AVoopaiSuTh8shie";
117 $msg .=
"Invalid App ID<br>\n";
120 # default DTSTART will be now minus 30 days 121 $dtstart = date(
"Y/m/d", time() - (30 * 24 * 3600));
123 if ( empty($USERPASS) ) {
124 if ( empty( $USERKEY ) ) {
126 $userrec = GetUserbyName($dbh, $inPost[
'cu'], $USERID);
128 $HB_ENV[
'Cu'] = $inPost[
'cu'];
130 $HB_ENV[
'Uid'] = $userrec[
'user_id'];
131 $HB_ENV[
'Cn'] = $userrec[
'user_name'];
132 $HB_ENV[
'Ce'] = time() + $HB_ENV[
'SYSENV'][
'ticket'][
'expires'];
133 $HB_ENV[
"Clw"] = $userrec[
'livewait'];
134 $HB_ENV[
"Clu"] = (empty($userrec[
'lastupdate']) ? $MC->msg(
"Unknown") : urlencode(trim($userrec[
'lastupdate'])));
135 $HB_ENV[
"Cauth"] = trim($userrec[
'primary_account']);
136 $HB_ENV[
"Fplog"] = (empty($userrec[
'llog']) ? $MC->msg(
"None") : urlencode(trim($userrec[
'llog'])));
137 $HB_ENV[
"Fflog"] = (empty($userrec[
'flog']) ? $MC->msg(
"None") : urlencode(trim($userrec[
'flog'])));
138 $HB_ENV[
"Ffchg"] = (is_null($userrec[
'fchange']) ?
'N' : $userrec[
'fchange']);
140 $HB_ENV[
'Ffremain'] = (is_null($userrec[
'fremain']) || $userrec[
'fremain'] == 0 ? $userrec[
'grace'] : $userrec[
'fremain']);
141 $HB_ENV[
'Fmsg_tx'] = $userrec[
'msg_tx'];
142 $HB_ENV[
'Fset'] = $userrec[
'flagset'];
143 $HB_ENV[
'Fset2'] = $userrec[
'flagset2'];
144 $HB_ENV[
'Fset3'] = $userrec[
'flagset3'];
145 $HB_ENV[
'Fhdays'] = $userrec[
'fhdays'];
146 $HB_ENV[
'Ml'] = $userrec[
'email'];
147 $HB_ENV[
'Ffreset'] = $userrec[
'freset'];
150 $baseKey = BuildBaseSessionTicket( $HB_ENV );
154 $newCe = $now + $HB_ENV[
'SYSENV'][
'ticket'][
'expires'];
156 $newSet =
"Ctime={$newCtime}&Ce={$newCe}";
158 $USERKEY = urlencode( BuildSessionTicketStr($HB_ENV, $baseKey, $newSet ) );
160 $USERKEY = urlencode($USERKEY);
163 $USERCLAUSE =
"&USERID=$USERID&USERPASS=$USERPASS";
195 $golink =
"{$WWWSvr}?APPID=$APPID&ORG=$CU&cu=$CU{$USERCLAUSE}&DTSTART=$dtstart";
197 if (!empty($MFABUNDLE))
198 $golink .=
"&MFABUNDLE=$MFABUNDLE";
200 $golink .=
"&CRED2=$CRED2";
202 $golink .=
"&CRED3=$CRED3";
204 $golink .=
"&MFAKEY=$MFAKEY";
205 if (!empty($URLQstr))
206 $golink .=
"&$URLQstr";
207 if (isset($UPDAWARE))
208 $golink .=
"&UPDAWARE=$UPDAWARE";
210 if (!empty($URLPassWith))
211 $golink .=
"&PASSWITH=" . urlencode($URLPassWith);
221 $WWWSvr = (empty($WWWSvr) ?
"http://" . $_SERVER[
'HTTP_HOST'] . dirname($_SERVER[
'PHP_SELF']) .
"/hcuAppFeed.prg" : $WWWSvr);
227 <title><?php echo hcu_displayHtml(
"App Simulator"); ?></title>
228 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8"/>
229 <meta name=
"robots" content=
"noindex,nofollow" />
230 <meta http-equiv=
"X-UA-Compatible" content=
"IE=edge" />
232 <meta name=
"viewport" content=
"width=device-width, initial-scale=1" />
235 <div
class=
'container-fluid'>
237 if ( strlen( $msg ) > 0 ) {
239 <div
class=
"well" style=
"color:darkred;">
245 <div
class=
'well well-sm col-xs-6' style=
"max-width:48%;">
247 <h3>HomeCU APP Key Generator</h3>
249 <form
id=
'formAppKey' name=
'formAppKey' method=
"post" action=
"GenAPP.prg">
252 <div
class=
"col-xs-12 hcu-container-margin">
253 <label
for=
"APPID" class=
"col-xs-3">
256 <input
id=
'APPID' name=
'APPID' class=
'col-xs-8' placeholder=
"Choose: OFXAA OFXRQ" 257 required data-required-msg=
"Choose: OFXAA OFXRQ" value=
"<?php echo "$APPID
"; ?>" size=
"50"/>
260 <div
class=
"col-xs-12 hcu-container-margin">
261 <label
for=
"cu" class=
"col-xs-3" >
264 <input
id=
'cu' name=
'cu' class=
'col-xs-8' placeholder=
"Upper Case CU Code" 265 required data-required-msg=
"The CU code" value=
"<?php echo "$cu
"; ?>" size=
"50"/>
268 <div
class=
"col-xs-12 hcu-container-margin">
269 <label
for=
"USERID" class=
"col-xs-3">
272 <input
id=
'USERID' name=
'USERID' class=
'col-xs-8' value=
"<?php echo "$USERID
"; ?>" size=
"50"/>
275 <div
class=
"col-xs-12 hcu-container-margin">
276 <div
class=
"col-xs-12" style=
'font-size:smaller; opacity=0.38; padding-bottom: 10px;'>
277 User Key is added to computed link; copy in latest
279 <label
for=
"USERKEY" class=
"col-xs-3">
282 <textarea
id=
'USERKEY' name=
'USERKEY' class=
'col-xs-8' style=
"height: 5em;"><?php echo
"$USERKEY"; ?></textarea>
285 <div
class=
"well col-xs-12 hcu-container-margin">
287 <div
class=
"col-xs-12" style=
'font-size:smaller; opacity=0.38; padding-bottom: 10px;'>Use
if testing authentication process (supply Password, blank
User Key, click Generate Link first)</div>
290 <label
for=
"USERPASS" class=
"col-xs-3">
293 <input
id=
'USERPASS' name=
'USERPASS' type=
"password" class=
'col-xs-8' placeholder=
"Leave blank to populate User Key" value=
"<?php echo "$USERPASS
"; ?>" size=
"50"/>
296 <div
class=
"col-xs-12"> </div>
299 <label
for=
"MFAKEY" class=
"col-xs-3">
302 <input
id=
'MFAKEY' name=
'MFAKEY' class=
'col-xs-8' placeholder=
"" value=
"<?php echo "$MFAKEY
"; ?>" size=
"50"/>
303 <div
class=
"col-sm-offset-3 col-xs-8" style=
'font-size:smaller; opacity=0.38;'>This is the device key stored on phone; can use one returned by the server
for subsequent calls.</div>
306 <div
class=
"col-xs-12"> </div>
309 <label
for=
"MFABUNDLE" class=
"col-xs-3">
312 <input
id=
'MFABUNDLE' name=
'MFABUNDLE' class=
'col-xs-8' placeholder=
"Copy latest MFA Bundle into here" value=
"<?php echo "$MFABUNDLE
"; ?>" size=
"50"/>
316 <div
class=
"well col-xs-12 hcu-container-margin">
318 <div
class=
"col-xs-12" style=
'font-size:smaller; opacity=0.38; padding-bottom: 10px;'>Passed with RQMODE or any other parameters, and PASSWITH values as needed</div>
321 <label
for=
"URLQstr" class=
"col-xs-3">
324 <input
id=
'URLQstr' name=
'URLQstr' class=
'col-xs-8' value=
"<?php echo "$URLQstr
"; ?>" size=
"50"/>
327 <div
class=
"col-xs-12"> </div>
330 <label
for=
"URLPassWith" class=
"col-xs-3">
333 <input
id=
'URLPassWith' name=
'URLPassWith' class=
'col-xs-8' value=
"<?php echo "$URLPassWith
"; ?>" size=
"50"/>
337 <div
class=
"col-xs-12 hcu-container-margin">
338 <label
for=
"WWWSvr" class=
"col-xs-3">
341 <input
id=
'WWWSvr' name=
'WWWSvr' class=
'col-xs-8' value=
"<?php echo "$WWWSvr
"; ?>" size=
"50"/>
345 <div
class=
"col-xs-12 hcu-container-margin">
346 <div
class=
"col-xs-6">
347 <button
id=
"generate" name=
'btnGenerate' type=
"submit" class=
"k-button k-primary hcu-all-100 hcu-xs-btn-margin-top hcu-xs-btn-pad">
348 <span
class=
"fa fa-arrow-right local-pad-icon"></span>
352 <div
class=
"col-xs-6">
353 <button
id=
"getData" name=
'getData' type=
"button" class=
"k-button hcu-all-100 hcu-xs-btn-margin-top hcu-xs-btn-pad">
354 <span
class=
"fa fa-arrow-right local-pad-icon"></span>
358 <input type=
"hidden" name=
"generate" value=
"go">
363 <div
class=
'well well-sm col-xs-6' style=
"max-width:48%; margin-left:10px;">
364 <div
class=
"col-xs-12 hcu-container-margin">
365 Computed link (sent when
'Get Data' clicked)
366 <textarea
id=
'targetLink' name=
'targetLink' class=
'col-xs-12' style=
"height: 10em;">
367 <?php echo
"$golink"; ?>
370 <div
class=
"col-xs-12 hcu-container-margin">
372 <textarea
id=
"getDataResult" name=
"getDataResult" class=
"col-xs-12" style=
"height: 27em;">
376 <div
class=
'col-xs-12'>
380 <li>Enter App ID, Org ID,
User ID. Leave
User Key blank to
get generated key.</li>
381 <li>Click Generate Key. This generates a
User Key to start communications.</li>
382 <li>If testing authentication process, enter password matching the
User ID; optionally can enter MFA Key or Query String fields as needed. Copy MFA bundle from replies.</li>
383 <li>Click Get Data. Copy the returned <userkey> contents into
User Key as needed.</li>
384 <li>Add Query String and Pass With (as needed). Click Generate Key to re-build the link.</li>
385 <li>Can edit Computed Link directly,
if desired, and then click Get Data.</li>
387 (Clicking Get Data will send AJAX call with computed link and
User Key).<br>
390 Possible Query String choices
for RQMODE (feature requests):<br>
393 <li>NOTICE (PASSWITH has notice response)</li>
394 <li>MEMBERSETTINGS (PASSWITH has GETALLOWED=1, GETSETTINGS=1(password)|2(email)|4(challenge)|8(useralias)|16(phone))</li>
403 <li>UPDCRED (PASSWITH: ASKLATER=1, EMAIL=<email addr>&OPTIN=Y|N&PHONE=<num1>|<num2>&CONFWORD=<words>&CQID_1=<id>&CQANS_1=<encoded resp>)</li>
406 Possible Query String choices for AUTHMODE (MFA process):
408 <li>AUTHMODE=EML|MFQ|MFS|MFC|MFP
410 <li>EML PassWith: MFA_E=email address</li>
411 <li>MFQ PassWith: id=answer (repeated if multiple)</li>
412 <li>MFS PassWith: MFS_Deliver=access code delivery location id</li>
413 <li>MFC PassWith: MFS_Auth=secure access code</li>
414 <li>MFP PassWith: (none, uses UserID and Password)</li>
423 <!--============================================-->
446 function Get_AppFeed($WWWSvr, $APPID, $CU, $USERCLAUSE, $CRED2, $CRED3, $DTSTART, $URLQstr, $URLPassWith) {
448 $req =
"APPID=$APPID&ORG=$CU&cu=$CU&$USERCLAUSE&CRED2=$CRED2&CRED3=$CRED3&DTSTART=$DTSTART";
450 if (!empty($URLQstr))
452 if (!empty($URLPassWith))
453 $req .=
"&PASSWITH=" . urlencode($URLPassWith);
455 $cmd =
"/usr/bin/curl --request POST --url '{$WWWSvr}?{$req}'";
458 CURLOPT_RETURNTRANSFER => 1,
460 CURLOPT_HEADER =>
false,
462 CURLOPT_POSTFIELDS => $req,
463 CURLOPT_URL =>
"$WWWSvr");
471 curl_setopt_array($ch, $curlopts);
472 $response = curl_exec($ch);
473 $cerrno = curl_errno($ch);
474 $cerr = curl_error($ch);
475 $HTTPerr = curl_getinfo($ch, CURLINFO_HTTP_CODE);
488 # check for fault & throw error 490 print
"Connection Error $cerrno $cerr<br>";
491 print
"$cmd<br>" . print_r($curlopts);
492 } elseif (empty($response) ) {
493 print
"Empty Response<br>";
495 print
"HTTP Error $HTTPerr<br>";
500 $dom =
new DOMDocument();
503 $dom->preserveWhiteSpace =
false;
504 $dom->formatOutput =
true;
507 $dom->loadXML($response);
508 $out = $dom->saveXML();
509 print
"<pre>" . htmlentities($out) .
"</pre>";
513 function Format_AppFeed($data) {
517 $dom =
new DOMDocument();
519 $dom->preserveWhiteSpace =
false;
520 $dom->formatOutput =
true;
522 $dom->loadXML($data);
523 $out = $dom->saveXML();
529 $(
"#generate").click(
function() {
530 var org = $(
"#cu").val();
531 var action = $(
"#formAppKey").attr(
"action" );
533 $(
"#formAppKey").attr(
"action", action +
"?cu=" + org );
536 $(
'#getData').click(
function () {
537 var targetLink = $(
'#targetLink').text().trim();
538 var userkey = $(
'#USERKEY').text().trim();
540 if ( userkey.indexOf(
"&" ) > -1 ) {
541 userkey = encodeURIComponent( userkey );
544 var whatToSend = targetLink +
"&USERKEY=" + userkey;
547 $(
this).prop(
"disabled",
"disabled");
548 $(
"#getDataResult").html(
"");
549 $(
"#getDataResult").css(
"display",
"inline");
557 .done(
function (data, textStatus, jqXHR) {
561 $(
"#getDataResult").html( data );
562 $(
"#getDataResult").show();
565 .fail(
function (jqXHR, textStatus, errorThrown) {
566 $(
"#getDataResult").html(
"<?php echo $MC->msg("Error
", HCU_DISPLAY_AS_HTML); ?>");
567 $(
"#getDataResult").css(
"color",
"red");
569 .always(
function (jqXHR, textStatus, errorThrown) {
570 $(
"#getData").removeProp(
"disabled");
571 $(
"#getDataResult").show();
584 .local-transfer-msg {
588 .local-transfer-button {
593 .k-dropdown .k-input,.k-selectbox .k-input {
597 .container-fluid-margin {
601 .k-block > .k-header {
606 .hcu-info-margin, .hcu-error-margin {
610 .hcu-info-padding, .hcu-error-padding {
618 .hcu-container-margin {