addAlias() 공개 메소드

public addAlias ( $namespace_uri, $desired_alias, $implicit = false )
예제 #1
0
 function test_onealias()
 {
     $nsm = new Auth_OpenID_NamespaceMap();
     $uri = 'http://example.com/foo';
     $alias = "foo";
     $nsm->addAlias($uri, $alias);
     $this->assertTrue($nsm->getNamespaceURI($alias) == $uri);
     $this->assertTrue($nsm->getAlias($uri) == $alias);
 }
예제 #2
0
 function test_getExtensionArgs_nonempty()
 {
     $data = array('foo', 'bar');
     $this->msg->setValues($this->type_a, $data);
     $aliases = new Auth_OpenID_NamespaceMap();
     $aliases->addAlias($this->type_a, $this->alias_a);
     $args = $this->msg->getExtensionArgs($aliases);
     $expected_args = array('mode' => 'store_request', 'type.' . $this->alias_a => $this->type_a, 'count.' . $this->alias_a => '2', sprintf('value.%s.1', $this->alias_a) => 'foo', sprintf('value.%s.2', $this->alias_a) => 'bar');
     $this->assertEquals($expected_args, $args);
 }
예제 #3
0
파일: AX.php 프로젝트: kaantunc/MYK-BOR
 /**
  * Serialize this object into arguments in the attribute exchange
  * namespace
  *
  * @return $args The dictionary of unqualified attribute exchange
  * arguments that represent this fetch_response, or
  * Auth_OpenID_AX_Error on error.
  */
 function getExtensionArgs($request = null)
 {
     $aliases = new Auth_OpenID_NamespaceMap();
     $zero_value_types = array();
     if ($request !== null) {
         // Validate the data in the context of the request (the
         // same attributes should be present in each, and the
         // counts in the response must be no more than the counts
         // in the request)
         foreach ($this->data as $type_uri => $unused) {
             if (!$request->contains($type_uri)) {
                 return new Auth_OpenID_AX_Error(sprintf("Response attribute not present in request: %s", $type_uri));
             }
         }
         foreach ($request->iterAttrs() as $attr_info) {
             // Copy the aliases from the request so that reading
             // the response in light of the request is easier
             if ($attr_info->alias === null) {
                 $aliases->add($attr_info->type_uri);
             } else {
                 $alias = $aliases->addAlias($attr_info->type_uri, $attr_info->alias);
                 if ($alias === null) {
                     return new Auth_OpenID_AX_Error(sprintf("Could not add alias %s for URI %s", $attr_info->alias, $attr_info->type_uri));
                 }
             }
             if (array_key_exists($attr_info->type_uri, $this->data)) {
                 $values = $this->data[$attr_info->type_uri];
             } else {
                 $values = array();
                 $zero_value_types[] = $attr_info;
             }
             if ($attr_info->count != Auth_OpenID_AX_UNLIMITED_VALUES && $attr_info->count < count($values)) {
                 return new Auth_OpenID_AX_Error(sprintf("More than the number of requested values " . "were specified for %s", $attr_info->type_uri));
             }
         }
     }
     $kv_args = $this->_getExtensionKVArgs($aliases);
     // Add the KV args into the response with the args that are
     // unique to the fetch_response
     $ax_args = $this->_newArgs();
     // For each requested attribute, put its type/alias and count
     // into the response even if no data were returned.
     foreach ($zero_value_types as $attr_info) {
         $alias = $aliases->getAlias($attr_info->type_uri);
         $kv_args['type.' . $alias] = $attr_info->type_uri;
         $kv_args['count.' . $alias] = '0';
     }
     $update_url = null;
     if ($request) {
         $update_url = $request->update_url;
     } else {
         $update_url = $this->update_url;
     }
     if ($update_url) {
         $ax_args['update_url'] = $update_url;
     }
     Auth_OpenID::update(&$ax_args, $kv_args);
     return $ax_args;
 }