LdapServiceFactory.php 1.05 KB
Newer Older
1
2
3
4
<?php

namespace UnicaenAuth\Provider\Identity;

5
use Interop\Container\ContainerInterface;
6
7
8
9
10
11
12
13
14
15
16
17
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;

/**
 * LDAP identity provider factory
 *
 * @author Bertrand GAUTHIER <bertrand.gauthier@unicaen.fr>
 */
class LdapServiceFactory implements FactoryInterface
{
    /**
     * {@inheritDoc}
18
     * @deprecated
19
20
21
     */
    public function createService(ServiceLocatorInterface $serviceLocator)
    {
22
23
24
25
26
27
28
        return $this->__invoke($serviceLocator, '?');
    }

    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
    {
        $config                 = $container->get('BjyAuthorize\Config');
        $user                   = $container->get('zfcuser_user_service');
29
        $simpleIdentityProvider = new Ldap($user->getAuthService());
30

31
32
33
34
35
36
        $simpleIdentityProvider->setDefaultRole($config['default_role']);
        $simpleIdentityProvider->setAuthenticatedRole($config['authenticated_role']);

        return $simpleIdentityProvider;
    }
}