Esempio n. 1
0
 /**
  * Creates a HTTP request.
  *
  * @param array $params the request parameters
  * @param array $headers the HTTP request headers
  */
 public function __construct($params = NULL, $headers = NULL)
 {
     if ($params == NULL) {
         $params = $_REQUEST;
     }
     parent::__construct($params);
     if ($headers == NULL) {
         // Special cases
         if (isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION'])) {
             $this->headers['authorization'] = $_SERVER['REDIRECT_HTTP_AUTHORIZATION'];
         }
         if (isset($_SERVER['PHP_AUTH_TYPE'])) {
             if (isset($_SERVER['PHP_AUTH_DIGEST'])) {
                 $this->headers['authorization'] = 'Digest ' . $_SERVER['PHP_AUTH_DIGEST'];
             } elseif (isset($_SERVER['PHP_AUTH_PW'])) {
                 $this->headers['authorization'] = 'Basic ' . base64_encode($_SERVER['PHP_AUTH_USER'] . ':' . $_SERVER['PHP_AUTH_PW']);
             }
         }
         foreach ($_SERVER as $name => $value) {
             if (substr($name, 0, 5) != 'HTTP_') {
                 continue;
             }
             $this->headers[HTTPResponse::httpCase(strtr(substr($name, 5), '_', '-'))] = $value;
         }
     } else {
         foreach ($headers as $name => $value) {
             $this->headers[HTTPResponse::httpCase($name)] = $value;
         }
     }
 }
Esempio n. 2
0
 /**
  * Creates an OAuth response.
  *
  * An OAuth response is created based on an OAuth request.  The
  * response will contain the same `state` and `redirect_uri`
  * parameters as the underlying request.
  * 
  * @param Request $request the request to which the response will
  * be made
  * @param array $data the initial response parameters
  */
 public function __construct($request = NULL, $data = array())
 {
     parent::__construct($data);
     if ($request != NULL) {
         if (isset($request['state'])) {
             $this->container['state'] = $request['state'];
         }
         if (isset($request['redirect_uri'])) {
             $this->redirect_uri = $request['redirect_uri'];
         }
     }
 }
Esempio n. 3
0
 /**
  * Creates a response.
  *
  * `$path_prefix` is used to construct paths to the configuration variables, which
  * are then accessed using {@link ArrayWrapper::pathGet()}.  For example, if
  * `$path_prefix` is `connect.userinfo`, then this will configure the JOSE
  * algorithms using the following paths:
  *
  * - `connect.userinfo_signed_response_alg`
  * - `connect.userinfo_encrypted_response_alg`
  * - `connect.userinfo_encrypted_response_enc`
  *
  * @param string the issuer ID
  * @param SimpleID\OAuth\OAuthClient $client the OAuth client to which the response
  * will be sent
  * @param string $path_prefix the prefix from which paths will be formed and passed
  * to {@link ArrayWrapper::pathGet()} to get the client configuration
  * @param array $data the initial claims
  * @param string $default_signed_response_alg the default `_signed_response_alg` value
  * if the client configuration is not found
  */
 function __construct($issuer, $client, $path_prefix, $data = array(), $default_signed_response_alg = null)
 {
     parent::__construct($data);
     $this->issuer = $issuer;
     $this->client = $client;
     if ($this->client->pathExists($path_prefix . '_signed_response_alg')) {
         $this->signed_response_alg = $this->client->pathGet($path_prefix . '_signed_response_alg');
     } elseif ($default_signed_response_alg != null) {
         $this->signed_response_alg = $default_signed_response_alg;
     }
     if ($this->client->pathExists($path_prefix . '_encrypted_response_alg')) {
         $this->encrypted_response_alg = $this->client->pathGet($path_prefix . '_encrypted_response_alg');
         if ($this->client->pathExists($path_prefix . '_encrypted_response_enc')) {
             $this->encrypted_response_enc = $this->client->pathGet($path_prefix . '_encrypted_response_enc');
         } else {
             $this->encrypted_response_enc = 'A128CBC-HS256';
         }
     }
 }
Esempio n. 4
0
 /**
  * Creates an form response.
  *
  * @param array $data the initial response parameters
  */
 public function __construct($data = array())
 {
     parent::__construct($data);
 }
Esempio n. 5
0
 private function toSecureArray($hidden_value = null)
 {
     $mgr = ModuleManager::instance();
     $copy = new ArrayWrapper($this->container);
     $secret_paths = $mgr->invokeAll('secretUserDataPaths');
     if ($secret_paths == null) {
         $secret_paths = array();
     }
     $secret_paths[] = 'uid';
     foreach ($secret_paths as $path) {
         if ($hidden_value) {
             $copy->pathSet($path, $hidden_value);
         } else {
             $copy->pathUnset($path);
         }
     }
     return $copy->toArray();
 }