Permalink
Browse files

CS

  • Loading branch information...
1 parent 8d2b8a4 commit b64eb9be92e58e635bab20e3c7dca420297bb234 @Maks3w committed Jun 6, 2012
@@ -43,11 +43,13 @@ public function bind($user_dn, $password)
}
if (!$user_dn) {
$this->logInfo('You must bind with an ldap user_dn');
+
return false;
}
if (!$password) {
$this->logInfo('Password can not be null to bind');
+
return false;
}
@@ -13,7 +13,7 @@
/**
* Bind to LDAP directory
*/
- function bind($user_dn, $password);
+ public function bind($user_dn, $password);
- function search($baseDn, $filter, array $attributes = array());
+ public function search($baseDn, $filter, array $attributes = array());
}
View
@@ -14,7 +14,7 @@ public function boot()
throw new \Exception("module php-ldap isn't install");
}
}
-
+
/* Require Symfony > 2.1.x
public function build(ContainerBuilder $container)
{
View
@@ -32,6 +32,7 @@ public static function ascToHex32($string)
$string = str_replace($char, '\\' . $hex, $string);
}
}
+
return $string;
}
@@ -49,6 +50,7 @@ public static function ascToHex32($string)
public static function hex32ToAsc($string)
{
$string = preg_replace("/\\\([0-9A-Fa-f]{2})/e", "''.chr(hexdec('\\1')).''", $string);
+
return $string;
}
-}
+}
View
@@ -59,8 +59,8 @@ public function findUserBy(array $criteria)
/**
* Build Ldap filter
*
- * @param array $criteria
- * @param string $condition
+ * @param array $criteria
+ * @param string $condition
* @return string
*/
private function buildFilter(array $criteria, $condition = '&')
@@ -77,10 +77,10 @@ private function buildFilter(array $criteria, $condition = '&')
/**
* Hydrates an user entity with ldap attributes.
- *
+ *
* @param LdapUserInterface $user user to hydrate
* @param array $entry ldap result
- *
+ *
* @return LdapUserInterface
*/
protected function hydrate(LdapUserInterface $user, array $entry)
@@ -133,6 +133,7 @@ public static function escapeValue($values = array())
}
$values[$key] = $val;
}
+
return (count($values) == 1 && array_key_exists(0, $values)) ? $values[0] : $values;
}
@@ -155,6 +156,7 @@ public static function unescapeValue($values = array())
// Translate hex code into ascii
$values[$key] = Converter::hex32ToAsc($value);
}
+
return (count($values) == 1 && array_key_exists(0, $values)) ? $values[0] : $values;
}
}
@@ -10,27 +10,27 @@
/**
* Find a user by its username.
*
- * @param string $username
- * @return \Symfony\Component\Security\Core\User\UserInterface or null if user does not exist
+ * @param string $username
+ * @return \Symfony\Component\Security\Core\User\UserInterface|null The user or null if the user does not exist
*/
- function findUserByUsername($username);
+ public function findUserByUsername($username);
/**
* Finds one user by the given criteria.
*
- * @param array $criteria
+ * @param array $criteria
* @return \Symfony\Component\Security\Core\User\UserInterface
*/
- function findUserBy(array $criteria);
+ public function findUserBy(array $criteria);
/**
* Bind the user on ldap
*
- * @param LdapUserInterface $user
- * @param string $password
+ * @param LdapUserInterface $user
+ * @param string $password
* @return Boolean
*/
- function bind(LdapUserInterface $user, $password);
+ public function bind(LdapUserInterface $user, $password);
/**
* Escapes the given VALUES according to RFC 2254 so that they can be safely used in LDAP filters.
@@ -9,12 +9,12 @@
*
* @param string $dn Distinguished Name
*/
- function setDn($dn);
+ public function setDn($dn);
/**
* Get Ldap Distinguished Name
*
* @return string Distinguished Name
*/
- function getDn();
+ public function getDn();
}
@@ -12,14 +12,14 @@
*
* @return LdapUserInterface
*/
- function createUser();
+ public function createUser();
/**
* Find a user by his username.
*
* @param string $username
- *
+ *
* @return LdapUserInterface|null
*/
- function findUserByUsername($username);
+ public function findUserByUsername($username);
}
@@ -3,7 +3,7 @@
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
-
+
<services>
<service id="security.authentication.factory.ldap" class="FR3D\LdapBundle\Security\Factory\LdapFactory" public="false">
<tag name="security.listener.factory" />
@@ -19,25 +19,25 @@
<tag name="monolog.logger" channel="ldap_connection" />
<argument type="service" id="logger" />
</service>
-
+
<service id="fr3d_ldap.ldap_manager.default" class="%fr3d_ldap.ldap_manager.class%">
<argument type="service" id="fr3d_ldap.client" />
<argument type="service" id="fr3d_ldap.user_manager" />
<argument>%fr3d_ldap.ldap_manager.parameters%</argument>
</service>
-
+
<service id="fr3d_ldap.security.user.provider" class="%fr3d_ldap.security.user.provider.class%">
<argument type="service" id="fr3d_ldap.ldap_manager" />
<tag name="monolog.logger" channel="security" />
<argument type="service" id="logger" />
</service>
-
+
<service id="fr3d_ldap.security.authentication.provider" class="%fr3d_ldap.security.authentication.provider.class%">
<argument type="service" id="security.user_checker" />
<argument /> <!-- Provider-key -->
<argument /> <!-- User Provider -->
<argument type="service" id="fr3d_ldap.ldap_manager" />
</service>
</services>
-
+
</container>
@@ -17,4 +17,4 @@
</services>
-</container>
+</container>
@@ -1,3 +1,3 @@
fr3d_ldap:
username:
- already_used: The username is already used
+ already_used: The username is already used
@@ -96,4 +96,4 @@ protected function checkAuthentication(UserInterface $user, UsernamePasswordToke
}
}
}
-}
+}
@@ -37,4 +37,4 @@ protected function createAuthProvider(ContainerBuilder $container, $id, $config,
return $provider;
}
-}
+}
@@ -2,7 +2,6 @@
namespace FR3D\LdapBundle\Security\User;
-use FR3D\LdapBundle\Model\LdapUserInterface;
use FR3D\LdapBundle\Ldap\LdapManagerInterface;
use Symfony\Component\Security\Core\User\UserProviderInterface;
use Symfony\Component\Security\Core\User\UserInterface;
@@ -78,7 +78,6 @@ public function testConstruct()
$propertyLdapUsernameAttr = $reflectionClass->getProperty('ldapUsernameAttr');
$propertyLdapUsernameAttr->setAccessible(true);
-
$this->assertEquals(array('uid', 'mail'), $propertyLdapAttributes->getValue($this->ldapManager));
$this->assertEquals('uid', $propertyLdapUsernameAttr->getValue($this->ldapManager));
}
@@ -3,7 +3,6 @@
namespace FR3D\LdapBundle\Tests\Security\User;
use FR3D\LdapBundle\Security\User\LdapUserProvider;
-use FR3D\LdapBundle\Ldap\LdapManagerInterface;
use FR3D\LdapBundle\Tests\TestUser;
class LdapUserProviderTest extends \PHPUnit_Framework_TestCase
@@ -67,4 +67,4 @@ public function testBadType()
{
$this->validator->isValid('bad_type', $this->constraint);
}
-}
+}
View
@@ -43,4 +43,4 @@ public function getTargets()
{
return self::CLASS_CONSTRAINT;
}
-}
+}
@@ -44,7 +44,7 @@ public function __construct(LdapManagerInterface $ldapManager)
* @param Constraint $constraint The constrain for the validation
*
* @return Boolean Whether or not the value is valid
- *
+ *
* @throws UnexpectedTypeException if $value is not instance of \Symfony\Component\Security\Core\User\UserInterface
*/
public function isValid($value, Constraint $constraint)
@@ -59,9 +59,10 @@ public function isValid($value, Constraint $constraint)
$this->setMessage($constraint->message, array(
'%property%' => $constraint->property
));
+
return false;
}
return true;
}
-}
+}

0 comments on commit b64eb9b

Please sign in to comment.