Skip to content
Snippets Groups Projects
Commit f499612c authored by Olav Morken's avatar Olav Morken
Browse files

SimpleSAML_AuthMemCookie: Replace getValue(...) with more specific get-functions.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1676 44740490-163a-0410-bde0-09ae8108e29a
parent ad447b16
No related branches found
No related tags found
No related merge requests found
...@@ -47,10 +47,10 @@ class SimpleSAML_AuthMemCookie { ...@@ -47,10 +47,10 @@ class SimpleSAML_AuthMemCookie {
/** /**
* Retrieve the login method which should be used to authenticate the user. * Retrieve the login method which should be used to authenticate the user.
* *
* @return The login type which should be used for Auth MemCookie. * @return string The login type which should be used for Auth MemCookie.
*/ */
public function getLoginMethod() { public function getLoginMethod() {
$loginMethod = $this->amcConfig->getValue('loginmethod', 'saml2'); $loginMethod = $this->amcConfig->getString('loginmethod', 'saml2');
$supportedLogins = array( $supportedLogins = array(
'saml2', 'saml2',
'shib13', 'shib13',
...@@ -66,10 +66,10 @@ class SimpleSAML_AuthMemCookie { ...@@ -66,10 +66,10 @@ class SimpleSAML_AuthMemCookie {
/** /**
* This function retrieves the name of the cookie from the configuration. * This function retrieves the name of the cookie from the configuration.
* *
* @return The name of the cookie. * @return string The name of the cookie.
*/ */
public function getCookieName() { public function getCookieName() {
$cookieName = $this->amcConfig->getValue('cookiename', 'AuthMemCookie'); $cookieName = $this->amcConfig->getString('cookiename', 'AuthMemCookie');
if(!is_string($cookieName) || strlen($cookieName) === 0) { if(!is_string($cookieName) || strlen($cookieName) === 0) {
throw new Exception('Configuration option \'cookiename\' contains an invalid value. This option should be a string.'); throw new Exception('Configuration option \'cookiename\' contains an invalid value. This option should be a string.');
} }
...@@ -81,13 +81,10 @@ class SimpleSAML_AuthMemCookie { ...@@ -81,13 +81,10 @@ class SimpleSAML_AuthMemCookie {
/** /**
* This function retrieves the name of the attribute which contains the username from the configuration. * This function retrieves the name of the attribute which contains the username from the configuration.
* *
* @return The name of the attribute which contains the username. * @return string The name of the attribute which contains the username.
*/ */
public function getUsernameAttr() { public function getUsernameAttr() {
$usernameAttr = $this->amcConfig->getValue('username'); $usernameAttr = $this->amcConfig->getString('username', NULL);
if($usernameAttr === NULL) {
throw new Exception('Missing required configuration option \'username\' in authmemcookie.php.');
}
return $usernameAttr; return $usernameAttr;
} }
...@@ -96,10 +93,10 @@ class SimpleSAML_AuthMemCookie { ...@@ -96,10 +93,10 @@ class SimpleSAML_AuthMemCookie {
/** /**
* This function retrieves the name of the attribute which contains the groups from the configuration. * This function retrieves the name of the attribute which contains the groups from the configuration.
* *
* @return The name of the attribute which contains the groups. * @return string The name of the attribute which contains the groups.
*/ */
public function getGroupsAttr() { public function getGroupsAttr() {
$groupsAttr = $this->amcConfig->getValue('groups'); $groupsAttr = $this->amcConfig->getString('groups', NULL);
return $groupsAttr; return $groupsAttr;
} }
...@@ -108,21 +105,12 @@ class SimpleSAML_AuthMemCookie { ...@@ -108,21 +105,12 @@ class SimpleSAML_AuthMemCookie {
/** /**
* This function creates and initializes a Memcache object from our configuration. * This function creates and initializes a Memcache object from our configuration.
* *
* @return A Memcache object initialized from our configuration. * @return Memcache A Memcache object initialized from our configuration.
*/ */
public function getMemcache() { public function getMemcache() {
$memcacheHost = $this->amcConfig->getValue('memcache.host', '127.0.0.1'); $memcacheHost = $this->amcConfig->getString('memcache.host', '127.0.0.1');
if(!is_string($memcacheHost)) { $memcachePort = $this->amcConfig->getInteger('memcache.port', 11211);
throw new Exception('Invalid value of the \'memcache.host\' configuration option. This option' .
' should be a string with a hostname or a string with an IP address.');
}
$memcachePort = $this->amcConfig->getValue('memcache.port', 11211);
if(!is_int($memcachePort)) {
throw new Exception('Invalid value of the \'memcache.port\' configuration option. This option' .
' should be an integer.');
}
$memcache = new Memcache; $memcache = new Memcache;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment