/** * Validate user attributes. * * @return void */ public function validateUserAttributes() { $attras = $this->object->getAttributes(); $this->assertInternalType('array', $attras); if (count($attras) != 4 || !is_array($attras['memberOf'])) { print "\n"; print_r($attras); } $this->assertEquals(4, count($attras)); $this->assertTrue($this->object->hasAttribute('givenName')); // direct access $this->assertEquals('John', $this->object->getAttribute('givenName')); // array access $this->assertArrayHasKey('givenName', $attras); $this->assertEquals('John', $attras['givenName']); $this->assertTrue($this->object->hasAttribute('surname')); // direct access $this->assertEquals('Smith', $this->object->getAttribute('surname')); // array access $this->assertArrayHasKey('surname', $attras); $this->assertEquals('Smith', $attras['surname']); $this->assertTrue($this->object->hasAttribute('memberOf')); // direct access $memberOf = $this->object->getAttribute('memberOf'); $this->assertInternalType('array', $memberOf); $this->assertEquals(2, count($memberOf)); $this->assertTrue(in_array('CN=Staff,OU=Groups,DC=example,DC=edu', $memberOf)); $this->assertTrue(in_array('CN=Spanish Department,OU=Departments,OU=Groups,DC=example,DC=edu', $memberOf)); // array access $this->assertArrayHasKey('memberOf', $attras); $this->assertInternalType('array', $attras['memberOf']); $this->assertEquals(2, count($attras['memberOf'])); $this->assertTrue(in_array('CN=Staff,OU=Groups,DC=example,DC=edu', $attras['memberOf'])); $this->assertTrue(in_array('CN=Spanish Department,OU=Departments,OU=Groups,DC=example,DC=edu', $attras['memberOf'])); }
/** * Answer attributes about the authenticated user. * * @warning should only be called after phpCAS::forceAuthentication() * or phpCAS::checkAuthentication(). * * @return array */ public static function getAttributes() { phpCAS::_validateClientExists(); try { return self::$_PHPCAS_CLIENT->getAttributes(); } catch (Exception $e) { phpCAS::error(get_class($e) . ': ' . $e->getMessage()); } }