ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
OAuthUtil Class Reference
+ Collaboration diagram for OAuthUtil:

Static Public Member Functions

static urlencode_rfc3986 ($input)
 
static urldecode_rfc3986 ($string)
 
static split_header ($header, $only_allow_oauth_parameters=true)
 
static get_headers ()
 
static parse_parameters ( $input)
 
static build_http_query ($params)
 

Detailed Description

Definition at line 762 of file OAuth.php.

Member Function Documentation

◆ build_http_query()

static OAuthUtil::build_http_query (   $params)
static

Definition at line 885 of file OAuth.php.

885 {
886 if (!$params) return '';
887
888 // Urlencode both keys and values
890 $values = OAuthUtil::urlencode_rfc3986(array_values($params));
891 $params = array_combine($keys, $values);
892
893 // Parameters are sorted by name, using lexicographical byte value ordering.
894 // Ref: Spec: 9.1.1 (1)
895 uksort($params, 'strcmp');
896
897 $pairs = array();
898 foreach ($params as $parameter => $value) {
899 if (is_array($value)) {
900 // If two or more parameters share the same name, they are sorted by their value
901 // Ref: Spec: 9.1.1 (1)
902 // June 12th, 2010 - changed to sort because of issue 164 by hidetaka
903 sort($value, SORT_STRING);
904 foreach ($value as $duplicate_value) {
905 $pairs[] = $parameter . '=' . $duplicate_value;
906 }
907 } else {
908 $pairs[] = $parameter . '=' . $value;
909 }
910 }
911 // For each parameter, the name is separated from the corresponding value by an '=' character (ASCII code 61)
912 // Each name-value pair is separated by an '&' character (ASCII code 38)
913 return implode('&', $pairs);
914 }
static urlencode_rfc3986($input)
Definition: OAuth.php:763
$keys
$params
Definition: disable.php:11

References $keys, $params, and urlencode_rfc3986().

Referenced by OAuthRequest\get_signable_parameters(), and OAuthRequest\to_postdata().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_headers()

static OAuthUtil::get_headers ( )
static

Definition at line 804 of file OAuth.php.

804 {
805 if (function_exists('apache_request_headers')) {
806 // we need this to get the actual Authorization: header
807 // because apache tends to tell us it doesn't exist
808 $headers = apache_request_headers();
809
810 // sanitize the output of apache_request_headers because
811 // we always want the keys to be Cased-Like-This and arh()
812 // returns the headers in the same case as they are in the
813 // request
814 $out = array();
815 foreach ($headers AS $key => $value) {
816 $key = str_replace(
817 " ",
818 "-",
819 ucwords(strtolower(str_replace("-", " ", $key)))
820 );
821 $out[$key] = $value;
822 }
823 } else {
824 // otherwise we don't have apache and are just going to have to hope
825 // that $_SERVER actually contains what we need
826 $out = array();
827 if( isset($_SERVER['CONTENT_TYPE']) )
828 $out['Content-Type'] = $_SERVER['CONTENT_TYPE'];
829 if( isset($_ENV['CONTENT_TYPE']) )
830 $out['Content-Type'] = $_ENV['CONTENT_TYPE'];
831
832 foreach ($_SERVER as $key => $value) {
833 if (substr($key, 0, 5) == "HTTP_") {
834 // this is chaos, basically it is just there to capitalize the first
835 // letter of every word that is not an initial HTTP and strip HTTP
836 // code from przemek
837 $key = str_replace(
838 " ",
839 "-",
840 ucwords(strtolower(str_replace("_", " ", substr($key, 5))))
841 );
842 $out[$key] = $value;
843 }
844 }
845 // The "Authorization" header may get turned into "Auth".
846 if (isset($out['Auth'])) {
847 $out['Authorization'] = $out['Auth'];
848 }
849 }
850 return $out;
851 }
$key
Definition: croninfo.php:18
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']

References $_SERVER, $key, and $out.

Referenced by OAuthRequest\from_request().

+ Here is the caller graph for this function:

◆ parse_parameters()

static OAuthUtil::parse_parameters (   $input)
static

Definition at line 856 of file OAuth.php.

856 {
857 if (!isset($input) || !$input) return array();
858
859 $pairs = explode('&', $input);
860
861 $parsed_parameters = array();
862 foreach ($pairs as $pair) {
863 $split = explode('=', $pair, 2);
864 $parameter = OAuthUtil::urldecode_rfc3986($split[0]);
865 $value = isset($split[1]) ? OAuthUtil::urldecode_rfc3986($split[1]) : '';
866
867 if (isset($parsed_parameters[$parameter])) {
868 // We have already recieved parameter(s) with this name, so add to the list
869 // of parameters with this name
870
871 if (is_scalar($parsed_parameters[$parameter])) {
872 // This is the first duplicate, so transform scalar (string) into an array
873 // so we can add the duplicates
874 $parsed_parameters[$parameter] = array($parsed_parameters[$parameter]);
875 }
876
877 $parsed_parameters[$parameter][] = $value;
878 } else {
879 $parsed_parameters[$parameter] = $value;
880 }
881 }
882 return $parsed_parameters;
883 }
static urldecode_rfc3986($string)
Definition: OAuth.php:781

References urldecode_rfc3986().

Referenced by OAuthRequest\__construct(), and OAuthRequest\from_request().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ split_header()

static OAuthUtil::split_header (   $header,
  $only_allow_oauth_parameters = true 
)
static

Definition at line 790 of file OAuth.php.

790 {
791 $params = array();
792 if (preg_match_all('/('.($only_allow_oauth_parameters ? 'oauth_' : '').'[a-z_-]*)=(:?"([^"]*)"|([^,]*))/', $header, $matches)) {
793 foreach ($matches[1] as $i => $h) {
794 $params[$h] = OAuthUtil::urldecode_rfc3986(empty($matches[3][$i]) ? $matches[4][$i] : $matches[3][$i]);
795 }
796 if (isset($params['realm'])) {
797 unset($params['realm']);
798 }
799 }
800 return $params;
801 }
$i
Definition: disco.tpl.php:19
$h

References $h, $header, $i, $params, and urldecode_rfc3986().

Referenced by OAuthRequest\from_request().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ urldecode_rfc3986()

static OAuthUtil::urldecode_rfc3986 (   $string)
static

Definition at line 781 of file OAuth.php.

781 {
782 return urldecode($string);
783 }

Referenced by parse_parameters(), and split_header().

+ Here is the caller graph for this function:

◆ urlencode_rfc3986()

static OAuthUtil::urlencode_rfc3986 (   $input)
static

Definition at line 763 of file OAuth.php.

763 {
764 if (is_array($input)) {
765 return array_map(array('OAuthUtil', 'urlencode_rfc3986'), $input);
766 } else if (is_scalar($input)) {
767 return str_replace(
768 '+',
769 ' ',
770 str_replace('%7E', '~', rawurlencode($input))
771 );
772 } else {
773 return '';
774 }
775 }

Referenced by build_http_query(), OAuthSignatureMethod_HMAC_SHA1\build_signature(), OAuthSignatureMethod_PLAINTEXT\build_signature(), OAuthRequest\get_signature_base_string(), OAuthRequest\to_header(), and OAuthToken\to_string().

+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: