summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Neves2012-02-26 12:09:28 +0100
committerMichael Neves2012-02-26 12:09:28 +0100
commit8ecfa7a239f9ee82b4bf9440395fb4947367a98b (patch)
tree88c0e8811948c0c930dd6f3f7d59a9228bc03042
parentstartDownload with relative path (diff)
downloadpbs2-8ecfa7a239f9ee82b4bf9440395fb4947367a98b.tar.gz
pbs2-8ecfa7a239f9ee82b4bf9440395fb4947367a98b.tar.xz
pbs2-8ecfa7a239f9ee82b4bf9440395fb4947367a98b.zip
smartcard auth
-rw-r--r--application/modules/fbgui/controllers/AuthController.php9
-rw-r--r--application/modules/fbgui/controllers/IndexController.php351
2 files changed, 184 insertions, 176 deletions
diff --git a/application/modules/fbgui/controllers/AuthController.php b/application/modules/fbgui/controllers/AuthController.php
index e0f6068..2eb42ad 100644
--- a/application/modules/fbgui/controllers/AuthController.php
+++ b/application/modules/fbgui/controllers/AuthController.php
@@ -25,7 +25,12 @@ class Fbgui_AuthController extends Zend_Controller_Action {
public function loginAction() {
if (Zend_Auth::getInstance()->hasIdentity()) {
$this->_redirect('/fbgui/');
- } else {
+ }
+ elseif($_SERVER['SSL_CLIENT_VERIFY'] === 'SUCCESS'){
+ print_a($_SERVER);
+ }
+ else {
+
if (!isset($_POST["login"])) {
$loginForm = new fbgui_Form_Login();
} else {
@@ -60,7 +65,7 @@ class Fbgui_AuthController extends Zend_Controller_Action {
}
}
}
- $this->view->loginForm = $loginForm;
+// $this->view->loginForm = $loginForm;
}
}
diff --git a/application/modules/fbgui/controllers/IndexController.php b/application/modules/fbgui/controllers/IndexController.php
index 8c909e3..5651796 100644
--- a/application/modules/fbgui/controllers/IndexController.php
+++ b/application/modules/fbgui/controllers/IndexController.php
@@ -11,179 +11,182 @@
*/
class Fbgui_IndexController extends Zend_Controller_Action {
- protected $membership;
-
- public function init() {
- /* Initialize action controller here */
- $userIDsNamespace = Zend_Session::namespaceGet('userIDs');
-
- $membershipMapper = new Application_Model_MembershipMapper();
- $this->membership = new Application_Model_Membership();
- $membershipMapper->find($userIDsNamespace['membershipID'], $this->membership);
- }
-
- public function errorAction() {
- $result = $this->_request->getParam('serialresult');
- if($result != "") {
-
- $this->view->notification = Pbs_Notifier::notify('serial', $result);
- }
- }
-
- public function indexAction() {
- $mySession = new Zend_Session_Namespace('pbs');
- $this->view->notification = array();
-
-
- if(count($mySession->postdata) <= 0) {
- $mySession->postdata = $_POST;
- }
-
- $result = $this->_request->getParam('notify');
- if($result == 'nomember') {
-
- $this->view->notification[] = Pbs_Notifier::notify('You have no membership, therefore you have no own BootMenu', 'info');
- }
-
- $d = new Pbs_Debug();
- $d->debug(array('FBGuiIndexController', $_SERVER['REMOTE_ADDR'], implode("\t", $mySession->postdata)));
-
- if(isset($mySession->postdata['bootisoID']) || isset($mySession->postdata['serialnumber'])) {
- // Create a session
- $n = new Pbs_Session();
-
- $bootisomapper = new Application_Model_BootIsoMapper();
- $bootiso = new Application_Model_BootIso();
- if(isset($mySession->postdata['bootisoID'])) {
- $bootisomapper->find($mySession->postdata['bootisoID'], $bootiso);
- $groupID = $bootiso->getGroupID();
- }
- elseif(isset($mySession->postdata['serialnumber'])) {
- $results = $bootisomapper->findBy(array('serialnumber' => $mySession->postdata['serialnumber']), true);
- if(count($results) == 0) {
- $this->_redirect('/fbgui/index/error/serialresult/noserial2');
- }
- $bootiso->setOptions($results[0]);
- $bootiso->setID($results[0]['bootisoID']);
- $groupID = $bootiso->getGroupID();
-
- }
-
- $client = new Application_Model_Client();
- $client->setMacadress($mySession->postdata['mac']);
- $client->setHardwarehash($mySession->postdata['hardwarehash']);
- $client->setGroupID($groupID);
- $client->setCreated(time());
- $client = $n->createClient($client);
- $clientID = $client->getID();
-
- $userIDsNamespace = Zend_Session::namespaceGet('userIDs');
-
- if(!isset($_SESSION['alphasessionID'])) {
- $session = new Application_Model_Session();
- $session->setBootisoID($bootiso->getID());
- $session->setClientID($clientID);
- $session->setTime(time());
- if($this->membership->getID() != '') {
- $session->setMembershipID($this->membership->getID());
- }
- $session->setIp($_SERVER['REMOTE_ADDR']);
- $session = $n->createSession($session);
- $_SESSION['alphasessionID'] = $session->getAlphasessionID();
- } else {
- $session = new Application_Model_Session();
- $sessionMapper = new Application_Model_SessionMapper();
- $sessions = $sessionMapper->findBy(array('alphasessionID' => $_SESSION['alphasessionID']));
- $session = $sessions[0];
- if($this->membership->getID() != '' && $session->getMembershipID() == '') {
- $session->setMembershipID($this->membership->getID());
- $sessionMapper->save($session);
- }
- }
- // Request Bootmenu
- $pbsFilter = new Pbs_Filter();
- $bootmenuID = $pbsFilter->evaluate();
- if($bootmenuID != null) {
- $this->view->alphasessionID = $_SESSION['alphasessionID'];
- // print_a('Debug Output',
- // 'Session is now set',
- // 'Your sessionID is '.$session->getID(),
- // 'Your alphasessionID is '.$session->getAlphasessionID(),
- // 'Your client is '.$session->getClientID(),
- // 'goto bootmenu '.$bootmenuID);
-
- $bootmenuMapper = new Application_Model_BootMenuMapper();
- $bm = $bootmenuMapper->find($bootmenuID);
- $this->view->title = $bm->getTitle();
- $this->view->startcounter = $bm->getStartcounter();
-
- $bootmenuentriesMapper = new Application_Model_BootMenuEntriesMapper();
- $res = $bootmenuentriesMapper->findBy(array('bootmenuID' => $bootmenuID), false);
- $this->view->entries = $res;
-
- if (!Zend_Auth::getInstance()->hasIdentity()) {
- $this->view->loginmenu = true;
- }
-
- if(Zend_Auth::getInstance()->hasIdentity()) {
- if($bm->MembershipID != '' && $bm->MembershipID == $this->membership->getID()) {
- } else {
-
- $this->view->notification[] = Pbs_Notifier::notify("This is not your Bootmenu. There is currently a BootMenu with a higher priority active.", 'info');
- }
- }
-
- if(count($res) == 0) {
-
- $this->view->notification[] = Pbs_Notifier::notify("There are no entries in the bootmenu.", 'info');
- $this->view->nobootmenu = true;
- unset($this->view->entries);
- }
-
-
- } else {
- // print_a('Debug Output',
- // 'Session is now set',
- // 'Your sessionID is '.$session->getID(),
- // 'Your alphasessionID is '.$session->getAlphasessionID(),
- // 'Your client is '.$session->getClientID(),
- // 'there is no bootmenu for you');
- if (!Zend_Auth::getInstance()->hasIdentity()) {
- $this->view->loginmenu = true;
-
- $this->view->notification[] = Pbs_Notifier::notify("There is no default BootMenu, please Login to get your BootMenu.", 'info');
- } else {
-
- $this->view->notification[] = Pbs_Notifier::notify("You have no BootMenu.", 'info');
- }
- $this->view->nobootmenu = true;
- }
- } else {
-#$this->_redirect('/fbgui/index/error/serialresult/noserial');
- }
-
- }
- public function startAction() {
- $bootmenuntryID = $this->_request->getParam('bme');
- $a = $_SESSION['alphasessionID'];
- $bootmenuentriesMapper = new Application_Model_BootMenuEntriesMapper();
- $bootmenuentry = new Application_Model_BootMenuEntries();
- $bootmenuentriesMapper->find($bootmenuntryID, $bootmenuentry);
-
- $sessionMapper = new Application_Model_SessionMapper();
- $session_k = $sessionMapper->findBy(array('alphasessionID' => $a), true);
-
- $session = new Application_Model_Session();
- $session->setOptions($session_k[0]);
- $session->setID($session_k[0]['sessionID']);
-
- $session->setBootmenuentryID($bootmenuntryID);
- $session->setBootosID($bootmenuentry->getBootosID());
- $sessionMapper->save($session);
-
-
- $this->view->host = $_SERVER['REMOTE_HOST'];
- $this->view->alphasessionID = $a;
- }
+ protected $membership;
+
+ public function init() {
+ /* Initialize action controller here */
+ $userIDsNamespace = Zend_Session::namespaceGet('userIDs');
+
+ $membershipMapper = new Application_Model_MembershipMapper();
+ $this->membership = new Application_Model_Membership();
+ $membershipMapper->find($userIDsNamespace['membershipID'], $this->membership);
+ }
+
+ public function errorAction() {
+ $result = $this->_request->getParam('serialresult');
+ if($result != "") {
+
+ $this->view->notification = Pbs_Notifier::notify('serial', $result);
+ }
+ }
+
+ public function indexAction() {
+ $mySession = new Zend_Session_Namespace('pbs');
+ $this->view->notification = array();
+
+
+ if(count($mySession->postdata) <= 0) {
+ $mySession->postdata = $_POST;
+ }
+
+ $result = $this->_request->getParam('notify');
+ if($result == 'nomember') {
+
+ $this->view->notification[] = Pbs_Notifier::notify('You have no membership, therefore you have no own BootMenu', 'info');
+ }
+
+ $d = new Pbs_Debug();
+ $d->debug(array('FBGuiIndexController', $_SERVER['REMOTE_ADDR'], implode("\t", $mySession->postdata)));
+
+ if(isset($mySession->postdata['serialnumber'])) {
+ // Create a session
+ $n = new Pbs_Session();
+
+ print_a($_SERVER);
+
+ $bootisomapper = new Application_Model_BootIsoMapper();
+ $bootiso = new Application_Model_BootIso();
+
+ if(isset($mySession->postdata['serialnumber'])) {
+ $results = $bootisomapper->findBy(array('serialnumber' => $mySession->postdata['serialnumber']), true);
+ if(count($results) == 0) {
+ $this->_redirect('/fbgui/index/error/serialresult/noserial2');
+ }
+ $bootiso->setOptions($results[0]);
+ $bootiso->setID($results[0]['bootisoID']);
+ $groupID = $bootiso->getGroupID();
+
+ }
+
+ if($_SERVER['SSL_CLIENT_VERIFY'] === 'SUCCESS'){
+ //TODO User provides authentication data
+ }
+
+ $client = new Application_Model_Client();
+ $client->setMacadress($mySession->postdata['mac']);
+ $client->setHardwarehash($mySession->postdata['hardwarehash']);
+ $client->setGroupID($groupID);
+ $client->setCreated(time());
+ $client = $n->createClient($client);
+ $clientID = $client->getID();
+
+ $userIDsNamespace = Zend_Session::namespaceGet('userIDs');
+
+ if(!isset($_SESSION['alphasessionID'])) {
+ $session = new Application_Model_Session();
+ $session->setBootisoID($bootiso->getID());
+ $session->setClientID($clientID);
+ $session->setTime(time());
+ if($this->membership->getID() != '') {
+ $session->setMembershipID($this->membership->getID());
+ }
+ $session->setIp($_SERVER['REMOTE_ADDR']);
+ $session = $n->createSession($session);
+ $_SESSION['alphasessionID'] = $session->getAlphasessionID();
+ } else {
+ $session = new Application_Model_Session();
+ $sessionMapper = new Application_Model_SessionMapper();
+ $sessions = $sessionMapper->findBy(array('alphasessionID' => $_SESSION['alphasessionID']));
+ $session = $sessions[0];
+ if($this->membership->getID() != '' && $session->getMembershipID() == '') {
+ $session->setMembershipID($this->membership->getID());
+ $sessionMapper->save($session);
+ }
+ }
+ // Request Bootmenu
+ $pbsFilter = new Pbs_Filter();
+ $bootmenuID = $pbsFilter->evaluate();
+ if($bootmenuID != null) {
+ $this->view->alphasessionID = $_SESSION['alphasessionID'];
+ // print_a('Debug Output',
+ // 'Session is now set',
+ // 'Your sessionID is '.$session->getID(),
+ // 'Your alphasessionID is '.$session->getAlphasessionID(),
+ // 'Your client is '.$session->getClientID(),
+ // 'goto bootmenu '.$bootmenuID);
+
+ $bootmenuMapper = new Application_Model_BootMenuMapper();
+ $bm = $bootmenuMapper->find($bootmenuID);
+ $this->view->title = $bm->getTitle();
+ $this->view->startcounter = $bm->getStartcounter();
+
+ $bootmenuentriesMapper = new Application_Model_BootMenuEntriesMapper();
+ $res = $bootmenuentriesMapper->findBy(array('bootmenuID' => $bootmenuID), false);
+ $this->view->entries = $res;
+
+ if (!Zend_Auth::getInstance()->hasIdentity()) {
+ $this->view->loginmenu = true;
+ }
+
+ if(Zend_Auth::getInstance()->hasIdentity()) {
+ if($bm->MembershipID != '' && $bm->MembershipID == $this->membership->getID()) {
+ } else {
+
+ $this->view->notification[] = Pbs_Notifier::notify("This is not your Bootmenu. There is currently a BootMenu with a higher priority active.", 'info');
+ }
+ }
+
+ if(count($res) == 0) {
+
+ $this->view->notification[] = Pbs_Notifier::notify("There are no entries in the bootmenu.", 'info');
+ $this->view->nobootmenu = true;
+ unset($this->view->entries);
+ }
+
+
+ } else {
+ // print_a('Debug Output',
+ // 'Session is now set',
+ // 'Your sessionID is '.$session->getID(),
+ // 'Your alphasessionID is '.$session->getAlphasessionID(),
+ // 'Your client is '.$session->getClientID(),
+ // 'there is no bootmenu for you');
+ if (!Zend_Auth::getInstance()->hasIdentity()) {
+ $this->view->loginmenu = true;
+
+ $this->view->notification[] = Pbs_Notifier::notify("There is no default BootMenu, please Login to get your BootMenu.", 'info');
+ } else {
+
+ $this->view->notification[] = Pbs_Notifier::notify("You have no BootMenu.", 'info');
+ }
+ $this->view->nobootmenu = true;
+ }
+ } else {
+ $this->_redirect('/fbgui/index/error/serialresult/noserial');
+ }
+
+ }
+ public function startAction() {
+ $bootmenuntryID = $this->_request->getParam('bme');
+ $a = $_SESSION['alphasessionID'];
+ $bootmenuentriesMapper = new Application_Model_BootMenuEntriesMapper();
+ $bootmenuentry = new Application_Model_BootMenuEntries();
+ $bootmenuentriesMapper->find($bootmenuntryID, $bootmenuentry);
+
+ $sessionMapper = new Application_Model_SessionMapper();
+ $session_k = $sessionMapper->findBy(array('alphasessionID' => $a), true);
+
+ $session = new Application_Model_Session();
+ $session->setOptions($session_k[0]);
+ $session->setID($session_k[0]['sessionID']);
+
+ $session->setBootmenuentryID($bootmenuntryID);
+ $session->setBootosID($bootmenuentry->getBootosID());
+ $sessionMapper->save($session);
+
+
+ $this->view->host = $_SERVER['REMOTE_HOST'];
+ $this->view->alphasessionID = $a;
+ }
}