/**
  * Generates an URI representing the authorization request.
  *
  * @param Request $request
  * @return string
  */
 public function createAuthorizationRequestUri(Request $request)
 {
     /* @var $clientInfo \InoOicClient\Client\ClientInfo */
     $clientInfo = $request->getClientInfo();
     if (!$clientInfo) {
         throw new \RuntimeException('Missing client info in request');
     }
     if (($endpointUri = $clientInfo->getAuthorizationEndpoint()) === null) {
         throw new Exception\MissingEndpointException('No endpoint specified');
     }
     $uri = new Uri($endpointUri);
     $params = array(Param::CLIENT_ID => $clientInfo->getClientId(), Param::REDIRECT_URI => $clientInfo->getRedirectUri(), Param::RESPONSE_TYPE => $this->arrayToSpaceDelimited($request->getResponseType()), Param::SCOPE => $this->arrayToSpaceDelimited($request->getScope()), Param::STATE => $request->getState());
     foreach ($params as $name => $value) {
         if (in_array($name, $this->requiredParams) && empty($value)) {
             throw new Exception\MissingFieldException($name);
         }
     }
     $uri->setQuery($params);
     return $uri->toString();
 }
 public function testConstructor()
 {
     $responseType = array('code', 'token');
     $scope = array('openid', 'email');
     $state = 'abc';
     $extraParams = array('nonce' => 'bar');
     $clientInfo = $this->createClientInfoMock();
     $request = new Request($clientInfo, $responseType, $scope, $state, $extraParams);
     $this->assertSame($clientInfo, $request->getClientInfo());
     $this->assertSame($responseType, $request->getResponseType());
     $this->assertSame($scope, $request->getScope());
     $this->assertSame($state, $request->getState());
     $params = $request->toArray();
     $this->assertArrayHasKey('nonce', $params);
     $this->assertSame('bar', $params['nonce']);
 }
 /**
  * Generates a request URI for the corresponding authorization request.
  * 
  * @param Request $request
  * @return string
  */
 public function createAuthorizationRequestUri(Request $request)
 {
     if ($stateManager = $this->getStateManager()) {
         $state = $stateManager->initState();
         $request->setState($state->getHash());
     }
     $this->setLastRequest($request);
     return $this->getUriGenerator()->createAuthorizationRequestUri($request);
 }