/** * Attempt to authenticate the current user. * * @return object User object if successful, PEAR_Error otherwise. * @access public */ public function authenticate() { global $configArray; if (isset($_POST['username']) && isset($_POST['password'])) { $username = $_POST['username']; $password = $_POST['password']; if ($username != '' && $password != '') { // Attempt SIP2 Authentication $mysip = new sip2(); $mysip->hostname = $configArray['SIP2']['host']; $mysip->port = $configArray['SIP2']['port']; if ($mysip->connect()) { //send selfcheck status message $in = $mysip->msgSCStatus(); $msg_result = $mysip->get_message($in); // Make sure the response is 98 as expected if (preg_match("/^98/", $msg_result)) { $result = $mysip->parseACSStatusResponse($msg_result); // Use result to populate SIP2 setings $mysip->AO = $result['variable']['AO'][0]; $mysip->AN = $result['variable']['AN'][0]; $mysip->patron = $username; $mysip->patronpwd = $password; $in = $mysip->msgPatronStatusRequest(); $msg_result = $mysip->get_message($in); // Make sure the response is 24 as expected if (preg_match("/^24/", $msg_result)) { $result = $mysip->parsePatronStatusResponse($msg_result); if ($result['variable']['BL'][0] == 'Y' and $result['variable']['CQ'][0] == 'Y') { // Success!!! $user = $this->_processSIP2User($result, $username, $password); // Set login cookie for 1 hour $user->password = $password; // Need this for Metalib } else { $user = new PEAR_Error('authentication_error_invalid'); } } else { $user = new PEAR_Error('authentication_error_technical'); } } else { $user = new PEAR_Error('authentication_error_technical'); } $mysip->disconnect(); } else { $user = new PEAR_Error('authentication_error_technical'); } } else { $user = new PEAR_Error('authentication_error_blank'); } } else { $user = new PEAR_Error('authentication_error_blank'); } return $user; }
/** * Attempt to authenticate the current user. Throws exception if login fails. * * @param \Zend\Http\PhpEnvironment\Request $request Request object containing * account credentials. * * @throws AuthException * @return \VuFind\Db\Row\User Object representing logged-in user. */ public function authenticate($request) { $username = trim($request->getPost()->get('username', '')); $password = trim($request->getPost()->get('password', '')); if ($username == '' || $password == '') { throw new AuthException('authentication_error_blank'); } // Attempt SIP2 Authentication $mysip = new \sip2(); $config = $this->getConfig(); if (isset($config->SIP2)) { $mysip->hostname = $config->SIP2->host; $mysip->port = $config->SIP2->port; } if (!$mysip->connect()) { throw new AuthException('authentication_error_technical'); } //send selfcheck status message $in = $mysip->msgSCStatus(); $msg_result = $mysip->get_message($in); // Make sure the response is 98 as expected if (!preg_match("/^98/", $msg_result)) { $mysip->disconnect(); throw new AuthException('authentication_error_technical'); } $result = $mysip->parseACSStatusResponse($msg_result); // Use result to populate SIP2 setings $mysip->AO = $result['variable']['AO'][0]; $mysip->AN = $result['variable']['AN'][0]; $mysip->patron = $username; $mysip->patronpwd = $password; $in = $mysip->msgPatronStatusRequest(); $msg_result = $mysip->get_message($in); // Make sure the response is 24 as expected if (!preg_match("/^24/", $msg_result)) { $mysip->disconnect(); throw new AuthException('authentication_error_technical'); } $result = $mysip->parsePatronStatusResponse($msg_result); $mysip->disconnect(); if ($result['variable']['BL'][0] == 'Y' and $result['variable']['CQ'][0] == 'Y') { // Success!!! $user = $this->processSIP2User($result, $username, $password); // Set login cookie for 1 hour $user->password = $password; // Need this for Metalib } else { throw new AuthException('authentication_error_invalid'); } return $user; }
public function checkInItem($barcode) { global $configArray; //Place the hold via SIP 2 $mysip = new sip2(); $mysip->hostname = $configArray['SIP2']['host']; $mysip->port = $configArray['SIP2']['online_port']; $hold_result['result'] = false; if ($mysip->connect()) { //send selfcheck status message $in = $mysip->msgSCStatus(); $msg_result = $mysip->get_message($in); // Make sure the response is 98 as expected if (preg_match("/^98/", $msg_result)) { $result = $mysip->parseACSStatusResponse($msg_result); // Use result to populate SIP2 setings $mysip->AO = $result['variable']['AO'][0]; /* set AO to value returned */ $mysip->AN = $result['variable']['AN'][0]; /* set AN to value returned */ $mysip->patron = $user->cat_username; $mysip->patronpwd = $user->cat_password; $in = $mysip->msgCheckin($barcode, $mysip->_datestamp()); $msg_result = $mysip->get_message($in); if (preg_match("/^10/", $msg_result)) { $result = $mysip->parseCheckinResponse($msg_result); $checkout_result['result'] = $result['fixed']['Ok'] == 1; $checkout_result['success'] = $checkout_result['result']; $checkout_result['message'] = $result['variable']['AF'][0]; $checkout_result['sipinput'] = $in; $checkout_result['sipresult'] = $result; } } } return $checkout_result; }
public function authenticate() { global $configArray; global $timer; if (isset($_POST['username']) && isset($_POST['password'])) { $username = $_POST['username']; $password = $_POST['password']; //Set this up to use library prefix $barcodePrefix = $configArray['Catalog']['barcodePrefix']; if (strlen($barcodePrefix) > 0) { if (strlen($username) == 9) { $username = substr($barcodePrefix, 0, 5) . $username; } elseif (strlen($username) == 8) { $username = substr($barcodePrefix, 0, 6) . $username; } elseif (strlen($username) == 7) { $username = $barcodePrefix . $username; } } //Check to see if we have already processed this user if (array_key_exists($username, self::$processedUsers)) { return self::$processedUsers[$username]; } if ($username != '' && $password != '') { // Attempt SIP2 Authentication $mysip = new sip2(); $mysip->hostname = $configArray['SIP2']['host']; $mysip->port = $configArray['SIP2']['port']; if ($mysip->connect()) { //send selfcheck status message $in = $mysip->msgSCStatus(); $msg_result = $mysip->get_message($in); // Make sure the response is 98 as expected if (preg_match("/^98/", $msg_result)) { $result = $mysip->parseACSStatusResponse($msg_result); // Use result to populate SIP2 setings $mysip->AO = $result['variable']['AO'][0]; /* set AO to value returned */ if (isset($result['variable']['AN'])) { $mysip->AN = $result['variable']['AN'][0]; /* set AN to value returned */ } $mysip->patron = $username; $mysip->patronpwd = $password; $in = $mysip->msgPatronStatusRequest(); $msg_result = $mysip->get_message($in); // Make sure the response is 24 as expected if (preg_match("/^24/", $msg_result)) { $result = $mysip->parsePatronStatusResponse($msg_result); if ($result['variable']['BL'][0] == 'Y' and $result['variable']['CQ'][0] == 'Y') { //Get patron info as well $in = $mysip->msgPatronInformation('none'); $msg_result = $mysip->get_message($in); // Make sure the response is 24 as expected if (preg_match("/^64/", $msg_result)) { $patronInfoResponse = $mysip->parsePatronInfoResponse($msg_result); //print_r($patronInfoResponse); } // Success!!! $user = $this->processSIP2User($result, $username, $password, $patronInfoResponse); // Set login cookie for 1 hour $user->password = $password; // Need this for Metalib } else { $user = new PEAR_Error('authentication_error_invalid'); } } else { $user = new PEAR_Error('authentication_error_technical'); } } else { $user = new PEAR_Error('authentication_error_technical'); } $mysip->disconnect(); } else { $user = new PEAR_Error('authentication_error_technical'); global $logger; $logger->log("Unable to connect to SIP server", PEAR_LOG_ERR); } } else { $user = new PEAR_Error('authentication_error_blank'); } $timer->logTime("Authenticated user in SIP2Authentication"); self::$processedUsers[$username] = $user; } else { $user = new PEAR_Error('authentication_error_blank'); } return $user; }