public function register(SecurityServiceProvider $provider)
    {
        $this->provider = $provider;

        if ($this->loginPath) {
            $this->provider->addUnsecurePattern("^{$this->loginPath}$");
        }

        $config = array(
            'logout' => array('logout_path' => $this->logoutPath),
            'pattern' => implode('|', $this->patterns)
        );

        $app = $this->provider->getApp();

        foreach ($this->authFactories as $id => $authFactory) {
            $this->registerAuthenticationFactory($app, $id, $authFactory['factory'], $authFactory['userProvider']);
            $config[$id] = array();
            if ($this->loginPath) {
                $config[$id]['login_path'] = $this->loginPath;
                $config[$id]['check_path'] = $this->loginCheckPath;
            }
        }

        $this->registerUserProvider($app);
        $this->registerContextListener($app);
        $this->registerEntryPoint($app);

        $this->provider->appendFirewallConfig($this->name, $config);
    }