Ejemplo n.º 1
0
    public function testClaims() 
    {
		$infoCard = new Zend_InfoCard();
		
		$infoCard->addCertificatePair($this->sslPrvKey, $this->sslPubKey);

		$claims = $infoCard->process($this->_xmlDocument);
		
		$this->assertTrue($claims instanceof Zend_InfoCard_Claims);

		$this->assertFalse($claims->isValid());
		
		$this->assertSame($claims->getCode(), Zend_InfoCard_Claims::RESULT_VALIDATION_FAILURE);
		
		$errormsg = $claims->getErrorMsg();
		$this->assertTrue(!empty($errormsg));
		
		
		@$claims->forceValid();
		
		$this->assertTrue($claims->isValid());
		
		$this->assertSame($claims->emailaddress, "*****@*****.**");
		$this->assertSame($claims->givenname, "John");
		$this->assertSame($claims->surname, "Coggeshall");
		$this->assertSame($claims->getCardID(), "rW1/y9BuncoBK4WSipF2hHYParxxgMHk6ANBrhz1Zr4=");
		$this->assertSame($claims->getClaim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress"), "*****@*****.**");
		$this->assertSame($claims->getDefaultNamespace(), "http://schemas.xmlsoap.org/ws/2005/05/identity/claims");
		
		try {
			unset($claims->givenname);
		} catch(Zend_InfoCard_Exception $e) {
			
		} catch(Exception $e) {
			$this->assertFalse(true);
		}
		
		
		try {
			$claims->givenname = "Test";
		} catch(Zend_InfoCard_Exception $e) {
			
		} catch(Exception $e) {
			$this->assertFalse(true);
		}
		
		$this->assertTrue(isset($claims->givenname));
	}
Ejemplo n.º 2
0
 /**
  * Add a Certificate Pair to the list of certificates searched by the component
  *
  * @param  string $private_key_file    The path to the private key file for the pair
  * @param  string $public_key_file     The path to the certificate / public key for the pair
  * @param  string $type                (optional) The URI for the type of key pair this is (default RSA with OAEP padding)
  * @param  string $password            (optional) The password for the private key file if necessary
  * @throws Zend_InfoCard_Exception
  * @return string A key ID representing this key pair in the component
  */
 public function addCertificatePair($private_key_file, $public_key_file, $type = Zend_InfoCard_Cipher::ENC_RSA_OAEP_MGF1P, $password = null)
 {
     return $this->_infoCard->addCertificatePair($private_key_file, $public_key_file, $type, $password);
 }
Ejemplo n.º 3
0
 public function testClaims()
 {
     if (version_compare(PHP_VERSION, '5.2.0', '<')) {
         $this->markTestSkipped('DOMDocument::C14N() not available until PHP 5.2.0');
     }
     try {
         $infoCard = new Zend_InfoCard();
     } catch (Zend_InfoCard_Exception $e) {
         $message = $e->getMessage();
         if (preg_match('/requires.+mcrypt/', $message)) {
             $this->markTestSkipped($message);
         } else {
             throw $e;
         }
     }
     $infoCard->addCertificatePair($this->sslPrvKey, $this->sslPubKey);
     $claims = $infoCard->process($this->_xmlDocument);
     $this->assertTrue($claims instanceof Zend_InfoCard_Claims);
     $this->assertFalse($claims->isValid());
     $this->assertSame($claims->getCode(), Zend_InfoCard_Claims::RESULT_VALIDATION_FAILURE);
     $errormsg = $claims->getErrorMsg();
     $this->assertTrue(!empty($errormsg));
     @$claims->forceValid();
     $this->assertTrue($claims->isValid());
     $this->assertSame($claims->emailaddress, "*****@*****.**");
     $this->assertSame($claims->givenname, "John");
     $this->assertSame($claims->surname, "Coggeshall");
     $this->assertSame($claims->getCardID(), "rW1/y9BuncoBK4WSipF2hHYParxxgMHk6ANBrhz1Zr4=");
     $this->assertSame($claims->getClaim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress"), "*****@*****.**");
     $this->assertSame($claims->getDefaultNamespace(), "http://schemas.xmlsoap.org/ws/2005/05/identity/claims");
     try {
         unset($claims->givenname);
     } catch (Zend_InfoCard_Exception $e) {
     } catch (Exception $e) {
         $this->assertFalse(true);
     }
     try {
         $claims->givenname = "Test";
     } catch (Zend_InfoCard_Exception $e) {
     } catch (Exception $e) {
         $this->assertFalse(true);
     }
     $this->assertTrue(isset($claims->givenname));
 }