public function testContructsAnInstanceFromHttpSessionAndSsoUser() { $samlResp = new SamlMnoRespStub(); $user = new Maestrano_Sso_User($samlResp); $this->subject = new Maestrano_Sso_Session($this->httpSession, $user); $this->assertEquals($this->httpSession, $this->subject->getHttpSession()); $this->assertEquals($user->getUid(), $this->subject->getUid()); $this->assertEquals($user->getGroupUid(), $this->subject->getGroupUid()); $this->assertEquals($user->getSsoSession(), $this->subject->getSessionToken()); $this->assertEquals($user->getSsoSessionRecheck(), $this->subject->getRecheck()); }
/** * Extend constructor to inialize app specific objects * * @param OneLogin_Saml_Response $saml_response * A SamlResponse object from Maestrano containing details * about the user being authenticated */ public function __construct($saml_response, $opts = array()) { // Call Parent parent::__construct($saml_response); // Assign new attributes $this->connection = $opts['db_connection']; }
/** * Used by findOrCreate to create a local user * based on the sso user. * If the method returns null then access is denied * * @param Maestrano_Sso_User $mnoUser * @return the the user created, null otherwise * @throws Exception */ public function findOrCreate($mnoUser) { $result = array(); $sql = "SELECT COUNT(*) FROM " . _DB_PREFIX_ . "employee WHERE email = '" . pSQL($mnoUser->email) . "'"; $totalShop = Db::getInstance()->getValue($sql); if ($totalShop == 0) { $passwd = md5(pSQL(_COOKIE_KEY_ . $this->generatePassword())); Db::getInstance()->insert('employee', array('id_profile' => (int) $this->id_profile, 'id_lang' => (int) $this->getCurrentLanguage(), 'lastname' => pSQL($mnoUser->getLastName()), 'firstname' => pSQL($mnoUser->getFirstName()), 'email' => pSQL($mnoUser->email), 'passwd' => pSQL($passwd), 'default_tab' => 1, 'active' => 1)); $result['id_employee'] = Db::getInstance()->Insert_ID(); $result['passwd'] = $passwd; $result['id_profile'] = $this->id_profile; return $result; } else { $sql = "SELECT id_employee,passwd,id_profile FROM " . _DB_PREFIX_ . "employee WHERE email = '" . pSQL($mnoUser->email) . "'"; if ($row = Db::getInstance()->getRow($sql)) { $result['id_employee'] = $row['id_employee']; $result['passwd'] = $row['passwd']; $result['id_profile'] = $row['id_profile']; return $result; } return false; } return false; }