Skip to content

Commit

Permalink
Merge pull request #22 from Deamon/feat-change-security-service
Browse files Browse the repository at this point in the history
Replacing security.context to security.token_storage
  • Loading branch information
ztec committed Apr 13, 2016
2 parents 87b919c + 40cb2e2 commit e794b33
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ php_ldap

ssl configuration for LDAP. see http://adldap.sourceforge.net/wiki/doku.php?id=ldap_over_ssl

Compatible with Symfony 2 starting from 2.1
Compatible with Symfony 2 starting from 2.6


Installation
Expand Down
2 changes: 1 addition & 1 deletion Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ services:

riper.security.active.directory.factory.adldap:
class: Riper\Security\ActiveDirectoryBundle\Security\Factory\AdldapFactory
arguments: [ "@security.context", "@riper.security.active.directory.service.adldap" ]
arguments: [ "@security.token_storage", "@riper.security.active.directory.service.adldap" ]
15 changes: 7 additions & 8 deletions Security/Factory/AdldapFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,34 @@

namespace Riper\Security\ActiveDirectoryBundle\Security\Factory;


use Riper\Security\ActiveDirectoryBundle\Exception\WrongTokenException;
use Riper\Security\ActiveDirectoryBundle\Service\AdldapService;
use Riper\Security\ActiveDirectoryBundle\Token\FaultyToken;
use Symfony\Component\Security\Core\SecurityContext;
use Riper\Security\ActiveDirectoryBundle\Security\Token\FaultyToken;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;

class AdldapFactory
{

/**
* @var SecurityContext
* @var TokenStorage
*/
private $securityContext;
private $tokenStorage;

/**
* @var AdldapService
*/
private $adldapService;

public function __construct(SecurityContext $securityContext, AdldapService $adldapService)
public function __construct(TokenStorage $tokenStorage, AdldapService $adldapService)
{
$this->securityContext = $securityContext;
$this->tokenStorage = $tokenStorage;
$this->adldapService = $adldapService;
}


public function getAuthenticatedAdLdap()
{
$token = $this->securityContext->getToken();
$token = $this->tokenStorage->getToken();
if ($token instanceof FaultyToken) {
throw new WrongTokenException(
'The token is not the right one. Did you forget to set "keep_password_in_token" to "true" in bundle configuration ?'
Expand Down

0 comments on commit e794b33

Please sign in to comment.