<?php

/*
 * This file is part of the AuthStack project.
 *
 * (c) Buckhill Ltd <development@buckhill.co.uk>
 *
 * This source file is subject to the Buckhill license that is bundled
 * with this source code in the file LICENSE.
 */

namespace AuthStack\SP;


use AuthStack\SP\Requests\AuthN;
use AuthStack\SP\Requests\Logout;
use LightSaml\Model\Protocol\Response;
use Symfony\Component\HttpFoundation\Request;
use AuthStack\SP\Responses\Logout as LogoutResponse;

/**
 * Class ACS
 * @package AuthStack\SP
 */
class ServiceProvider extends AbstractSP
{
    public function consume(Request $request = null)
    {
        $response = $this->checkRequest($request);

        $assertion = $this->getAssertions($response);

        $collection = AttributeCollection::fromAssertion($assertion);



        return $collection;
    }


    /**
     * @return Response
     */
    public function response()
    {
        return $this->response;
    }


    /**
     * @return AuthN
     */
    public function authn()
    {
        return new AuthN($this->idp);
    }


    /**
     * @param Request|null $request
     *
     * @return LogoutResponse
     */
    public function consumeLogout(Request $request = null)
    {
        $response = $this->checkRequest($request);

        $logout = new LogoutResponse($this->idp, $response);

        return $logout;
    }


    /**
     * @return Logout
     */
    public function createLogout()
    {
        return new Logout($this->idp);
    }
}
