/**
  * launchkey_form - login form for wp-login.php
  *
  * @since 1.1.0
  *
  * @param string $class A space separated list of classes to set on the "class" attribute of a containing DIV for the login button
  * @param string $id The value to set on the "id" attribute of a containing DIV for the login button
  * @param string $style A string of HTML style code tto set on the "style" attribute of a containing DIV for the login button
  */
 public function launchkey_form($class = '', $id = '', $style = '')
 {
     if (isset($_GET['launchkey_error'])) {
         $this->wp_facade->_echo($this->template->render_template('error', array('error' => 'Error!', 'message' => 'The LaunchKey request was denied or an issue was detected during authentication. Please try again.')));
     } elseif (isset($_GET['launchkey_ssl_error'])) {
         $this->wp_facade->_echo($this->template->render_template('error', array('error' => 'Error!', 'message' => 'There was an error trying to request the LaunchKey servers. If this persists you may need to disable SSL verification.')));
     } elseif (isset($_GET['launchkey_security'])) {
         $this->wp_facade->_echo($this->template->render_template('error', array('error' => 'Error!', 'message' => 'There was a security issue detected and you have been logged out for your safety. Log back in to ensure a secure session.')));
     }
     $container = SAML2_Utils::getContainer();
     $request = new SAML2_AuthnRequest();
     $request->setId($container->generateId());
     //$request->setProviderName( parse_url( $this->wp_facade->home_url( '/' ), PHP_URL_HOST ) );
     $request->setDestination($this->login_url);
     $request->setIssuer($this->entity_id);
     $request->setRelayState($this->wp_facade->admin_url());
     $request->setAssertionConsumerServiceURL($this->wp_facade->wp_login_url());
     $request->setProtocolBinding(SAML2_Const::BINDING_HTTP_POST);
     $request->setIsPassive(false);
     $request->setNameIdPolicy(array('Format' => SAML2_Const::NAMEID_PERSISTENT, 'AllowCreate' => true));
     // Send it off using the HTTP-Redirect binding
     $binding = new SAML2_HTTPRedirect();
     $binding->setDestination($this->login_url);
     $this->wp_facade->_echo($this->template->render_template('launchkey-form', array('class' => $class, 'id' => $id, 'style' => $style, 'login_url' => $binding->getRedirectURL($request), 'login_text' => 'Log in with', 'login_with_app_name' => 'LaunchKey', 'size' => in_array($this->wp_facade->get_locale(), array('fr_FR', 'es_ES')) ? 'small' : 'medium')));
 }
 /**
  * @param WP_User $user
  * @param string $implementation_type
  * @param int $rocket_key
  * @param string $app_display_name
  *
  * @return string
  */
 private function handle_pair(WP_User $user, $implementation_type, $rocket_key, $app_display_name)
 {
     if (LaunchKey_WP_Implementation_Type::OAUTH === $implementation_type) {
         $display = $this->template->render_template('personal-options/unpaired-oauth', array('app_display_name' => $app_display_name, 'pair_uri' => sprintf('https://oauth.launchkey.com/authorize?client_id=%s&redirect_uri=%s', $rocket_key, $this->wp_facade->admin_url('/admin-ajax.php?action=launchkey-callback&launchkey_admin_pair=1'))));
     } elseif (LaunchKey_WP_Implementation_Type::NATIVE === $implementation_type) {
         $display = $this->template->render_template('personal-options/unpaired-native', array('app_display_name' => $app_display_name, 'nonce' => $this->wp_facade->wp_create_nonce(static::NONCE_KEY)));
     } elseif (LaunchKey_WP_Implementation_Type::WHITE_LABEL == $implementation_type) {
         $nonce = $this->wp_facade->wp_create_nonce(static::NONCE_KEY);
         $display = $this->template->render_template('personal-options/white-label', array('app_display_name' => $app_display_name, 'nonce' => $nonce, 'pair_uri' => $this->wp_facade->admin_url('/admin-ajax.php?action=' . LaunchKey_WP_Native_Client::WHITE_LABEL_PAIR_ACTION), 'paired' => isset($user->launchkey_username) ? 'true' : 'false', 'has_password' => empty($user->user_pass) ? 'false' : 'true', 'password_remove_uri' => $this->wp_facade->admin_url('/profile.php?launchkey_remove_password=1&launchkey_nonce=' . $nonce)));
     }
     return $display;
 }
 /**
  * launchkey_form - login form for wp-login.php
  *
  * @since 1.0.0
  *
  * @param string $class A space separated list of classes to set on the "class" attribute of a containing DIV for the login button
  * @param string $id The value to set on the "id" attribute of a containing DIV for the login button
  * @param string $style A string of HTML style code tto set on the "style" attribute of a containing DIV for the login button
  */
 public function launchkey_form($class = '', $id = '', $style = '')
 {
     $options = $this->get_option();
     if (isset($_GET['launchkey_error'])) {
         $this->wp_facade->_echo($this->template->render_template('error', array('error' => 'Error!', 'message' => 'The LaunchKey request was denied or an issue was detected during authentication. Please try again.')));
     } elseif (isset($_GET['launchkey_ssl_error'])) {
         $this->wp_facade->_echo($this->template->render_template('error', array('error' => 'Error!', 'message' => 'There was an error trying to request the LaunchKey servers. If this persists you may need to disable SSL verification.')));
     } elseif (isset($_GET['launchkey_security'])) {
         $this->wp_facade->_echo($this->template->render_template('error', array('error' => 'Error!', 'message' => 'There was a security issue detected and you have been logged out for your safety. Log back in to ensure a secure session.')));
     }
     if (isset($_GET['launchkey_pair'])) {
         $this->wp_facade->_echo($this->template->render_template('auth-message', array('alert' => 'Almost finished!', 'message' => 'Log in with your WordPress username and password for the last time to finish the user pair process. After this you can login exclusively with LaunchKey!')));
     } else {
         $this->wp_facade->_echo($this->template->render_template('launchkey-form', array('class' => $class, 'id' => $id, 'style' => $style, 'login_url' => sprintf('%s/authorize?client_id=%s&redirect_uri=%s', $this->base_url, $options[LaunchKey_WP_Options::OPTION_ROCKET_KEY], urlencode($this->wp_facade->admin_url('admin-ajax.php?action=launchkey-callback'))), 'login_text' => 'Log in with', 'login_with_app_name' => $options[LaunchKey_WP_Options::OPTION_APP_DISPLAY_NAME], 'size' => in_array($this->wp_facade->get_locale(), array('fr_FR', 'es_ES')) ? 'small' : 'medium')));
     }
 }
 private function render_template($template, $context = array())
 {
     $this->wp_facade->_echo($this->template->render_template($template, $context));
 }
 /**
  * Display the "Processing Login" animation
  *
  * @since 1.0.0
  */
 public function progress_bar()
 {
     $this->wp_facade->_echo($this->template->render_template('progress-bar', array('processing' => 'Processing login')));
 }
 /**
  * @requires test_render_template_reads_correct_file
  */
 public function test_render_template_replaces_all_the_placeholders_with_translated_context_items()
 {
     $expected = "<template>\n    <key1>Translated [value1]</key1>\n    <key2>Translated [value2]</key2>\n</template>";
     $actual = $this->template->render_template('template', array('key1' => 'value1', 'key2' => 'value2'));
     $this->assertEquals($expected, $actual);
 }