/**
  * Starts the Uni-Login login process (by redirecting the user to the authentication provider).
  *
  * @return void
  */
 public function login()
 {
     // Default callback url
     $url = ['action' => 'callback'];
     $returnUrl = $this->request->query('returnUrl');
     if ($returnUrl) {
         $url['?'] = ['returnUrl' => Router::url($returnUrl)];
     }
     $url = Router::url($url, true);
     $query = ['path' => UniLoginUtil::encodeUrl($url), 'auth' => UniLoginUtil::calculateUrlFingerprint($url), 'id' => Configure::read('UniLogin.provider.applicationId')];
     $redirectUrl = Configure::read('UniLogin.provider.url');
     $redirectUrl .= '?' . http_build_query($query);
     return $this->redirect($redirectUrl);
 }
 /**
  * testAuthenticateRedirectUrlParameterWithoutApplicationId method
  *
  * @return void
  */
 public function testAuthenticateRedirectUrlParameterWithoutApplicationId()
 {
     $url = 'http://www.mydomain.com';
     $path = UniLoginUtil::encodeUrl($url);
     $auth = UniLoginUtil::calculateUrlFingerprint($url);
     $this->testAction('/uni_login/test_provider/authenticate', ['data' => ['path' => $path, 'auth' => $auth], 'method' => 'get']);
     $this->assertContains($url, $this->headers['Location']);
     $this->assertNotContains('user='******'Location']);
     $this->assertNotContains('timestamp=', $this->headers['Location']);
     $this->assertNotContains('auth=', $this->headers['Location']);
 }
 /**
  * Tests `UniLoginUtil::calculateUrlFingerprint`.
  *
  * @return void
  */
 public function testCalculateUrlFingerprint()
 {
     $url = 'http://www.emu.dk/appl';
     $expected = '59169cb39fab40cb0ad6ade6a6eb491e';
     $result = UniLoginUtil::calculateUrlFingerprint($url);
     $this->assertEquals($expected, $result);
 }