/**
  * Retrieve the messages and show them
  */
 public function displayAllMessages()
 {
     $messageArray = PostmanSession::getInstance()->getMessage();
     if ($messageArray) {
         PostmanSession::getInstance()->unsetMessage();
         foreach ($messageArray as $m) {
             $type = $m['type'];
             switch ($type) {
                 case 'error':
                     $className = self::ERROR_CLASS;
                     break;
                 case 'warning':
                     $className = self::WARNING_CLASS;
                     break;
                 default:
                     $className = self::SUCCESS_CLASS;
                     break;
             }
             $message = $m['message'];
             $this->printMessage($message, $className);
         }
     }
 }
 /**
  * This method is called when a user clicks on a "Request Permission from Google" link.
  * This link will create a remote API call for Google and redirect the user from WordPress to Google.
  * Google will redirect back to WordPress after the user responds.
  */
 public function handleOAuthPermissionRequestAction()
 {
     $this->logger->debug('handling OAuth Permission request');
     $authenticationManager = PostmanAuthenticationManagerFactory::getInstance()->createAuthenticationManager(PostmanTransportRegistry::getInstance()->getCurrentTransport(), $this->options, $this->authorizationToken);
     $transactionId = $authenticationManager->generateRequestTransactionId();
     PostmanSession::getInstance()->setOauthInProgress($transactionId);
     $authenticationManager->requestVerificationCode($transactionId);
 }
 /**
  * Sanitize a Basic Auth password, and base64-encode it
  *
  * @param unknown $desc        	
  * @param unknown $key        	
  * @param unknown $input        	
  * @param unknown $new_input        	
  */
 private function sanitizePassword($desc, $key, $input, &$new_input, $existingPassword)
 {
     // WordPress calling Sanitize twice is a known issue
     // https://core.trac.wordpress.org/ticket/21989
     $action = PostmanSession::getInstance()->getAction();
     // if $action is not empty, then sanitize has already run
     if (!empty($action)) {
         // use the already encoded password in the $input
         $new_input[$key] = $input[$key];
         // log it
         $this->logger->debug('Warning, second sanitizePassword attempt detected');
     } else {
         if (isset($input[$key])) {
             if (strlen($input[$key]) > 0 && preg_match('/^\\**$/', $input[$key])) {
                 // if the password is all stars, then keep the existing password
                 $new_input[$key] = $existingPassword;
             } else {
                 // otherwise the password is new, so trim it
                 $new_input[$key] = trim($input[$key]);
             }
             // log it
             $this->logSanitize($desc, $new_input[$key]);
             // base-64 scramble password
             $new_input[$key] = base64_encode($new_input[$key]);
         }
     }
     $this->logger->debug(sprintf('Encoding %s as %s', $desc, $new_input[$key]));
 }