public function testGetterSetter()
 {
     $twofactorAdapter = new twofactorAdapter();
     $this->assertEquals(".", $twofactorAdapter->getDir());
     $this->assertEquals("", $twofactorAdapter->getServiceName());
     $this->assertNotEquals("", $twofactorAdapter->getSecret());
     $twofactorAdapter->setDir(__DIR__ . "/../tests");
     $this->assertEquals(__DIR__ . "/../tests", $twofactorAdapter->getDir());
     $twofactorAdapter->setServiceName("none");
     $this->assertEquals("none", $twofactorAdapter->getServiceName());
 }
예제 #2
0
 public function __construct($dir = ".", $cookieCode = "", $serviceName = "none")
 {
     if ($cookieCode == "") {
         $cookieCode = md5(rand());
     }
     $this->dir = $dir;
     $this->cookieCode = $cookieCode;
     $this->twofactorAdapter = new twofactorAdapter();
     $this->twofactorAdapter->setDir($this->dir);
     $this->twofactorAdapter->setServiceName($serviceName);
     $secret = $this->readSecret();
     if ($secret && $secret != 1) {
         //I have a secret stored, so I set it as secret
         $this->twofactorAdapter->setSecret($secret);
     } else {
         //I don't have a secret stored so I store the secret generated by library
         $this->storeSecret($this->twofactorAdapter->getSecret());
     }
     $this->secret = $this->twofactorAdapter->getSecret();
 }