repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6 values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1 value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
nextras/forms | src/Controls/DateTimePickerPrototype.php | DateTimePickerPrototype.getControl | public function getControl()
{
$control = parent::getControl();
$control->type = $this->htmlType;
$control->addClass($this->htmlType);
list($min, $max) = $this->extractRangeRule($this->getRules());
if ($min instanceof DateTimeInterface) {
$control->min = $min->format($this->htmlFormat);
}
if ($max instanceof DateTimeInterface) {
$control->max = $max->format($this->htmlFormat);
}
$value = $this->getValue();
if ($value instanceof DateTimeInterface) {
$control->value = $value->format($this->htmlFormat);
}
return $control;
} | php | public function getControl()
{
$control = parent::getControl();
$control->type = $this->htmlType;
$control->addClass($this->htmlType);
list($min, $max) = $this->extractRangeRule($this->getRules());
if ($min instanceof DateTimeInterface) {
$control->min = $min->format($this->htmlFormat);
}
if ($max instanceof DateTimeInterface) {
$control->max = $max->format($this->htmlFormat);
}
$value = $this->getValue();
if ($value instanceof DateTimeInterface) {
$control->value = $value->format($this->htmlFormat);
}
return $control;
} | [
"public",
"function",
"getControl",
"(",
")",
"{",
"$",
"control",
"=",
"parent",
"::",
"getControl",
"(",
")",
";",
"$",
"control",
"->",
"type",
"=",
"$",
"this",
"->",
"htmlType",
";",
"$",
"control",
"->",
"addClass",
"(",
"$",
"this",
"->",
"htm... | Generates control's HTML element.
@return Html | [
"Generates",
"control",
"s",
"HTML",
"element",
"."
] | train | https://github.com/nextras/forms/blob/548f93a0be0f5424b1a418bad3932de125ad31c8/src/Controls/DateTimePickerPrototype.php#L45-L64 |
nextras/forms | src/Controls/DateTimePickerPrototype.php | DateTimePickerPrototype.extractRangeRule | protected function extractRangeRule(Rules $rules)
{
$controlMin = $controlMax = null;
foreach ($rules as $rule) {
$branch = property_exists($rule, 'branch') ? $rule->branch : $rule->subRules;
if (!$branch) {
$validator = property_exists($rule, 'validator') ? $rule->validator : $rule->operation;
if ($validator === Form::RANGE && !$rule->isNegative) {
$ruleMinMax = $rule->arg;
}
} elseif ($branch) {
$validator = property_exists($rule, 'validator') ? $rule->validator : $rule->operation;
if ($validator === Form::FILLED && !$rule->isNegative && $rule->control === $this) {
$ruleMinMax = $this->extractRangeRule($branch);
}
}
if (isset($ruleMinMax)) {
list($ruleMin, $ruleMax) = $ruleMinMax;
if ($ruleMin !== null && ($controlMin === null || $ruleMin > $controlMin)) {
$controlMin = $ruleMin;
}
if ($ruleMax !== null && ($controlMax === null || $ruleMax < $controlMax)) {
$controlMax = $ruleMax;
}
$ruleMinMax = null;
}
}
return [$controlMin, $controlMax];
} | php | protected function extractRangeRule(Rules $rules)
{
$controlMin = $controlMax = null;
foreach ($rules as $rule) {
$branch = property_exists($rule, 'branch') ? $rule->branch : $rule->subRules;
if (!$branch) {
$validator = property_exists($rule, 'validator') ? $rule->validator : $rule->operation;
if ($validator === Form::RANGE && !$rule->isNegative) {
$ruleMinMax = $rule->arg;
}
} elseif ($branch) {
$validator = property_exists($rule, 'validator') ? $rule->validator : $rule->operation;
if ($validator === Form::FILLED && !$rule->isNegative && $rule->control === $this) {
$ruleMinMax = $this->extractRangeRule($branch);
}
}
if (isset($ruleMinMax)) {
list($ruleMin, $ruleMax) = $ruleMinMax;
if ($ruleMin !== null && ($controlMin === null || $ruleMin > $controlMin)) {
$controlMin = $ruleMin;
}
if ($ruleMax !== null && ($controlMax === null || $ruleMax < $controlMax)) {
$controlMax = $ruleMax;
}
$ruleMinMax = null;
}
}
return [$controlMin, $controlMax];
} | [
"protected",
"function",
"extractRangeRule",
"(",
"Rules",
"$",
"rules",
")",
"{",
"$",
"controlMin",
"=",
"$",
"controlMax",
"=",
"null",
";",
"foreach",
"(",
"$",
"rules",
"as",
"$",
"rule",
")",
"{",
"$",
"branch",
"=",
"property_exists",
"(",
"$",
... | Finds minimum and maximum allowed dates.
@return array 0 => DateTime|null $minDate, 1 => DateTime|null $maxDate | [
"Finds",
"minimum",
"and",
"maximum",
"allowed",
"dates",
"."
] | train | https://github.com/nextras/forms/blob/548f93a0be0f5424b1a418bad3932de125ad31c8/src/Controls/DateTimePickerPrototype.php#L140-L170 |
nextras/forms | src/Controls/Fragments/TemplateControlTrait.php | TemplateControlTrait.redrawControl | public function redrawControl($snippet = NULL, $redraw = TRUE)
{
if ($redraw) {
$this->invalidSnippets[$snippet === NULL ? "\0" : $snippet] = TRUE;
} elseif ($snippet === NULL) {
$this->invalidSnippets = [];
} else {
$this->invalidSnippets[$snippet] = FALSE;
}
} | php | public function redrawControl($snippet = NULL, $redraw = TRUE)
{
if ($redraw) {
$this->invalidSnippets[$snippet === NULL ? "\0" : $snippet] = TRUE;
} elseif ($snippet === NULL) {
$this->invalidSnippets = [];
} else {
$this->invalidSnippets[$snippet] = FALSE;
}
} | [
"public",
"function",
"redrawControl",
"(",
"$",
"snippet",
"=",
"NULL",
",",
"$",
"redraw",
"=",
"TRUE",
")",
"{",
"if",
"(",
"$",
"redraw",
")",
"{",
"$",
"this",
"->",
"invalidSnippets",
"[",
"$",
"snippet",
"===",
"NULL",
"?",
"\"\\0\"",
":",
"$"... | Forces control or its snippet to repaint.
@return void | [
"Forces",
"control",
"or",
"its",
"snippet",
"to",
"repaint",
"."
] | train | https://github.com/nextras/forms/blob/548f93a0be0f5424b1a418bad3932de125ad31c8/src/Controls/Fragments/TemplateControlTrait.php#L187-L198 |
nextras/forms | src/Controls/Fragments/TemplateControlTrait.php | TemplateControlTrait.isControlInvalid | public function isControlInvalid($snippet = NULL)
{
if ($snippet === NULL) {
if (count($this->invalidSnippets) > 0) {
return TRUE;
} else {
$queue = [$this];
do {
foreach (array_shift($queue)->getComponents() as $component) {
if ($component instanceof IRenderable) {
if ($component->isControlInvalid()) {
// $this->invalidSnippets['__child'] = TRUE; // as cache
return TRUE;
}
} elseif ($component instanceof Nette\ComponentModel\IContainer) {
$queue[] = $component;
}
}
} while ($queue);
return FALSE;
}
} elseif (isset($this->invalidSnippets[$snippet])) {
return $this->invalidSnippets[$snippet];
} else {
return isset($this->invalidSnippets["\0"]);
}
} | php | public function isControlInvalid($snippet = NULL)
{
if ($snippet === NULL) {
if (count($this->invalidSnippets) > 0) {
return TRUE;
} else {
$queue = [$this];
do {
foreach (array_shift($queue)->getComponents() as $component) {
if ($component instanceof IRenderable) {
if ($component->isControlInvalid()) {
// $this->invalidSnippets['__child'] = TRUE; // as cache
return TRUE;
}
} elseif ($component instanceof Nette\ComponentModel\IContainer) {
$queue[] = $component;
}
}
} while ($queue);
return FALSE;
}
} elseif (isset($this->invalidSnippets[$snippet])) {
return $this->invalidSnippets[$snippet];
} else {
return isset($this->invalidSnippets["\0"]);
}
} | [
"public",
"function",
"isControlInvalid",
"(",
"$",
"snippet",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"snippet",
"===",
"NULL",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"invalidSnippets",
")",
">",
"0",
")",
"{",
"return",
"TRUE",
";",
... | Is required to repaint the control or its snippet?
@param string snippet name
@return bool | [
"Is",
"required",
"to",
"repaint",
"the",
"control",
"or",
"its",
"snippet?"
] | train | https://github.com/nextras/forms/blob/548f93a0be0f5424b1a418bad3932de125ad31c8/src/Controls/Fragments/TemplateControlTrait.php#L221-L251 |
nextras/forms | src/Bridges/Latte/Macros/BaseInputMacros.php | BaseInputMacros.macroLabelEnd | public function macroLabelEnd(MacroNode $node, PhpWriter $writer)
{
if ($node->content != null) {
$node->openingCode = rtrim($node->openingCode, '?> ') . '->startTag() ?>';
return $writer->write('if ($_label) echo $_label->endTag()');
}
} | php | public function macroLabelEnd(MacroNode $node, PhpWriter $writer)
{
if ($node->content != null) {
$node->openingCode = rtrim($node->openingCode, '?> ') . '->startTag() ?>';
return $writer->write('if ($_label) echo $_label->endTag()');
}
} | [
"public",
"function",
"macroLabelEnd",
"(",
"MacroNode",
"$",
"node",
",",
"PhpWriter",
"$",
"writer",
")",
"{",
"if",
"(",
"$",
"node",
"->",
"content",
"!=",
"null",
")",
"{",
"$",
"node",
"->",
"openingCode",
"=",
"rtrim",
"(",
"$",
"node",
"->",
... | {/label} | [
"{",
"/",
"label",
"}"
] | train | https://github.com/nextras/forms/blob/548f93a0be0f5424b1a418bad3932de125ad31c8/src/Bridges/Latte/Macros/BaseInputMacros.php#L60-L66 |
openid/php-openid | Auth/OpenID/BigMath.php | Auth_OpenID_MathLibrary.longToBinary | function longToBinary($long)
{
$cmp = $this->cmp($long, 0);
if ($cmp < 0) {
$msg = __FUNCTION__ . " takes only positive integers.";
trigger_error($msg, E_USER_ERROR);
return null;
}
if ($cmp == 0) {
return "\x00";
}
$bytes = array();
while ($this->cmp($long, 0) > 0) {
array_unshift($bytes, $this->mod($long, 256));
$long = $this->div($long, pow(2, 8));
}
if ($bytes && ($bytes[0] > 127)) {
array_unshift($bytes, 0);
}
$string = '';
foreach ($bytes as $byte) {
$string .= pack('C', $byte);
}
return $string;
} | php | function longToBinary($long)
{
$cmp = $this->cmp($long, 0);
if ($cmp < 0) {
$msg = __FUNCTION__ . " takes only positive integers.";
trigger_error($msg, E_USER_ERROR);
return null;
}
if ($cmp == 0) {
return "\x00";
}
$bytes = array();
while ($this->cmp($long, 0) > 0) {
array_unshift($bytes, $this->mod($long, 256));
$long = $this->div($long, pow(2, 8));
}
if ($bytes && ($bytes[0] > 127)) {
array_unshift($bytes, 0);
}
$string = '';
foreach ($bytes as $byte) {
$string .= pack('C', $byte);
}
return $string;
} | [
"function",
"longToBinary",
"(",
"$",
"long",
")",
"{",
"$",
"cmp",
"=",
"$",
"this",
"->",
"cmp",
"(",
"$",
"long",
",",
"0",
")",
";",
"if",
"(",
"$",
"cmp",
"<",
"0",
")",
"{",
"$",
"msg",
"=",
"__FUNCTION__",
".",
"\" takes only positive intege... | Given a long integer, returns the number converted to a binary
string. This function accepts long integer values of arbitrary
magnitude and uses the local large-number math library when
available.
@param integer $long The long number (can be a normal PHP
integer or a number created by one of the available long number
libraries)
@return string $binary The binary version of $long | [
"Given",
"a",
"long",
"integer",
"returns",
"the",
"number",
"converted",
"to",
"a",
"binary",
"string",
".",
"This",
"function",
"accepts",
"long",
"integer",
"values",
"of",
"arbitrary",
"magnitude",
"and",
"uses",
"the",
"local",
"large",
"-",
"number",
"... | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/BigMath.php#L45-L75 |
openid/php-openid | Auth/OpenID/BigMath.php | Auth_OpenID_MathLibrary.binaryToLong | function binaryToLong($str)
{
if ($str === null) {
return null;
}
// Use array_merge to return a zero-indexed array instead of a
// one-indexed array.
$bytes = array_merge(unpack('C*', $str));
$n = $this->init(0);
if ($bytes && ($bytes[0] > 127)) {
trigger_error("bytesToNum works only for positive integers.",
E_USER_WARNING);
return null;
}
foreach ($bytes as $byte) {
$n = $this->mul($n, pow(2, 8));
$n = $this->add($n, $byte);
}
return $n;
} | php | function binaryToLong($str)
{
if ($str === null) {
return null;
}
// Use array_merge to return a zero-indexed array instead of a
// one-indexed array.
$bytes = array_merge(unpack('C*', $str));
$n = $this->init(0);
if ($bytes && ($bytes[0] > 127)) {
trigger_error("bytesToNum works only for positive integers.",
E_USER_WARNING);
return null;
}
foreach ($bytes as $byte) {
$n = $this->mul($n, pow(2, 8));
$n = $this->add($n, $byte);
}
return $n;
} | [
"function",
"binaryToLong",
"(",
"$",
"str",
")",
"{",
"if",
"(",
"$",
"str",
"===",
"null",
")",
"{",
"return",
"null",
";",
"}",
"// Use array_merge to return a zero-indexed array instead of a",
"// one-indexed array.",
"$",
"bytes",
"=",
"array_merge",
"(",
"un... | Given a binary string, returns the binary string converted to a
long number.
@param string $str The binary version of a long number,
probably as a result of calling longToBinary
@return integer $long The long number equivalent of the binary
string $str | [
"Given",
"a",
"binary",
"string",
"returns",
"the",
"binary",
"string",
"converted",
"to",
"a",
"long",
"number",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/BigMath.php#L86-L110 |
openid/php-openid | Auth/OpenID/BigMath.php | Auth_OpenID_MathLibrary.rand | function rand($stop)
{
static $duplicate_cache = array();
// Used as the key for the duplicate cache
$rbytes = $this->longToBinary($stop);
if (array_key_exists($rbytes, $duplicate_cache)) {
list($duplicate, $nbytes) = $duplicate_cache[$rbytes];
} else {
if ($rbytes[0] == "\x00") {
$nbytes = Auth_OpenID::bytes($rbytes) - 1;
} else {
$nbytes = Auth_OpenID::bytes($rbytes);
}
$mxrand = $this->pow(256, $nbytes);
// If we get a number less than this, then it is in the
// duplicated range.
$duplicate = $this->mod($mxrand, $stop);
if (count($duplicate_cache) > 10) {
$duplicate_cache = array();
}
$duplicate_cache[$rbytes] = array($duplicate, $nbytes);
}
do {
$bytes = "\x00" . Auth_OpenID_CryptUtil::getBytes($nbytes);
$n = $this->binaryToLong($bytes);
// Keep looping if this value is in the low duplicated range
} while ($this->cmp($n, $duplicate) < 0);
return $this->mod($n, $stop);
} | php | function rand($stop)
{
static $duplicate_cache = array();
// Used as the key for the duplicate cache
$rbytes = $this->longToBinary($stop);
if (array_key_exists($rbytes, $duplicate_cache)) {
list($duplicate, $nbytes) = $duplicate_cache[$rbytes];
} else {
if ($rbytes[0] == "\x00") {
$nbytes = Auth_OpenID::bytes($rbytes) - 1;
} else {
$nbytes = Auth_OpenID::bytes($rbytes);
}
$mxrand = $this->pow(256, $nbytes);
// If we get a number less than this, then it is in the
// duplicated range.
$duplicate = $this->mod($mxrand, $stop);
if (count($duplicate_cache) > 10) {
$duplicate_cache = array();
}
$duplicate_cache[$rbytes] = array($duplicate, $nbytes);
}
do {
$bytes = "\x00" . Auth_OpenID_CryptUtil::getBytes($nbytes);
$n = $this->binaryToLong($bytes);
// Keep looping if this value is in the low duplicated range
} while ($this->cmp($n, $duplicate) < 0);
return $this->mod($n, $stop);
} | [
"function",
"rand",
"(",
"$",
"stop",
")",
"{",
"static",
"$",
"duplicate_cache",
"=",
"array",
"(",
")",
";",
"// Used as the key for the duplicate cache",
"$",
"rbytes",
"=",
"$",
"this",
"->",
"longToBinary",
"(",
"$",
"stop",
")",
";",
"if",
"(",
"arra... | Returns a random number in the specified range. This function
accepts $start, $stop, and $step values of arbitrary magnitude
and will utilize the local large-number math library when
available.
@param integer $stop The end of the range, or the maximum
random number to return
@return integer $result The resulting randomly-generated number | [
"Returns",
"a",
"random",
"number",
"in",
"the",
"specified",
"range",
".",
"This",
"function",
"accepts",
"$start",
"$stop",
"and",
"$step",
"values",
"of",
"arbitrary",
"magnitude",
"and",
"will",
"utilize",
"the",
"local",
"large",
"-",
"number",
"math",
... | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/BigMath.php#L138-L174 |
openid/php-openid | Auth/OpenID/BigMath.php | Auth_OpenID_BcMathWrapper._powmod | function _powmod($base, $exponent, $modulus)
{
$square = $this->mod($base, $modulus);
$result = 1;
while($this->cmp($exponent, 0) > 0) {
if ($this->mod($exponent, 2)) {
$result = $this->mod($this->mul($result, $square), $modulus);
}
$square = $this->mod($this->mul($square, $square), $modulus);
$exponent = $this->div($exponent, 2);
}
return $result;
} | php | function _powmod($base, $exponent, $modulus)
{
$square = $this->mod($base, $modulus);
$result = 1;
while($this->cmp($exponent, 0) > 0) {
if ($this->mod($exponent, 2)) {
$result = $this->mod($this->mul($result, $square), $modulus);
}
$square = $this->mod($this->mul($square, $square), $modulus);
$exponent = $this->div($exponent, 2);
}
return $result;
} | [
"function",
"_powmod",
"(",
"$",
"base",
",",
"$",
"exponent",
",",
"$",
"modulus",
")",
"{",
"$",
"square",
"=",
"$",
"this",
"->",
"mod",
"(",
"$",
"base",
",",
"$",
"modulus",
")",
";",
"$",
"result",
"=",
"1",
";",
"while",
"(",
"$",
"this"... | Same as bcpowmod when bcpowmod is missing
@access private
@param int $base
@param int $exponent
@param int $modulus
@return int | [
"Same",
"as",
"bcpowmod",
"when",
"bcpowmod",
"is",
"missing"
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/BigMath.php#L287-L299 |
openid/php-openid | Auth/OpenID/CryptUtil.php | Auth_OpenID_CryptUtil.getBytes | static function getBytes($num_bytes)
{
static $f = null;
if ($f === null) {
if (Auth_OpenID_RAND_SOURCE === null) {
$f = false;
} else {
$f = @fopen(Auth_OpenID_RAND_SOURCE, "r");
if ($f === false) {
$msg = 'Define Auth_OpenID_RAND_SOURCE as null to ' .
' continue with an insecure random number generator.';
trigger_error($msg, E_USER_ERROR);
}
}
}
if ($f === false) {
// pseudorandom used
$bytes = '';
for ($i = 0; $i < $num_bytes; $i += 4) {
$bytes .= pack('L', mt_rand());
}
$bytes = substr($bytes, 0, $num_bytes);
} else {
$bytes = fread($f, $num_bytes);
}
return $bytes;
} | php | static function getBytes($num_bytes)
{
static $f = null;
if ($f === null) {
if (Auth_OpenID_RAND_SOURCE === null) {
$f = false;
} else {
$f = @fopen(Auth_OpenID_RAND_SOURCE, "r");
if ($f === false) {
$msg = 'Define Auth_OpenID_RAND_SOURCE as null to ' .
' continue with an insecure random number generator.';
trigger_error($msg, E_USER_ERROR);
}
}
}
if ($f === false) {
// pseudorandom used
$bytes = '';
for ($i = 0; $i < $num_bytes; $i += 4) {
$bytes .= pack('L', mt_rand());
}
$bytes = substr($bytes, 0, $num_bytes);
} else {
$bytes = fread($f, $num_bytes);
}
return $bytes;
} | [
"static",
"function",
"getBytes",
"(",
"$",
"num_bytes",
")",
"{",
"static",
"$",
"f",
"=",
"null",
";",
"if",
"(",
"$",
"f",
"===",
"null",
")",
"{",
"if",
"(",
"Auth_OpenID_RAND_SOURCE",
"===",
"null",
")",
"{",
"$",
"f",
"=",
"false",
";",
"}",
... | Get the specified number of random bytes.
Attempts to use a cryptographically secure (not predictable)
source of randomness if available. If there is no high-entropy
randomness source available, it will fail. As a last resort,
for non-critical systems, define
<code>Auth_OpenID_RAND_SOURCE</code> as <code>null</code>, and
the code will fall back on a pseudo-random number generator.
@param int $num_bytes The length of the return value
@return string $bytes random bytes | [
"Get",
"the",
"specified",
"number",
"of",
"random",
"bytes",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/CryptUtil.php#L40-L66 |
openid/php-openid | Auth/OpenID/CryptUtil.php | Auth_OpenID_CryptUtil.randomString | static function randomString($length, $population = null)
{
if ($population === null) {
return Auth_OpenID_CryptUtil::getBytes($length);
}
$popsize = strlen($population);
if ($popsize > 256) {
$msg = 'More than 256 characters supplied to ' . __FUNCTION__;
trigger_error($msg, E_USER_ERROR);
}
$duplicate = 256 % $popsize;
$str = "";
for ($i = 0; $i < $length; $i++) {
do {
$n = ord(Auth_OpenID_CryptUtil::getBytes(1));
} while ($n < $duplicate);
$n %= $popsize;
$str .= $population[$n];
}
return $str;
} | php | static function randomString($length, $population = null)
{
if ($population === null) {
return Auth_OpenID_CryptUtil::getBytes($length);
}
$popsize = strlen($population);
if ($popsize > 256) {
$msg = 'More than 256 characters supplied to ' . __FUNCTION__;
trigger_error($msg, E_USER_ERROR);
}
$duplicate = 256 % $popsize;
$str = "";
for ($i = 0; $i < $length; $i++) {
do {
$n = ord(Auth_OpenID_CryptUtil::getBytes(1));
} while ($n < $duplicate);
$n %= $popsize;
$str .= $population[$n];
}
return $str;
} | [
"static",
"function",
"randomString",
"(",
"$",
"length",
",",
"$",
"population",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"population",
"===",
"null",
")",
"{",
"return",
"Auth_OpenID_CryptUtil",
"::",
"getBytes",
"(",
"$",
"length",
")",
";",
"}",
"$",
... | Produce a string of length random bytes, chosen from chrs. If
$chrs is null, the resulting string may contain any characters.
@param integer $length The length of the resulting
randomly-generated string
@param string|null $population A string of characters from which to choose
to build the new string
@return string $result A string of randomly-chosen characters
from $chrs | [
"Produce",
"a",
"string",
"of",
"length",
"random",
"bytes",
"chosen",
"from",
"chrs",
".",
"If",
"$chrs",
"is",
"null",
"the",
"resulting",
"string",
"may",
"contain",
"any",
"characters",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/CryptUtil.php#L79-L105 |
openid/php-openid | Auth/OpenID/Association.php | Auth_OpenID_Association.fromExpiresIn | static function fromExpiresIn($expires_in, $handle, $secret, $assoc_type)
{
$issued = time();
$lifetime = $expires_in;
return new Auth_OpenID_Association($handle, $secret,
$issued, $lifetime, $assoc_type);
} | php | static function fromExpiresIn($expires_in, $handle, $secret, $assoc_type)
{
$issued = time();
$lifetime = $expires_in;
return new Auth_OpenID_Association($handle, $secret,
$issued, $lifetime, $assoc_type);
} | [
"static",
"function",
"fromExpiresIn",
"(",
"$",
"expires_in",
",",
"$",
"handle",
",",
"$",
"secret",
",",
"$",
"assoc_type",
")",
"{",
"$",
"issued",
"=",
"time",
"(",
")",
";",
"$",
"lifetime",
"=",
"$",
"expires_in",
";",
"return",
"new",
"Auth_Ope... | This is an alternate constructor (factory method) used by the
OpenID consumer library to create associations. OpenID store
implementations shouldn't use this constructor.
@access private
@param integer $expires_in This is the amount of time this
association is good for, measured in seconds since the
association was issued.
@param string $handle This is the handle the server gave this
association.
@param string $secret This is the shared secret the server
generated for this association.
@param string $assoc_type This is the type of association this
instance represents. The only valid values of this field at
this time is 'HMAC-SHA1' and 'HMAC-SHA256', but new types may
be defined in the future.
@return Auth_OpenID_Association | [
"This",
"is",
"an",
"alternate",
"constructor",
"(",
"factory",
"method",
")",
"used",
"by",
"the",
"OpenID",
"consumer",
"library",
"to",
"create",
"associations",
".",
"OpenID",
"store",
"implementations",
"shouldn",
"t",
"use",
"this",
"constructor",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/Association.php#L96-L102 |
openid/php-openid | Auth/OpenID/Association.php | Auth_OpenID_Association.getExpiresIn | function getExpiresIn($now = null)
{
if ($now == null) {
$now = time();
}
return max(0, $this->issued + $this->lifetime - $now);
} | php | function getExpiresIn($now = null)
{
if ($now == null) {
$now = time();
}
return max(0, $this->issued + $this->lifetime - $now);
} | [
"function",
"getExpiresIn",
"(",
"$",
"now",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"now",
"==",
"null",
")",
"{",
"$",
"now",
"=",
"time",
"(",
")",
";",
"}",
"return",
"max",
"(",
"0",
",",
"$",
"this",
"->",
"issued",
"+",
"$",
"this",
"->... | This returns the number of seconds this association is still
valid for, or 0 if the association is no longer valid.
@param int|null $now
@return int $seconds The number of seconds this association
is still valid for, or 0 if the association is no longer valid. | [
"This",
"returns",
"the",
"number",
"of",
"seconds",
"this",
"association",
"is",
"still",
"valid",
"for",
"or",
"0",
"if",
"the",
"association",
"is",
"no",
"longer",
"valid",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/Association.php#L154-L161 |
openid/php-openid | Auth/OpenID/Association.php | Auth_OpenID_Association.equal | function equal($other)
{
return ((gettype($this) == gettype($other))
&& ($this->handle == $other->handle)
&& ($this->secret == $other->secret)
&& ($this->issued == $other->issued)
&& ($this->lifetime == $other->lifetime)
&& ($this->assoc_type == $other->assoc_type));
} | php | function equal($other)
{
return ((gettype($this) == gettype($other))
&& ($this->handle == $other->handle)
&& ($this->secret == $other->secret)
&& ($this->issued == $other->issued)
&& ($this->lifetime == $other->lifetime)
&& ($this->assoc_type == $other->assoc_type));
} | [
"function",
"equal",
"(",
"$",
"other",
")",
"{",
"return",
"(",
"(",
"gettype",
"(",
"$",
"this",
")",
"==",
"gettype",
"(",
"$",
"other",
")",
")",
"&&",
"(",
"$",
"this",
"->",
"handle",
"==",
"$",
"other",
"->",
"handle",
")",
"&&",
"(",
"$... | This checks to see if two {@link Auth_OpenID_Association}
instances represent the same association.
@param object $other
@return bool $result true if the two instances represent the
same association, false otherwise. | [
"This",
"checks",
"to",
"see",
"if",
"two",
"{",
"@link",
"Auth_OpenID_Association",
"}",
"instances",
"represent",
"the",
"same",
"association",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/Association.php#L171-L179 |
openid/php-openid | Auth/OpenID/Association.php | Auth_OpenID_Association.serialize | function serialize()
{
$data = array(
'version' => '2',
'handle' => $this->handle,
'secret' => base64_encode($this->secret),
'issued' => strval(intval($this->issued)),
'lifetime' => strval(intval($this->lifetime)),
'assoc_type' => $this->assoc_type
);
assert(array_keys($data) == $this->assoc_keys);
return Auth_OpenID_KVForm::fromArray($data);
} | php | function serialize()
{
$data = array(
'version' => '2',
'handle' => $this->handle,
'secret' => base64_encode($this->secret),
'issued' => strval(intval($this->issued)),
'lifetime' => strval(intval($this->lifetime)),
'assoc_type' => $this->assoc_type
);
assert(array_keys($data) == $this->assoc_keys);
return Auth_OpenID_KVForm::fromArray($data);
} | [
"function",
"serialize",
"(",
")",
"{",
"$",
"data",
"=",
"array",
"(",
"'version'",
"=>",
"'2'",
",",
"'handle'",
"=>",
"$",
"this",
"->",
"handle",
",",
"'secret'",
"=>",
"base64_encode",
"(",
"$",
"this",
"->",
"secret",
")",
",",
"'issued'",
"=>",
... | Convert an association to KV form.
@return string $result String in KV form suitable for
deserialization by deserialize. | [
"Convert",
"an",
"association",
"to",
"KV",
"form",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/Association.php#L187-L201 |
openid/php-openid | Auth/OpenID/Association.php | Auth_OpenID_Association.deserialize | static function deserialize($class_name, $assoc_s)
{
$pairs = Auth_OpenID_KVForm::toArray($assoc_s, $strict = true);
$keys = array();
$values = array();
foreach ($pairs as $key => $value) {
if (is_array($value)) {
list($key, $value) = $value;
}
$keys[] = $key;
$values[] = $value;
}
$class_vars = get_class_vars($class_name);
$class_assoc_keys = $class_vars['assoc_keys'];
sort($keys);
sort($class_assoc_keys);
if ($keys != $class_assoc_keys) {
trigger_error('Unexpected key values: ' . var_export($keys, true),
E_USER_WARNING);
return null;
}
$version = $pairs['version'];
$handle = $pairs['handle'];
$secret = $pairs['secret'];
$issued = $pairs['issued'];
$lifetime = $pairs['lifetime'];
$assoc_type = $pairs['assoc_type'];
if ($version != '2') {
trigger_error('Unknown version: ' . $version, E_USER_WARNING);
return null;
}
$issued = intval($issued);
$lifetime = intval($lifetime);
$secret = base64_decode($secret);
return new $class_name(
$handle, $secret, $issued, $lifetime, $assoc_type);
} | php | static function deserialize($class_name, $assoc_s)
{
$pairs = Auth_OpenID_KVForm::toArray($assoc_s, $strict = true);
$keys = array();
$values = array();
foreach ($pairs as $key => $value) {
if (is_array($value)) {
list($key, $value) = $value;
}
$keys[] = $key;
$values[] = $value;
}
$class_vars = get_class_vars($class_name);
$class_assoc_keys = $class_vars['assoc_keys'];
sort($keys);
sort($class_assoc_keys);
if ($keys != $class_assoc_keys) {
trigger_error('Unexpected key values: ' . var_export($keys, true),
E_USER_WARNING);
return null;
}
$version = $pairs['version'];
$handle = $pairs['handle'];
$secret = $pairs['secret'];
$issued = $pairs['issued'];
$lifetime = $pairs['lifetime'];
$assoc_type = $pairs['assoc_type'];
if ($version != '2') {
trigger_error('Unknown version: ' . $version, E_USER_WARNING);
return null;
}
$issued = intval($issued);
$lifetime = intval($lifetime);
$secret = base64_decode($secret);
return new $class_name(
$handle, $secret, $issued, $lifetime, $assoc_type);
} | [
"static",
"function",
"deserialize",
"(",
"$",
"class_name",
",",
"$",
"assoc_s",
")",
"{",
"$",
"pairs",
"=",
"Auth_OpenID_KVForm",
"::",
"toArray",
"(",
"$",
"assoc_s",
",",
"$",
"strict",
"=",
"true",
")",
";",
"$",
"keys",
"=",
"array",
"(",
")",
... | Parse an association as stored by serialize(). This is the
inverse of serialize.
@param string $class_name
@param string $assoc_s Association as serialized by serialize()
@return Auth_OpenID_Association $result instance of this class | [
"Parse",
"an",
"association",
"as",
"stored",
"by",
"serialize",
"()",
".",
"This",
"is",
"the",
"inverse",
"of",
"serialize",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/Association.php#L211-L254 |
openid/php-openid | Auth/OpenID/Association.php | Auth_OpenID_Association.sign | function sign($pairs)
{
$kv = Auth_OpenID_KVForm::fromArray($pairs);
/* Invalid association types should be caught at constructor */
$callback = $this->_macs[$this->assoc_type];
return call_user_func_array($callback, array($this->secret, $kv));
} | php | function sign($pairs)
{
$kv = Auth_OpenID_KVForm::fromArray($pairs);
/* Invalid association types should be caught at constructor */
$callback = $this->_macs[$this->assoc_type];
return call_user_func_array($callback, array($this->secret, $kv));
} | [
"function",
"sign",
"(",
"$",
"pairs",
")",
"{",
"$",
"kv",
"=",
"Auth_OpenID_KVForm",
"::",
"fromArray",
"(",
"$",
"pairs",
")",
";",
"/* Invalid association types should be caught at constructor */",
"$",
"callback",
"=",
"$",
"this",
"->",
"_macs",
"[",
"$",
... | Generate a signature for a sequence of (key, value) pairs
@access private
@param array $pairs The pairs to sign, in order. This is an
array of two-tuples.
@return string $signature The binary signature of this sequence
of pairs | [
"Generate",
"a",
"signature",
"for",
"a",
"sequence",
"of",
"(",
"key",
"value",
")",
"pairs"
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/Association.php#L265-L273 |
openid/php-openid | Auth/OpenID/Association.php | Auth_OpenID_Association.signMessage | function signMessage($message)
{
if ($message->hasKey(Auth_OpenID_OPENID_NS, 'sig') ||
$message->hasKey(Auth_OpenID_OPENID_NS, 'signed')) {
// Already has a sig
return null;
}
$extant_handle = $message->getArg(Auth_OpenID_OPENID_NS,
'assoc_handle');
if ($extant_handle && ($extant_handle != $this->handle)) {
// raise ValueError("Message has a different association handle")
return null;
}
$signed_message = $message;
$signed_message->setArg(Auth_OpenID_OPENID_NS, 'assoc_handle',
$this->handle);
$message_keys = array_keys($signed_message->toPostArgs());
$signed_list = array();
$signed_prefix = 'openid.';
foreach ($message_keys as $k) {
if (strpos($k, $signed_prefix) === 0) {
$signed_list[] = substr($k, strlen($signed_prefix));
}
}
$signed_list[] = 'signed';
sort($signed_list);
$signed_message->setArg(Auth_OpenID_OPENID_NS, 'signed',
implode(',', $signed_list));
$sig = $this->getMessageSignature($signed_message);
$signed_message->setArg(Auth_OpenID_OPENID_NS, 'sig', $sig);
return $signed_message;
} | php | function signMessage($message)
{
if ($message->hasKey(Auth_OpenID_OPENID_NS, 'sig') ||
$message->hasKey(Auth_OpenID_OPENID_NS, 'signed')) {
// Already has a sig
return null;
}
$extant_handle = $message->getArg(Auth_OpenID_OPENID_NS,
'assoc_handle');
if ($extant_handle && ($extant_handle != $this->handle)) {
// raise ValueError("Message has a different association handle")
return null;
}
$signed_message = $message;
$signed_message->setArg(Auth_OpenID_OPENID_NS, 'assoc_handle',
$this->handle);
$message_keys = array_keys($signed_message->toPostArgs());
$signed_list = array();
$signed_prefix = 'openid.';
foreach ($message_keys as $k) {
if (strpos($k, $signed_prefix) === 0) {
$signed_list[] = substr($k, strlen($signed_prefix));
}
}
$signed_list[] = 'signed';
sort($signed_list);
$signed_message->setArg(Auth_OpenID_OPENID_NS, 'signed',
implode(',', $signed_list));
$sig = $this->getMessageSignature($signed_message);
$signed_message->setArg(Auth_OpenID_OPENID_NS, 'sig', $sig);
return $signed_message;
} | [
"function",
"signMessage",
"(",
"$",
"message",
")",
"{",
"if",
"(",
"$",
"message",
"->",
"hasKey",
"(",
"Auth_OpenID_OPENID_NS",
",",
"'sig'",
")",
"||",
"$",
"message",
"->",
"hasKey",
"(",
"Auth_OpenID_OPENID_NS",
",",
"'signed'",
")",
")",
"{",
"// Al... | Generate a signature for some fields in a dictionary
@access private
@param Auth_OpenID_Message $message
@return string $signature The signature, base64 encoded
@internal param array $fields The fields to sign, in order; this is an
array of strings.
@internal param array $data Dictionary of values to sign (an array of
string => string pairs). | [
"Generate",
"a",
"signature",
"for",
"some",
"fields",
"in",
"a",
"dictionary"
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/Association.php#L286-L324 |
openid/php-openid | Auth/OpenID/Association.php | Auth_OpenID_Association._makePairs | function _makePairs($message)
{
$signed = $message->getArg(Auth_OpenID_OPENID_NS, 'signed');
if (!$signed || Auth_OpenID::isFailure($signed)) {
// raise ValueError('Message has no signed list: %s' % (message,))
return null;
}
$signed_list = explode(',', $signed);
$pairs = array();
$data = $message->toPostArgs();
foreach ($signed_list as $field) {
$pairs[] = array($field, Auth_OpenID::arrayGet($data,
'openid.' .
$field, ''));
}
return $pairs;
} | php | function _makePairs($message)
{
$signed = $message->getArg(Auth_OpenID_OPENID_NS, 'signed');
if (!$signed || Auth_OpenID::isFailure($signed)) {
// raise ValueError('Message has no signed list: %s' % (message,))
return null;
}
$signed_list = explode(',', $signed);
$pairs = array();
$data = $message->toPostArgs();
foreach ($signed_list as $field) {
$pairs[] = array($field, Auth_OpenID::arrayGet($data,
'openid.' .
$field, ''));
}
return $pairs;
} | [
"function",
"_makePairs",
"(",
"$",
"message",
")",
"{",
"$",
"signed",
"=",
"$",
"message",
"->",
"getArg",
"(",
"Auth_OpenID_OPENID_NS",
",",
"'signed'",
")",
";",
"if",
"(",
"!",
"$",
"signed",
"||",
"Auth_OpenID",
"::",
"isFailure",
"(",
"$",
"signed... | Given a {@link Auth_OpenID_Message}, return the key/value pairs
to be signed according to the signed list in the message. If
the message lacks a signed list, return null.
@access private
@param Auth_OpenID_Message $message
@return array|null | [
"Given",
"a",
"{",
"@link",
"Auth_OpenID_Message",
"}",
"return",
"the",
"key",
"/",
"value",
"pairs",
"to",
"be",
"signed",
"according",
"to",
"the",
"signed",
"list",
"in",
"the",
"message",
".",
"If",
"the",
"message",
"lacks",
"a",
"signed",
"list",
... | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/Association.php#L335-L352 |
openid/php-openid | Auth/OpenID/Association.php | Auth_OpenID_Association.getMessageSignature | function getMessageSignature($message)
{
$pairs = $this->_makePairs($message);
return base64_encode($this->sign($pairs));
} | php | function getMessageSignature($message)
{
$pairs = $this->_makePairs($message);
return base64_encode($this->sign($pairs));
} | [
"function",
"getMessageSignature",
"(",
"$",
"message",
")",
"{",
"$",
"pairs",
"=",
"$",
"this",
"->",
"_makePairs",
"(",
"$",
"message",
")",
";",
"return",
"base64_encode",
"(",
"$",
"this",
"->",
"sign",
"(",
"$",
"pairs",
")",
")",
";",
"}"
] | Given an {@link Auth_OpenID_Message}, return the signature for
the signed list in the message.
@access private
@param Auth_OpenID_Message $message
@return string | [
"Given",
"an",
"{",
"@link",
"Auth_OpenID_Message",
"}",
"return",
"the",
"signature",
"for",
"the",
"signed",
"list",
"in",
"the",
"message",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/Association.php#L362-L366 |
openid/php-openid | Auth/OpenID/Association.php | Auth_OpenID_Association.checkMessageSignature | function checkMessageSignature($message)
{
$sig = $message->getArg(Auth_OpenID_OPENID_NS,
'sig');
if (!$sig || Auth_OpenID::isFailure($sig)) {
return false;
}
$calculated_sig = $this->getMessageSignature($message);
return Auth_OpenID_CryptUtil::constEq($calculated_sig, $sig);
} | php | function checkMessageSignature($message)
{
$sig = $message->getArg(Auth_OpenID_OPENID_NS,
'sig');
if (!$sig || Auth_OpenID::isFailure($sig)) {
return false;
}
$calculated_sig = $this->getMessageSignature($message);
return Auth_OpenID_CryptUtil::constEq($calculated_sig, $sig);
} | [
"function",
"checkMessageSignature",
"(",
"$",
"message",
")",
"{",
"$",
"sig",
"=",
"$",
"message",
"->",
"getArg",
"(",
"Auth_OpenID_OPENID_NS",
",",
"'sig'",
")",
";",
"if",
"(",
"!",
"$",
"sig",
"||",
"Auth_OpenID",
"::",
"isFailure",
"(",
"$",
"sig"... | Confirm that the signature of these fields matches the
signature contained in the data.
@access private
@param Auth_OpenID_Message $message
@return bool | [
"Confirm",
"that",
"the",
"signature",
"of",
"these",
"fields",
"matches",
"the",
"signature",
"contained",
"in",
"the",
"data",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/Association.php#L376-L387 |
openid/php-openid | Auth/OpenID/Association.php | Auth_OpenID_SessionNegotiator.setAllowedTypes | function setAllowedTypes($allowed_types)
{
foreach ($allowed_types as $pair) {
list($assoc_type, $session_type) = $pair;
if (!Auth_OpenID_checkSessionType($assoc_type, $session_type)) {
return false;
}
}
$this->allowed_types = $allowed_types;
return true;
} | php | function setAllowedTypes($allowed_types)
{
foreach ($allowed_types as $pair) {
list($assoc_type, $session_type) = $pair;
if (!Auth_OpenID_checkSessionType($assoc_type, $session_type)) {
return false;
}
}
$this->allowed_types = $allowed_types;
return true;
} | [
"function",
"setAllowedTypes",
"(",
"$",
"allowed_types",
")",
"{",
"foreach",
"(",
"$",
"allowed_types",
"as",
"$",
"pair",
")",
"{",
"list",
"(",
"$",
"assoc_type",
",",
"$",
"session_type",
")",
"=",
"$",
"pair",
";",
"if",
"(",
"!",
"Auth_OpenID_chec... | Set the allowed association types, checking to make sure each
combination is valid.
@access private
@param array $allowed_types
@return bool | [
"Set",
"the",
"allowed",
"association",
"types",
"checking",
"to",
"make",
"sure",
"each",
"combination",
"is",
"valid",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/Association.php#L553-L564 |
openid/php-openid | Auth/OpenID/Association.php | Auth_OpenID_SessionNegotiator.addAllowedType | function addAllowedType($assoc_type, $session_type = null)
{
if ($this->allowed_types === null) {
$this->allowed_types = array();
}
if ($session_type === null) {
$available = Auth_OpenID_getSessionTypes($assoc_type);
if (!$available) {
return false;
}
foreach ($available as $session_type) {
$this->addAllowedType($assoc_type, $session_type);
}
} else {
if (Auth_OpenID_checkSessionType($assoc_type, $session_type)) {
$this->allowed_types[] = array($assoc_type, $session_type);
} else {
return false;
}
}
return true;
} | php | function addAllowedType($assoc_type, $session_type = null)
{
if ($this->allowed_types === null) {
$this->allowed_types = array();
}
if ($session_type === null) {
$available = Auth_OpenID_getSessionTypes($assoc_type);
if (!$available) {
return false;
}
foreach ($available as $session_type) {
$this->addAllowedType($assoc_type, $session_type);
}
} else {
if (Auth_OpenID_checkSessionType($assoc_type, $session_type)) {
$this->allowed_types[] = array($assoc_type, $session_type);
} else {
return false;
}
}
return true;
} | [
"function",
"addAllowedType",
"(",
"$",
"assoc_type",
",",
"$",
"session_type",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"allowed_types",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"allowed_types",
"=",
"array",
"(",
")",
";",
"}",
"if",
... | Add an association type and session type to the allowed types
list. The assocation/session pairs are tried in the order that
they are added.
@access private
@param $assoc_type
@param null $session_type
@return bool | [
"Add",
"an",
"association",
"type",
"and",
"session",
"type",
"to",
"the",
"allowed",
"types",
"list",
".",
"The",
"assocation",
"/",
"session",
"pairs",
"are",
"tried",
"in",
"the",
"order",
"that",
"they",
"are",
"added",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/Association.php#L576-L601 |
openid/php-openid | Auth/OpenID/Association.php | Auth_OpenID_SessionNegotiator.isAllowed | function isAllowed($assoc_type, $session_type)
{
$assoc_good = in_array(array($assoc_type, $session_type),
$this->allowed_types);
$matches = in_array($session_type,
Auth_OpenID_getSessionTypes($assoc_type));
return ($assoc_good && $matches);
} | php | function isAllowed($assoc_type, $session_type)
{
$assoc_good = in_array(array($assoc_type, $session_type),
$this->allowed_types);
$matches = in_array($session_type,
Auth_OpenID_getSessionTypes($assoc_type));
return ($assoc_good && $matches);
} | [
"function",
"isAllowed",
"(",
"$",
"assoc_type",
",",
"$",
"session_type",
")",
"{",
"$",
"assoc_good",
"=",
"in_array",
"(",
"array",
"(",
"$",
"assoc_type",
",",
"$",
"session_type",
")",
",",
"$",
"this",
"->",
"allowed_types",
")",
";",
"$",
"matches... | Is this combination of association type and session type allowed? | [
"Is",
"this",
"combination",
"of",
"association",
"type",
"and",
"session",
"type",
"allowed?"
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/Association.php#L604-L613 |
openid/php-openid | Auth/OpenID/SQLStore.php | Auth_OpenID_SQLStore.reset | function reset()
{
$this->connection->query(sprintf("DELETE FROM %s",
$this->associations_table_name));
$this->connection->query(sprintf("DELETE FROM %s",
$this->nonces_table_name));
} | php | function reset()
{
$this->connection->query(sprintf("DELETE FROM %s",
$this->associations_table_name));
$this->connection->query(sprintf("DELETE FROM %s",
$this->nonces_table_name));
} | [
"function",
"reset",
"(",
")",
"{",
"$",
"this",
"->",
"connection",
"->",
"query",
"(",
"sprintf",
"(",
"\"DELETE FROM %s\"",
",",
"$",
"this",
"->",
"associations_table_name",
")",
")",
";",
"$",
"this",
"->",
"connection",
"->",
"query",
"(",
"sprintf",... | Resets the store by removing all records from the store's
tables. | [
"Resets",
"the",
"store",
"by",
"removing",
"all",
"records",
"from",
"the",
"store",
"s",
"tables",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/SQLStore.php#L212-L219 |
openid/php-openid | Auth/OpenID/SQLStore.php | Auth_OpenID_SQLStore._octify | function _octify($str)
{
$result = "";
for ($i = 0; $i < Auth_OpenID::bytes($str); $i++) {
$ch = substr($str, $i, 1);
if ($ch == "\\") {
$result .= "\\\\\\\\";
} else if (ord($ch) == 0) {
$result .= "\\\\000";
} else {
$result .= "\\" . strval(decoct(ord($ch)));
}
}
return $result;
} | php | function _octify($str)
{
$result = "";
for ($i = 0; $i < Auth_OpenID::bytes($str); $i++) {
$ch = substr($str, $i, 1);
if ($ch == "\\") {
$result .= "\\\\\\\\";
} else if (ord($ch) == 0) {
$result .= "\\\\000";
} else {
$result .= "\\" . strval(decoct(ord($ch)));
}
}
return $result;
} | [
"function",
"_octify",
"(",
"$",
"str",
")",
"{",
"$",
"result",
"=",
"\"\"",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"Auth_OpenID",
"::",
"bytes",
"(",
"$",
"str",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"ch",
"=",
"subst... | "Octifies" a binary string by returning a string with escaped
octal bytes. This is used for preparing binary data for
PostgreSQL BYTEA fields.
@access private
@param string $str
@return string | [
"Octifies",
"a",
"binary",
"string",
"by",
"returning",
"a",
"string",
"with",
"escaped",
"octal",
"bytes",
".",
"This",
"is",
"used",
"for",
"preparing",
"binary",
"data",
"for",
"PostgreSQL",
"BYTEA",
"fields",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/SQLStore.php#L517-L531 |
openid/php-openid | Auth/OpenID/SQLStore.php | Auth_OpenID_SQLStore._unoctify | function _unoctify($str)
{
$result = "";
$i = 0;
while ($i < strlen($str)) {
$char = $str[$i];
if ($char == "\\") {
// Look to see if the next char is a backslash and
// append it.
if ($str[$i + 1] != "\\") {
$octal_digits = substr($str, $i + 1, 3);
$dec = octdec($octal_digits);
$char = chr($dec);
$i += 4;
} else {
$char = "\\";
$i += 2;
}
} else {
$i += 1;
}
$result .= $char;
}
return $result;
} | php | function _unoctify($str)
{
$result = "";
$i = 0;
while ($i < strlen($str)) {
$char = $str[$i];
if ($char == "\\") {
// Look to see if the next char is a backslash and
// append it.
if ($str[$i + 1] != "\\") {
$octal_digits = substr($str, $i + 1, 3);
$dec = octdec($octal_digits);
$char = chr($dec);
$i += 4;
} else {
$char = "\\";
$i += 2;
}
} else {
$i += 1;
}
$result .= $char;
}
return $result;
} | [
"function",
"_unoctify",
"(",
"$",
"str",
")",
"{",
"$",
"result",
"=",
"\"\"",
";",
"$",
"i",
"=",
"0",
";",
"while",
"(",
"$",
"i",
"<",
"strlen",
"(",
"$",
"str",
")",
")",
"{",
"$",
"char",
"=",
"$",
"str",
"[",
"$",
"i",
"]",
";",
"i... | "Unoctifies" octal-escaped data from PostgreSQL and returns the
resulting ASCII (possibly binary) string.
@access private
@param string $str
@return string | [
"Unoctifies",
"octal",
"-",
"escaped",
"data",
"from",
"PostgreSQL",
"and",
"returns",
"the",
"resulting",
"ASCII",
"(",
"possibly",
"binary",
")",
"string",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/SQLStore.php#L541-L567 |
openid/php-openid | Auth/Yadis/XML.php | Auth_Yadis_XMLParser.init | function init($xml_string, $namespace_map)
{
if (!$this->setXML($xml_string)) {
return false;
}
foreach ($namespace_map as $prefix => $uri) {
if (!$this->registerNamespace($prefix, $uri)) {
return false;
}
}
return true;
} | php | function init($xml_string, $namespace_map)
{
if (!$this->setXML($xml_string)) {
return false;
}
foreach ($namespace_map as $prefix => $uri) {
if (!$this->registerNamespace($prefix, $uri)) {
return false;
}
}
return true;
} | [
"function",
"init",
"(",
"$",
"xml_string",
",",
"$",
"namespace_map",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"setXML",
"(",
"$",
"xml_string",
")",
")",
"{",
"return",
"false",
";",
"}",
"foreach",
"(",
"$",
"namespace_map",
"as",
"$",
"prefix... | Initialize an instance of Auth_Yadis_XMLParser with some
XML and namespaces. This SHOULD NOT be overridden by
subclasses.
@param string $xml_string A string of XML to be parsed.
@param array $namespace_map An array of ($ns_name => $ns_uri)
to be registered with the XML parser. May be empty.
@return boolean $result True if the initialization and
namespace registration(s) succeeded; false otherwise. | [
"Initialize",
"an",
"instance",
"of",
"Auth_Yadis_XMLParser",
"with",
"some",
"XML",
"and",
"namespaces",
".",
"This",
"SHOULD",
"NOT",
"be",
"overridden",
"by",
"subclasses",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/Yadis/XML.php#L33-L46 |
openid/php-openid | Auth/OpenID/KVForm.php | Auth_OpenID_KVForm.toArray | static function toArray($kvs, $strict=false)
{
$lines = explode("\n", $kvs);
$last = array_pop($lines);
if ($last !== '') {
array_push($lines, $last);
if ($strict) {
return false;
}
}
$values = array();
for ($lineno = 0; $lineno < count($lines); $lineno++) {
$line = $lines[$lineno];
$kv = explode(':', $line, 2);
if (count($kv) != 2) {
if ($strict) {
return false;
}
continue;
}
$key = $kv[0];
$tkey = trim($key);
if ($tkey != $key) {
if ($strict) {
return false;
}
}
$value = $kv[1];
$tval = trim($value);
if ($tval != $value) {
if ($strict) {
return false;
}
}
$values[$tkey] = $tval;
}
return $values;
} | php | static function toArray($kvs, $strict=false)
{
$lines = explode("\n", $kvs);
$last = array_pop($lines);
if ($last !== '') {
array_push($lines, $last);
if ($strict) {
return false;
}
}
$values = array();
for ($lineno = 0; $lineno < count($lines); $lineno++) {
$line = $lines[$lineno];
$kv = explode(':', $line, 2);
if (count($kv) != 2) {
if ($strict) {
return false;
}
continue;
}
$key = $kv[0];
$tkey = trim($key);
if ($tkey != $key) {
if ($strict) {
return false;
}
}
$value = $kv[1];
$tval = trim($value);
if ($tval != $value) {
if ($strict) {
return false;
}
}
$values[$tkey] = $tval;
}
return $values;
} | [
"static",
"function",
"toArray",
"(",
"$",
"kvs",
",",
"$",
"strict",
"=",
"false",
")",
"{",
"$",
"lines",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"kvs",
")",
";",
"$",
"last",
"=",
"array_pop",
"(",
"$",
"lines",
")",
";",
"if",
"(",
"$",
"... | Convert an OpenID colon/newline separated string into an
associative array
@static
@access private
@param string $kvs
@param bool $strict
@return array|bool | [
"Convert",
"an",
"OpenID",
"colon",
"/",
"newline",
"separated",
"string",
"into",
"an",
"associative",
"array"
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/KVForm.php#L32-L76 |
openid/php-openid | Auth/OpenID/KVForm.php | Auth_OpenID_KVForm.fromArray | static function fromArray($values)
{
if ($values === null) {
return null;
}
ksort($values);
$serialized = '';
foreach ($values as $key => $value) {
if (is_array($value)) {
list($key, $value) = array($value[0], $value[1]);
}
if (strpos($key, ':') !== false) {
return null;
}
if (strpos($key, "\n") !== false) {
return null;
}
if (strpos($value, "\n") !== false) {
return null;
}
$serialized .= "$key:$value\n";
}
return $serialized;
} | php | static function fromArray($values)
{
if ($values === null) {
return null;
}
ksort($values);
$serialized = '';
foreach ($values as $key => $value) {
if (is_array($value)) {
list($key, $value) = array($value[0], $value[1]);
}
if (strpos($key, ':') !== false) {
return null;
}
if (strpos($key, "\n") !== false) {
return null;
}
if (strpos($value, "\n") !== false) {
return null;
}
$serialized .= "$key:$value\n";
}
return $serialized;
} | [
"static",
"function",
"fromArray",
"(",
"$",
"values",
")",
"{",
"if",
"(",
"$",
"values",
"===",
"null",
")",
"{",
"return",
"null",
";",
"}",
"ksort",
"(",
"$",
"values",
")",
";",
"$",
"serialized",
"=",
"''",
";",
"foreach",
"(",
"$",
"values",... | Convert an array into an OpenID colon/newline separated string
@static
@access private
@param null|array $values
@return null|string | [
"Convert",
"an",
"array",
"into",
"an",
"OpenID",
"colon",
"/",
"newline",
"separated",
"string"
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/KVForm.php#L86-L114 |
openid/php-openid | contrib/signed_assertions/SAML.php | SAML.createSamlAssertion | function createSamlAssertion($authenticatedUser, $notBefore, $notOnOrAfter, $rsadsa, $acsURI,$attribute,$value,$assertionTemplate)
{
$samlResponse = $assertionTemplate;
$samlResponse = str_replace('USERNAME_STRING', $authenticatedUser, $samlResponse);
$samlResponse = str_replace('RESPONSE_ID', $this->samlCreateId(), $samlResponse);
$samlResponse = str_replace('ISSUE_INSTANT', $this->samlGetDateTime(time()), $samlResponse);
$samlResponse = str_replace('NOT_BEFORE', $this->samlGetDateTime(strtotime($notBefore)), $samlResponse);
$samlResponse = str_replace('NOT_ON_OR_AFTER', $this->samlGetDateTime(strtotime($notOnOrAfter)),$samlResponse);
$samlResponse = str_replace('ASSERTION_ID',$this->samlCreateId(), $samlResponse);
$samlResponse = str_replace('RSADSA', strtolower($rsadsa), $samlResponse);
$samlResponse = str_replace('ISSUER_DOMAIN', $acsURI, $samlResponse);
$samlResponse = str_replace('ATTRIBUTE_NAME', $attribute, $samlResponse);
$samlResponse = str_replace('ATTRIBUTE_VALUE', $value, $samlResponse);
return $samlResponse;
} | php | function createSamlAssertion($authenticatedUser, $notBefore, $notOnOrAfter, $rsadsa, $acsURI,$attribute,$value,$assertionTemplate)
{
$samlResponse = $assertionTemplate;
$samlResponse = str_replace('USERNAME_STRING', $authenticatedUser, $samlResponse);
$samlResponse = str_replace('RESPONSE_ID', $this->samlCreateId(), $samlResponse);
$samlResponse = str_replace('ISSUE_INSTANT', $this->samlGetDateTime(time()), $samlResponse);
$samlResponse = str_replace('NOT_BEFORE', $this->samlGetDateTime(strtotime($notBefore)), $samlResponse);
$samlResponse = str_replace('NOT_ON_OR_AFTER', $this->samlGetDateTime(strtotime($notOnOrAfter)),$samlResponse);
$samlResponse = str_replace('ASSERTION_ID',$this->samlCreateId(), $samlResponse);
$samlResponse = str_replace('RSADSA', strtolower($rsadsa), $samlResponse);
$samlResponse = str_replace('ISSUER_DOMAIN', $acsURI, $samlResponse);
$samlResponse = str_replace('ATTRIBUTE_NAME', $attribute, $samlResponse);
$samlResponse = str_replace('ATTRIBUTE_VALUE', $value, $samlResponse);
return $samlResponse;
} | [
"function",
"createSamlAssertion",
"(",
"$",
"authenticatedUser",
",",
"$",
"notBefore",
",",
"$",
"notOnOrAfter",
",",
"$",
"rsadsa",
",",
"$",
"acsURI",
",",
"$",
"attribute",
",",
"$",
"value",
",",
"$",
"assertionTemplate",
")",
"{",
"$",
"samlResponse",... | Returns a SAML response with various elements filled in.
@param string $authenticatedUser The OpenId of the user
@param string $notBefore The ISO 8601 formatted date before which the
response is invalid
@param string $notOnOrAfter The ISO 8601 formatted data after which the
response is invalid
@param string $rsadsa 'rsa' if the response will be signed with RSA keys,
'dsa' for DSA keys
@param string $requestID The ID of the request we're responding to
@param string $destination The ACS URL that the response is submitted to
@return string XML SAML response. | [
"Returns",
"a",
"SAML",
"response",
"with",
"various",
"elements",
"filled",
"in",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/contrib/signed_assertions/SAML.php#L43-L57 |
openid/php-openid | contrib/signed_assertions/SAML.php | SAML.signAssertion | function signAssertion($responseXmlString,$privKey,$cert)
{
if (file_exists("/tmp/xml")) {
$tempFileDir="/tmp/xml/";
} else {
mkdir("/tmp/xml",0777);
$tempFileDir="/tmp/xml/";
}
$tempName = 'saml-response-' . $this->samlCreateId() . '.xml';
$tempFileName=$tempFileDir.$tempName;
while (file_exists($tempFileName))
$tempFileName = 'saml-response-' . $this->samlCreateId() . '.xml';
if (!$handle = fopen($tempFileName, 'w')) {
return null;
}
if (fwrite($handle, $responseXmlString) === false) {
return null;
}
fclose($handle);
$cmd = 'xmlsec1 --sign --privkey-pem ' . $privKey .
',' . $cert . ' --output ' . $tempFileName .
'.out ' . $tempFileName;
exec($cmd, $resp);
unlink($tempFileName);
$xmlResult = @file_get_contents($tempFileName . '.out');
if (!$xmlResult) {
return null;
} else {
unlink($tempFileName . '.out');
return $xmlResult;
}
} | php | function signAssertion($responseXmlString,$privKey,$cert)
{
if (file_exists("/tmp/xml")) {
$tempFileDir="/tmp/xml/";
} else {
mkdir("/tmp/xml",0777);
$tempFileDir="/tmp/xml/";
}
$tempName = 'saml-response-' . $this->samlCreateId() . '.xml';
$tempFileName=$tempFileDir.$tempName;
while (file_exists($tempFileName))
$tempFileName = 'saml-response-' . $this->samlCreateId() . '.xml';
if (!$handle = fopen($tempFileName, 'w')) {
return null;
}
if (fwrite($handle, $responseXmlString) === false) {
return null;
}
fclose($handle);
$cmd = 'xmlsec1 --sign --privkey-pem ' . $privKey .
',' . $cert . ' --output ' . $tempFileName .
'.out ' . $tempFileName;
exec($cmd, $resp);
unlink($tempFileName);
$xmlResult = @file_get_contents($tempFileName . '.out');
if (!$xmlResult) {
return null;
} else {
unlink($tempFileName . '.out');
return $xmlResult;
}
} | [
"function",
"signAssertion",
"(",
"$",
"responseXmlString",
",",
"$",
"privKey",
",",
"$",
"cert",
")",
"{",
"if",
"(",
"file_exists",
"(",
"\"/tmp/xml\"",
")",
")",
"{",
"$",
"tempFileDir",
"=",
"\"/tmp/xml/\"",
";",
"}",
"else",
"{",
"mkdir",
"(",
"\"/... | Signs a SAML response with the given private key, and embeds the public key.
@param string $responseXmlString The unsigned Assertion which will be signed
@param string $priKey Private key to sign the certificate
@param string $cert Public key certificate of signee
@return string Signed Assertion | [
"Signs",
"a",
"SAML",
"response",
"with",
"the",
"given",
"private",
"key",
"and",
"embeds",
"the",
"public",
"key",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/contrib/signed_assertions/SAML.php#L66-L100 |
openid/php-openid | contrib/signed_assertions/SAML.php | SAML.verifyAssertion | function verifyAssertion($responseXmlString,$rootcert)
{
date_default_timezone_set("UTC");
if (file_exists("/tmp/xml")) {
$tempFileDir="/tmp/xml/";
} else {
mkdir("/tmp/xml",0777);
$tempFileDir="/tmp/xml/";
}
$tempName = 'saml-response-' . $this->samlCreateId() . '.xml';
$tempFileName=$tempFileDir.$tempName;
while (file_exists($tempFileName))
$tempFileName = 'saml-response-' . $this->samlCreateId() . '.xml';
if (!$handle = fopen($tempFileName, 'w')) {
return false;
}
if (fwrite($handle, $responseXmlString) === false) {
return false;
}
$p=xml_parser_create();
$result=xml_parse_into_struct($p,$responseXmlString,$vals,$index);
xml_parser_free($p);
$cert_info=$index["X509CERTIFICATE"];
$conditions=$index["CONDITIONS"];
foreach($cert_info as $key=>$value){
file_put_contents($tempFileName.'.cert',$vals[$value]['value']);
}
$cert=$tempFileName.'.cert';
$before=0;
$after=0;
foreach($conditions as $key=>$value){
$before=$vals[$value]['attributes']['NOTBEFORE'];
$after=$vals[$value]['attributes']['NOTONORAFTER'];
}
$before=$this->validSamlDateFormat($before);
$after=$this->validSamlDateFormat($after);
if(strtotime("now") < $before || strtotime("now") >= $after){
unlink($tempFileName);
unlink($cert);
return false;
}
fclose($handle);
$cmd = 'xmlsec1 --verify --pubkey-cert ' . $cert .'--trusted '.$rootcert. ' '.$tempFileName.'* 2>&1 1>/dev/null';
exec($cmd,$resp);
if(strcmp($resp[0],"FAIL") == 0){
$value = false;
}elseif(strcmp($resp[0],"ERROR") == 0){
$value = false;
}elseif(strcmp($resp[0],"OK") == 0){
$value = TRUE;
}
unlink($tempFileName);
unlink($cert);
return $value;
} | php | function verifyAssertion($responseXmlString,$rootcert)
{
date_default_timezone_set("UTC");
if (file_exists("/tmp/xml")) {
$tempFileDir="/tmp/xml/";
} else {
mkdir("/tmp/xml",0777);
$tempFileDir="/tmp/xml/";
}
$tempName = 'saml-response-' . $this->samlCreateId() . '.xml';
$tempFileName=$tempFileDir.$tempName;
while (file_exists($tempFileName))
$tempFileName = 'saml-response-' . $this->samlCreateId() . '.xml';
if (!$handle = fopen($tempFileName, 'w')) {
return false;
}
if (fwrite($handle, $responseXmlString) === false) {
return false;
}
$p=xml_parser_create();
$result=xml_parse_into_struct($p,$responseXmlString,$vals,$index);
xml_parser_free($p);
$cert_info=$index["X509CERTIFICATE"];
$conditions=$index["CONDITIONS"];
foreach($cert_info as $key=>$value){
file_put_contents($tempFileName.'.cert',$vals[$value]['value']);
}
$cert=$tempFileName.'.cert';
$before=0;
$after=0;
foreach($conditions as $key=>$value){
$before=$vals[$value]['attributes']['NOTBEFORE'];
$after=$vals[$value]['attributes']['NOTONORAFTER'];
}
$before=$this->validSamlDateFormat($before);
$after=$this->validSamlDateFormat($after);
if(strtotime("now") < $before || strtotime("now") >= $after){
unlink($tempFileName);
unlink($cert);
return false;
}
fclose($handle);
$cmd = 'xmlsec1 --verify --pubkey-cert ' . $cert .'--trusted '.$rootcert. ' '.$tempFileName.'* 2>&1 1>/dev/null';
exec($cmd,$resp);
if(strcmp($resp[0],"FAIL") == 0){
$value = false;
}elseif(strcmp($resp[0],"ERROR") == 0){
$value = false;
}elseif(strcmp($resp[0],"OK") == 0){
$value = TRUE;
}
unlink($tempFileName);
unlink($cert);
return $value;
} | [
"function",
"verifyAssertion",
"(",
"$",
"responseXmlString",
",",
"$",
"rootcert",
")",
"{",
"date_default_timezone_set",
"(",
"\"UTC\"",
")",
";",
"if",
"(",
"file_exists",
"(",
"\"/tmp/xml\"",
")",
")",
"{",
"$",
"tempFileDir",
"=",
"\"/tmp/xml/\"",
";",
"}... | Verify a saml response with the given public key.
@param string $responseXmlString Response to sign
@param string $rootcert trusted public key certificate
@return string Signed SAML response | [
"Verify",
"a",
"saml",
"response",
"with",
"the",
"given",
"public",
"key",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/contrib/signed_assertions/SAML.php#L109-L168 |
openid/php-openid | contrib/signed_assertions/SAML.php | SAML.samlCreateId | function samlCreateId()
{
$rndChars = 'abcdefghijklmnop';
$rndId = '';
for ($i = 0; $i < 40; $i++ ) {
$rndId .= $rndChars[rand(0,strlen($rndChars)-1)];
}
return $rndId;
} | php | function samlCreateId()
{
$rndChars = 'abcdefghijklmnop';
$rndId = '';
for ($i = 0; $i < 40; $i++ ) {
$rndId .= $rndChars[rand(0,strlen($rndChars)-1)];
}
return $rndId;
} | [
"function",
"samlCreateId",
"(",
")",
"{",
"$",
"rndChars",
"=",
"'abcdefghijklmnop'",
";",
"$",
"rndId",
"=",
"''",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"40",
";",
"$",
"i",
"++",
")",
"{",
"$",
"rndId",
".=",
"$",
"rndChar... | Creates a 40-character string containing 160-bits of pseudorandomness.
@return string Containing pseudorandomness of 160 bits | [
"Creates",
"a",
"40",
"-",
"character",
"string",
"containing",
"160",
"-",
"bits",
"of",
"pseudorandomness",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/contrib/signed_assertions/SAML.php#L175-L183 |
openid/php-openid | contrib/signed_assertions/SAML.php | SAML.validSamlDateFormat | function validSamlDateFormat($samlDate)
{
if ($samlDate == "") return false;
$indexT = strpos($samlDate, 'T');
$indexZ = strpos($samlDate, 'Z');
if (($indexT != 10) || ($indexZ != 19)) {
return false;
}
$dateString = substr($samlDate, 0, 10);
$timeString = substr($samlDate, $indexT + 1, 8);
list($year, $month, $day) = explode('-', $dateString);
list($hour, $minute, $second) = explode(':', $timeString);
$parsedDate = gmmktime($hour, $minute, $second, $month, $day, $year);
if (($parsedDate === false) || ($parsedDate == -1)) return false;
if (!checkdate($month, $day, $year)) return false;
return $parsedDate;
} | php | function validSamlDateFormat($samlDate)
{
if ($samlDate == "") return false;
$indexT = strpos($samlDate, 'T');
$indexZ = strpos($samlDate, 'Z');
if (($indexT != 10) || ($indexZ != 19)) {
return false;
}
$dateString = substr($samlDate, 0, 10);
$timeString = substr($samlDate, $indexT + 1, 8);
list($year, $month, $day) = explode('-', $dateString);
list($hour, $minute, $second) = explode(':', $timeString);
$parsedDate = gmmktime($hour, $minute, $second, $month, $day, $year);
if (($parsedDate === false) || ($parsedDate == -1)) return false;
if (!checkdate($month, $day, $year)) return false;
return $parsedDate;
} | [
"function",
"validSamlDateFormat",
"(",
"$",
"samlDate",
")",
"{",
"if",
"(",
"$",
"samlDate",
"==",
"\"\"",
")",
"return",
"false",
";",
"$",
"indexT",
"=",
"strpos",
"(",
"$",
"samlDate",
",",
"'T'",
")",
";",
"$",
"indexZ",
"=",
"strpos",
"(",
"$"... | Attempts to check whether a SAML date is valid. Returns true or false.
@param string $samlDate
@return bool | [
"Attempts",
"to",
"check",
"whether",
"a",
"SAML",
"date",
"is",
"valid",
".",
"Returns",
"true",
"or",
"false",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/contrib/signed_assertions/SAML.php#L201-L217 |
openid/php-openid | Auth/OpenID/MemcachedStore.php | Auth_OpenID_MemcachedStore.storeAssociation | function storeAssociation($server_url, $association)
{
// create memcached keys for association itself
// and list of associations for this server
$associationKey = $this->associationKey($server_url,
$association->handle);
$serverKey = $this->associationServerKey($server_url);
// get list of associations
$serverAssociations = $this->connection->get($serverKey);
// if no such list, initialize it with empty array
if (!$serverAssociations) {
$serverAssociations = array();
}
// and store given association key in it
$serverAssociations[$association->issued] = $associationKey;
// save associations' keys list
$this->connection->set(
$serverKey,
$serverAssociations,
$this->compress
);
// save association itself
$this->connection->set(
$associationKey,
$association,
$this->compress,
$association->issued + $association->lifetime);
} | php | function storeAssociation($server_url, $association)
{
// create memcached keys for association itself
// and list of associations for this server
$associationKey = $this->associationKey($server_url,
$association->handle);
$serverKey = $this->associationServerKey($server_url);
// get list of associations
$serverAssociations = $this->connection->get($serverKey);
// if no such list, initialize it with empty array
if (!$serverAssociations) {
$serverAssociations = array();
}
// and store given association key in it
$serverAssociations[$association->issued] = $associationKey;
// save associations' keys list
$this->connection->set(
$serverKey,
$serverAssociations,
$this->compress
);
// save association itself
$this->connection->set(
$associationKey,
$association,
$this->compress,
$association->issued + $association->lifetime);
} | [
"function",
"storeAssociation",
"(",
"$",
"server_url",
",",
"$",
"association",
")",
"{",
"// create memcached keys for association itself",
"// and list of associations for this server",
"$",
"associationKey",
"=",
"$",
"this",
"->",
"associationKey",
"(",
"$",
"server_ur... | Store association until its expiration time in memcached.
Overwrites any existing association with same server_url and
handle. Handles list of associations for every server.
@param string $server_url
@param Auth_OpenID_Association $association | [
"Store",
"association",
"until",
"its",
"expiration",
"time",
"in",
"memcached",
".",
"Overwrites",
"any",
"existing",
"association",
"with",
"same",
"server_url",
"and",
"handle",
".",
"Handles",
"list",
"of",
"associations",
"for",
"every",
"server",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/MemcachedStore.php#L64-L94 |
openid/php-openid | Auth/OpenID/MemcachedStore.php | Auth_OpenID_MemcachedStore.getAssociation | function getAssociation($server_url, $handle = null)
{
// simple case: handle given
if ($handle !== null) {
// get association, return null if failed
$association = $this->connection->get(
$this->associationKey($server_url, $handle));
return $association ? $association : null;
}
// no handle given, working with list
// create key for list of associations
$serverKey = $this->associationServerKey($server_url);
// get list of associations
$serverAssociations = $this->connection->get($serverKey);
// return null if failed or got empty list
if (!$serverAssociations) {
return null;
}
// get key of most recently issued association
$keys = array_keys($serverAssociations);
sort($keys);
$lastKey = $serverAssociations[array_pop($keys)];
// get association, return null if failed
$association = $this->connection->get($lastKey);
return $association ? $association : null;
} | php | function getAssociation($server_url, $handle = null)
{
// simple case: handle given
if ($handle !== null) {
// get association, return null if failed
$association = $this->connection->get(
$this->associationKey($server_url, $handle));
return $association ? $association : null;
}
// no handle given, working with list
// create key for list of associations
$serverKey = $this->associationServerKey($server_url);
// get list of associations
$serverAssociations = $this->connection->get($serverKey);
// return null if failed or got empty list
if (!$serverAssociations) {
return null;
}
// get key of most recently issued association
$keys = array_keys($serverAssociations);
sort($keys);
$lastKey = $serverAssociations[array_pop($keys)];
// get association, return null if failed
$association = $this->connection->get($lastKey);
return $association ? $association : null;
} | [
"function",
"getAssociation",
"(",
"$",
"server_url",
",",
"$",
"handle",
"=",
"null",
")",
"{",
"// simple case: handle given",
"if",
"(",
"$",
"handle",
"!==",
"null",
")",
"{",
"// get association, return null if failed",
"$",
"association",
"=",
"$",
"this",
... | Read association from memcached. If no handle given
and multiple associations found, returns latest issued
@param string $server_url
@param null $handle
@return Auth_OpenID_Association|null | [
"Read",
"association",
"from",
"memcached",
".",
"If",
"no",
"handle",
"given",
"and",
"multiple",
"associations",
"found",
"returns",
"latest",
"issued"
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/MemcachedStore.php#L104-L133 |
openid/php-openid | Auth/OpenID/MemcachedStore.php | Auth_OpenID_MemcachedStore.removeAssociation | function removeAssociation($server_url, $handle)
{
// create memcached keys for association itself
// and list of associations for this server
$serverKey = $this->associationServerKey($server_url);
$associationKey = $this->associationKey($server_url,
$handle);
// get list of associations
$serverAssociations = $this->connection->get($serverKey);
// return null if failed or got empty list
if (!$serverAssociations) {
return false;
}
// ensure that given association key exists in list
$serverAssociations = array_flip($serverAssociations);
if (!array_key_exists($associationKey, $serverAssociations)) {
return false;
}
// remove given association key from list
unset($serverAssociations[$associationKey]);
$serverAssociations = array_flip($serverAssociations);
// save updated list
$this->connection->set(
$serverKey,
$serverAssociations,
$this->compress
);
// delete association
return $this->connection->delete($associationKey);
} | php | function removeAssociation($server_url, $handle)
{
// create memcached keys for association itself
// and list of associations for this server
$serverKey = $this->associationServerKey($server_url);
$associationKey = $this->associationKey($server_url,
$handle);
// get list of associations
$serverAssociations = $this->connection->get($serverKey);
// return null if failed or got empty list
if (!$serverAssociations) {
return false;
}
// ensure that given association key exists in list
$serverAssociations = array_flip($serverAssociations);
if (!array_key_exists($associationKey, $serverAssociations)) {
return false;
}
// remove given association key from list
unset($serverAssociations[$associationKey]);
$serverAssociations = array_flip($serverAssociations);
// save updated list
$this->connection->set(
$serverKey,
$serverAssociations,
$this->compress
);
// delete association
return $this->connection->delete($associationKey);
} | [
"function",
"removeAssociation",
"(",
"$",
"server_url",
",",
"$",
"handle",
")",
"{",
"// create memcached keys for association itself",
"// and list of associations for this server",
"$",
"serverKey",
"=",
"$",
"this",
"->",
"associationServerKey",
"(",
"$",
"server_url",... | Immediately delete association from memcache.
@param string $server_url
@param string $handle
@return bool|mixed | [
"Immediately",
"delete",
"association",
"from",
"memcache",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/MemcachedStore.php#L142-L176 |
openid/php-openid | Auth/OpenID/MemcachedStore.php | Auth_OpenID_MemcachedStore.useNonce | function useNonce($server_url, $timestamp, $salt)
{
global $Auth_OpenID_SKEW;
// save one request to memcache when nonce obviously expired
if (abs($timestamp - time()) > $Auth_OpenID_SKEW) {
return false;
}
// returns false when nonce already exists
// otherwise adds nonce
return $this->connection->add(
'openid_nonce_' . sha1($server_url) . '_' . sha1($salt),
1, // any value here
$this->compress,
$Auth_OpenID_SKEW);
} | php | function useNonce($server_url, $timestamp, $salt)
{
global $Auth_OpenID_SKEW;
// save one request to memcache when nonce obviously expired
if (abs($timestamp - time()) > $Auth_OpenID_SKEW) {
return false;
}
// returns false when nonce already exists
// otherwise adds nonce
return $this->connection->add(
'openid_nonce_' . sha1($server_url) . '_' . sha1($salt),
1, // any value here
$this->compress,
$Auth_OpenID_SKEW);
} | [
"function",
"useNonce",
"(",
"$",
"server_url",
",",
"$",
"timestamp",
",",
"$",
"salt",
")",
"{",
"global",
"$",
"Auth_OpenID_SKEW",
";",
"// save one request to memcache when nonce obviously expired",
"if",
"(",
"abs",
"(",
"$",
"timestamp",
"-",
"time",
"(",
... | Create nonce for server and salt, expiring after
$Auth_OpenID_SKEW seconds.
@param string $server_url
@param int $timestamp
@param string $salt
@return bool | [
"Create",
"nonce",
"for",
"server",
"and",
"salt",
"expiring",
"after",
"$Auth_OpenID_SKEW",
"seconds",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/MemcachedStore.php#L187-L203 |
openid/php-openid | Auth/OpenID.php | Auth_OpenID.getQuery | static function getQuery($query_str=null)
{
$data = array();
if ($query_str !== null) {
$data = Auth_OpenID::params_from_string($query_str);
} else if (!array_key_exists('REQUEST_METHOD', $_SERVER)) {
// Do nothing.
} else {
// XXX HACK FIXME HORRIBLE.
//
// POSTing to a URL with query parameters is acceptable, but
// we don't have a clean way to distinguish those parameters
// when we need to do things like return_to verification
// which only want to look at one kind of parameter. We're
// going to emulate the behavior of some other environments
// by defaulting to GET and overwriting with POST if POST
// data is available.
$data = Auth_OpenID::params_from_string($_SERVER['QUERY_STRING']);
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$str = file_get_contents('php://input');
if ($str === false) {
$post = array();
} else {
$post = Auth_OpenID::params_from_string($str);
}
$data = array_merge($data, $post);
}
}
return $data;
} | php | static function getQuery($query_str=null)
{
$data = array();
if ($query_str !== null) {
$data = Auth_OpenID::params_from_string($query_str);
} else if (!array_key_exists('REQUEST_METHOD', $_SERVER)) {
// Do nothing.
} else {
// XXX HACK FIXME HORRIBLE.
//
// POSTing to a URL with query parameters is acceptable, but
// we don't have a clean way to distinguish those parameters
// when we need to do things like return_to verification
// which only want to look at one kind of parameter. We're
// going to emulate the behavior of some other environments
// by defaulting to GET and overwriting with POST if POST
// data is available.
$data = Auth_OpenID::params_from_string($_SERVER['QUERY_STRING']);
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$str = file_get_contents('php://input');
if ($str === false) {
$post = array();
} else {
$post = Auth_OpenID::params_from_string($str);
}
$data = array_merge($data, $post);
}
}
return $data;
} | [
"static",
"function",
"getQuery",
"(",
"$",
"query_str",
"=",
"null",
")",
"{",
"$",
"data",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"query_str",
"!==",
"null",
")",
"{",
"$",
"data",
"=",
"Auth_OpenID",
"::",
"params_from_string",
"(",
"$",
"qu... | Gets the query data from the server environment based on the
request method used. If GET was used, this looks at
$_SERVER['QUERY_STRING'] directly. If POST was used, this
fetches data from the special php://input file stream.
Returns an associative array of the query arguments.
Skips invalid key/value pairs (i.e. keys with no '=value'
portion).
Returns an empty array if neither GET nor POST was used, or if
POST was used but php://input cannot be opened.
See background:
http://lists.openidenabled.com/pipermail/dev/2007-March/000395.html
@access private
@param string|null $query_str
@return array | [
"Gets",
"the",
"query",
"data",
"from",
"the",
"server",
"environment",
"based",
"on",
"the",
"request",
"method",
"used",
".",
"If",
"GET",
"was",
"used",
"this",
"looks",
"at",
"$_SERVER",
"[",
"QUERY_STRING",
"]",
"directly",
".",
"If",
"POST",
"was",
... | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID.php#L149-L183 |
openid/php-openid | Auth/OpenID.php | Auth_OpenID.parse_str | static function parse_str($query)
{
if ($query === null) {
return null;
}
$parts = explode('&', $query);
$new_parts = array();
for ($i = 0; $i < count($parts); $i++) {
$pair = explode('=', $parts[$i]);
if (count($pair) != 2) {
continue;
}
list($key, $value) = $pair;
$new_parts[urldecode($key)] = urldecode($value);
}
return $new_parts;
} | php | static function parse_str($query)
{
if ($query === null) {
return null;
}
$parts = explode('&', $query);
$new_parts = array();
for ($i = 0; $i < count($parts); $i++) {
$pair = explode('=', $parts[$i]);
if (count($pair) != 2) {
continue;
}
list($key, $value) = $pair;
$new_parts[urldecode($key)] = urldecode($value);
}
return $new_parts;
} | [
"static",
"function",
"parse_str",
"(",
"$",
"query",
")",
"{",
"if",
"(",
"$",
"query",
"===",
"null",
")",
"{",
"return",
"null",
";",
"}",
"$",
"parts",
"=",
"explode",
"(",
"'&'",
",",
"$",
"query",
")",
";",
"$",
"new_parts",
"=",
"array",
"... | Replacement for PHP's broken parse_str.
@param string|null $query
@return array|null | [
"Replacement",
"for",
"PHP",
"s",
"broken",
"parse_str",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID.php#L281-L302 |
openid/php-openid | Auth/OpenID.php | Auth_OpenID.httpBuildQuery | static function httpBuildQuery($data)
{
$pairs = array();
foreach ($data as $key => $value) {
if (is_array($value)) {
$pairs[] = urlencode($value[0])."=".urlencode($value[1]);
} else {
$pairs[] = urlencode($key)."=".urlencode($value);
}
}
return implode("&", $pairs);
} | php | static function httpBuildQuery($data)
{
$pairs = array();
foreach ($data as $key => $value) {
if (is_array($value)) {
$pairs[] = urlencode($value[0])."=".urlencode($value[1]);
} else {
$pairs[] = urlencode($key)."=".urlencode($value);
}
}
return implode("&", $pairs);
} | [
"static",
"function",
"httpBuildQuery",
"(",
"$",
"data",
")",
"{",
"$",
"pairs",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
... | Implements the PHP 5 'http_build_query' functionality.
@access private
@param array $data Either an array key/value pairs or an array
of arrays, each of which holding two values: a key and a value,
sequentially.
@return string $result The result of url-encoding the key/value
pairs from $data into a URL query string
(e.g. "username=bob&id=56"). | [
"Implements",
"the",
"PHP",
"5",
"http_build_query",
"functionality",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID.php#L315-L326 |
openid/php-openid | Auth/OpenID.php | Auth_OpenID.appendArgs | static function appendArgs($url, $args)
{
if (count($args) == 0) {
return $url;
}
// Non-empty array; if it is an array of arrays, use
// multisort; otherwise use sort.
if (array_key_exists(0, $args) &&
is_array($args[0])) {
// Do nothing here.
} else {
$keys = array_keys($args);
sort($keys);
$new_args = array();
foreach ($keys as $key) {
$new_args[] = array($key, $args[$key]);
}
$args = $new_args;
}
$sep = '?';
if (strpos($url, '?') !== false) {
$sep = '&';
}
return $url . $sep . Auth_OpenID::httpBuildQuery($args);
} | php | static function appendArgs($url, $args)
{
if (count($args) == 0) {
return $url;
}
// Non-empty array; if it is an array of arrays, use
// multisort; otherwise use sort.
if (array_key_exists(0, $args) &&
is_array($args[0])) {
// Do nothing here.
} else {
$keys = array_keys($args);
sort($keys);
$new_args = array();
foreach ($keys as $key) {
$new_args[] = array($key, $args[$key]);
}
$args = $new_args;
}
$sep = '?';
if (strpos($url, '?') !== false) {
$sep = '&';
}
return $url . $sep . Auth_OpenID::httpBuildQuery($args);
} | [
"static",
"function",
"appendArgs",
"(",
"$",
"url",
",",
"$",
"args",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"args",
")",
"==",
"0",
")",
"{",
"return",
"$",
"url",
";",
"}",
"// Non-empty array; if it is an array of arrays, use",
"// multisort; otherwise us... | "Appends" query arguments onto a URL. The URL may or may not
already have arguments (following a question mark).
@access private
@param string $url A URL, which may or may not already have
arguments.
@param array $args Either an array key/value pairs or an array of
arrays, each of which holding two values: a key and a value,
sequentially. If $args is an ordinary key/value array, the
parameters will be added to the URL in sorted alphabetical order;
if $args is an array of arrays, their order will be preserved.
@return string $url The original URL with the new parameters added. | [
"Appends",
"query",
"arguments",
"onto",
"a",
"URL",
".",
"The",
"URL",
"may",
"or",
"may",
"not",
"already",
"have",
"arguments",
"(",
"following",
"a",
"question",
"mark",
")",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID.php#L343-L370 |
openid/php-openid | Auth/OpenID.php | Auth_OpenID.urlunparse | static function urlunparse($scheme, $host, $port = null, $path = '/',
$query = '', $fragment = '')
{
if (!$scheme) {
$scheme = 'http';
}
if (!$host) {
return false;
}
if (!$path) {
$path = '';
}
$result = $scheme . "://" . $host;
if ($port) {
$result .= ":" . $port;
}
$result .= $path;
if ($query) {
$result .= "?" . $query;
}
if ($fragment) {
$result .= "#" . $fragment;
}
return $result;
} | php | static function urlunparse($scheme, $host, $port = null, $path = '/',
$query = '', $fragment = '')
{
if (!$scheme) {
$scheme = 'http';
}
if (!$host) {
return false;
}
if (!$path) {
$path = '';
}
$result = $scheme . "://" . $host;
if ($port) {
$result .= ":" . $port;
}
$result .= $path;
if ($query) {
$result .= "?" . $query;
}
if ($fragment) {
$result .= "#" . $fragment;
}
return $result;
} | [
"static",
"function",
"urlunparse",
"(",
"$",
"scheme",
",",
"$",
"host",
",",
"$",
"port",
"=",
"null",
",",
"$",
"path",
"=",
"'/'",
",",
"$",
"query",
"=",
"''",
",",
"$",
"fragment",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"$",
"scheme",
")",
... | Implements python's urlunparse, which is not available in PHP.
Given the specified components of a URL, this function rebuilds
and returns the URL.
@access private
@param string $scheme The scheme (e.g. 'http'). Defaults to 'http'.
@param string $host The host. Required.
@param string $port The port.
@param string $path The path.
@param string $query The query.
@param string $fragment The fragment.
@return string $url The URL resulting from assembling the
specified components. | [
"Implements",
"python",
"s",
"urlunparse",
"which",
"is",
"not",
"available",
"in",
"PHP",
".",
"Given",
"the",
"specified",
"components",
"of",
"a",
"URL",
"this",
"function",
"rebuilds",
"and",
"returns",
"the",
"URL",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID.php#L387-L420 |
openid/php-openid | Auth/OpenID/Discover.php | Auth_OpenID_ServiceEndpoint.matchTypes | function matchTypes($type_uris)
{
$result = array();
foreach ($type_uris as $test_uri) {
if ($this->supportsType($test_uri)) {
$result[] = $test_uri;
}
}
return $result;
} | php | function matchTypes($type_uris)
{
$result = array();
foreach ($type_uris as $test_uri) {
if ($this->supportsType($test_uri)) {
$result[] = $test_uri;
}
}
return $result;
} | [
"function",
"matchTypes",
"(",
"$",
"type_uris",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"type_uris",
"as",
"$",
"test_uri",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"supportsType",
"(",
"$",
"test_uri",
")",
")",
... | /*
Query this endpoint to see if it has any of the given type
URIs. This is useful for implementing other endpoint classes
that e.g. need to check for the presence of multiple versions
of a single protocol.
@param $type_uris The URIs that you wish to check
@return all types that are in both in type_uris and
$this->type_uris | [
"/",
"*",
"Query",
"this",
"endpoint",
"to",
"see",
"if",
"it",
"has",
"any",
"of",
"the",
"given",
"type",
"URIs",
".",
"This",
"is",
"useful",
"for",
"implementing",
"other",
"endpoint",
"classes",
"that",
"e",
".",
"g",
".",
"need",
"to",
"check",
... | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/Discover.php#L124-L134 |
openid/php-openid | Auth/OpenID/Discover.php | Auth_OpenID_ServiceEndpoint.consumerFromXRDS | function consumerFromXRDS($uri, $xrds_text)
{
$xrds =& Auth_Yadis_XRDS::parseXRDS($xrds_text);
if ($xrds) {
$yadis_services =
$xrds->services(array('filter_MatchesAnyOpenIDConsumerType'));
return Auth_OpenID_makeOpenIDEndpoints($uri, $yadis_services);
}
return null;
} | php | function consumerFromXRDS($uri, $xrds_text)
{
$xrds =& Auth_Yadis_XRDS::parseXRDS($xrds_text);
if ($xrds) {
$yadis_services =
$xrds->services(array('filter_MatchesAnyOpenIDConsumerType'));
return Auth_OpenID_makeOpenIDEndpoints($uri, $yadis_services);
}
return null;
} | [
"function",
"consumerFromXRDS",
"(",
"$",
"uri",
",",
"$",
"xrds_text",
")",
"{",
"$",
"xrds",
"=",
"&",
"Auth_Yadis_XRDS",
"::",
"parseXRDS",
"(",
"$",
"xrds_text",
")",
";",
"if",
"(",
"$",
"xrds",
")",
"{",
"$",
"yadis_services",
"=",
"$",
"xrds",
... | /*
Parse the given document as XRDS looking for OpenID consumer services.
@return array of Auth_OpenID_ServiceEndpoint or null if the
document cannot be parsed. | [
"/",
"*",
"Parse",
"the",
"given",
"document",
"as",
"XRDS",
"looking",
"for",
"OpenID",
"consumer",
"services",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/Discover.php#L207-L218 |
openid/php-openid | Auth/OpenID/Discover.php | Auth_OpenID_ServiceEndpoint.fromDiscoveryResult | static function fromDiscoveryResult($discoveryResult)
{
if ($discoveryResult->isXRDS()) {
return Auth_OpenID_ServiceEndpoint::fromXRDS(
$discoveryResult->normalized_uri,
$discoveryResult->response_text);
} else {
return Auth_OpenID_ServiceEndpoint::fromHTML(
$discoveryResult->normalized_uri,
$discoveryResult->response_text);
}
} | php | static function fromDiscoveryResult($discoveryResult)
{
if ($discoveryResult->isXRDS()) {
return Auth_OpenID_ServiceEndpoint::fromXRDS(
$discoveryResult->normalized_uri,
$discoveryResult->response_text);
} else {
return Auth_OpenID_ServiceEndpoint::fromHTML(
$discoveryResult->normalized_uri,
$discoveryResult->response_text);
}
} | [
"static",
"function",
"fromDiscoveryResult",
"(",
"$",
"discoveryResult",
")",
"{",
"if",
"(",
"$",
"discoveryResult",
"->",
"isXRDS",
"(",
")",
")",
"{",
"return",
"Auth_OpenID_ServiceEndpoint",
"::",
"fromXRDS",
"(",
"$",
"discoveryResult",
"->",
"normalized_uri... | Create endpoints from a DiscoveryResult.
@param Auth_Yadis_DiscoveryResult $discoveryResult
@return Auth_OpenID_ServiceEndpoint[]|null null if
endpoints cannot be created. | [
"Create",
"endpoints",
"from",
"a",
"DiscoveryResult",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/Discover.php#L246-L257 |
openid/php-openid | Auth/OpenID/Server.php | Auth_OpenID_ServerError.encodeToURL | function encodeToURL()
{
if (!$this->message) {
return null;
}
$msg = $this->toMessage();
return $msg->toURL($this->getReturnTo());
} | php | function encodeToURL()
{
if (!$this->message) {
return null;
}
$msg = $this->toMessage();
return $msg->toURL($this->getReturnTo());
} | [
"function",
"encodeToURL",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"message",
")",
"{",
"return",
"null",
";",
"}",
"$",
"msg",
"=",
"$",
"this",
"->",
"toMessage",
"(",
")",
";",
"return",
"$",
"msg",
"->",
"toURL",
"(",
"$",
"this",
... | Encodes this error's response as a URL suitable for
redirection. If the response has no return_to, another
Auth_OpenID_ServerError is returned. | [
"Encodes",
"this",
"error",
"s",
"response",
"as",
"a",
"URL",
"suitable",
"for",
"redirection",
".",
"If",
"the",
"response",
"has",
"no",
"return_to",
"another",
"Auth_OpenID_ServerError",
"is",
"returned",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/Server.php#L206-L214 |
openid/php-openid | Auth/OpenID/Server.php | Auth_OpenID_ServerError.whichEncoding | function whichEncoding()
{
global $_Auth_OpenID_Request_Modes;
if ($this->hasReturnTo()) {
if ($this->message->isOpenID2() &&
(strlen($this->encodeToURL()) >
Auth_OpenID_OPENID1_URL_LIMIT)) {
return Auth_OpenID_ENCODE_HTML_FORM;
} else {
return Auth_OpenID_ENCODE_URL;
}
}
if (!$this->message) {
return null;
}
$mode = $this->message->getArg(Auth_OpenID_OPENID_NS,
'mode');
if ($mode) {
if (!in_array($mode, $_Auth_OpenID_Request_Modes)) {
return Auth_OpenID_ENCODE_KVFORM;
}
}
return null;
} | php | function whichEncoding()
{
global $_Auth_OpenID_Request_Modes;
if ($this->hasReturnTo()) {
if ($this->message->isOpenID2() &&
(strlen($this->encodeToURL()) >
Auth_OpenID_OPENID1_URL_LIMIT)) {
return Auth_OpenID_ENCODE_HTML_FORM;
} else {
return Auth_OpenID_ENCODE_URL;
}
}
if (!$this->message) {
return null;
}
$mode = $this->message->getArg(Auth_OpenID_OPENID_NS,
'mode');
if ($mode) {
if (!in_array($mode, $_Auth_OpenID_Request_Modes)) {
return Auth_OpenID_ENCODE_KVFORM;
}
}
return null;
} | [
"function",
"whichEncoding",
"(",
")",
"{",
"global",
"$",
"_Auth_OpenID_Request_Modes",
";",
"if",
"(",
"$",
"this",
"->",
"hasReturnTo",
"(",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"message",
"->",
"isOpenID2",
"(",
")",
"&&",
"(",
"strlen",
"(... | Returns one of Auth_OpenID_ENCODE_URL,
Auth_OpenID_ENCODE_KVFORM, or null, depending on the type of
encoding expected for this error's payload. | [
"Returns",
"one",
"of",
"Auth_OpenID_ENCODE_URL",
"Auth_OpenID_ENCODE_KVFORM",
"or",
"null",
"depending",
"on",
"the",
"type",
"of",
"encoding",
"expected",
"for",
"this",
"error",
"s",
"payload",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/Server.php#L267-L294 |
openid/php-openid | Auth/OpenID/Server.php | Auth_OpenID_CheckIDRequest.returnToVerified | function returnToVerified()
{
$fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
return call_user_func_array($this->verifyReturnTo,
array($this->trust_root, $this->return_to, $fetcher));
} | php | function returnToVerified()
{
$fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
return call_user_func_array($this->verifyReturnTo,
array($this->trust_root, $this->return_to, $fetcher));
} | [
"function",
"returnToVerified",
"(",
")",
"{",
"$",
"fetcher",
"=",
"Auth_Yadis_Yadis",
"::",
"getHTTPFetcher",
"(",
")",
";",
"return",
"call_user_func_array",
"(",
"$",
"this",
"->",
"verifyReturnTo",
",",
"array",
"(",
"$",
"this",
"->",
"trust_root",
",",
... | /*
Does the relying party publish the return_to URL for this
response under the realm? It is up to the provider to set a
policy for what kinds of realms should be allowed. This
return_to URL verification reduces vulnerability to data-theft
attacks based on open proxies, corss-site-scripting, or open
redirectors.
This check should only be performed after making sure that the
return_to URL matches the realm.
@return true if the realm publishes a document with the
return_to URL listed, false if not or if discovery fails | [
"/",
"*",
"Does",
"the",
"relying",
"party",
"publish",
"the",
"return_to",
"URL",
"for",
"this",
"response",
"under",
"the",
"realm?",
"It",
"is",
"up",
"to",
"the",
"provider",
"to",
"set",
"a",
"policy",
"for",
"what",
"kinds",
"of",
"realms",
"should... | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/Server.php#L924-L929 |
openid/php-openid | Auth/OpenID/Server.php | Auth_OpenID_CheckIDRequest.answer | function answer($allow, $server_url = null, $identity = null,
$claimed_id = null)
{
if (!$this->return_to) {
return new Auth_OpenID_NoReturnToError();
}
if (!$server_url) {
if ((!$this->message->isOpenID1()) &&
(!$this->server->op_endpoint)) {
return new Auth_OpenID_ServerError(null,
"server should be constructed with op_endpoint to " .
"respond to OpenID 2.0 messages.");
}
$server_url = $this->server->op_endpoint;
}
if ($allow) {
$mode = 'id_res';
} else if ($this->message->isOpenID1()) {
if ($this->immediate) {
$mode = 'id_res';
} else {
$mode = 'cancel';
}
} else {
if ($this->immediate) {
$mode = 'setup_needed';
} else {
$mode = 'cancel';
}
}
if (!$this->trustRootValid()) {
return new Auth_OpenID_UntrustedReturnURL(null,
$this->return_to,
$this->trust_root);
}
$response = new Auth_OpenID_ServerResponse($this);
if ($claimed_id &&
($this->message->isOpenID1())) {
return new Auth_OpenID_ServerError(null,
"claimed_id is new in OpenID 2.0 and not " .
"available for ".$this->namespace);
}
if ($identity && !$claimed_id) {
$claimed_id = $identity;
}
if ($allow) {
$response_claimed_id = '';
if ($this->identity == Auth_OpenID_IDENTIFIER_SELECT) {
if (!$identity) {
return new Auth_OpenID_ServerError(null,
"This request uses IdP-driven identifier selection. " .
"You must supply an identifier in the response.");
}
$response_identity = $identity;
$response_claimed_id = $claimed_id;
} else if ($this->identity) {
if ($identity &&
($this->identity != $identity)) {
$fmt = "Request was for %s, cannot reply with identity %s";
return new Auth_OpenID_ServerError(null,
sprintf($fmt, $this->identity, $identity));
}
$response_identity = $this->identity;
$response_claimed_id = $this->claimed_id;
} else {
if ($identity) {
return new Auth_OpenID_ServerError(null,
"This request specified no identity and " .
"you supplied ".$identity);
}
$response_identity = null;
}
if (($this->message->isOpenID1()) &&
($response_identity === null)) {
return new Auth_OpenID_ServerError(null,
"Request was an OpenID 1 request, so response must " .
"include an identifier.");
}
$response->fields->updateArgs(Auth_OpenID_OPENID_NS,
array('mode' => $mode,
'return_to' => $this->return_to,
'response_nonce' => Auth_OpenID_mkNonce()));
if (!$this->message->isOpenID1()) {
$response->fields->setArg(Auth_OpenID_OPENID_NS,
'op_endpoint', $server_url);
}
if ($response_identity !== null) {
$response->fields->setArg(
Auth_OpenID_OPENID_NS,
'identity',
$response_identity);
if ($this->message->isOpenID2()) {
$response->fields->setArg(
Auth_OpenID_OPENID_NS,
'claimed_id',
$response_claimed_id);
}
}
} else {
$response->fields->setArg(Auth_OpenID_OPENID_NS,
'mode', $mode);
if ($this->immediate) {
if (($this->message->isOpenID1()) &&
(!$server_url)) {
return new Auth_OpenID_ServerError(null,
'setup_url is required for $allow=false \
in OpenID 1.x immediate mode.');
}
$setup_request = new Auth_OpenID_CheckIDRequest(
$this->identity,
$this->return_to,
$this->trust_root,
false,
$this->assoc_handle,
$this->server,
$this->claimed_id);
$setup_request->message = $this->message;
$setup_url = $setup_request->encodeToURL($server_url);
if ($setup_url === null) {
return new Auth_OpenID_NoReturnToError();
}
$response->fields->setArg(Auth_OpenID_OPENID_NS,
'user_setup_url',
$setup_url);
}
}
return $response;
} | php | function answer($allow, $server_url = null, $identity = null,
$claimed_id = null)
{
if (!$this->return_to) {
return new Auth_OpenID_NoReturnToError();
}
if (!$server_url) {
if ((!$this->message->isOpenID1()) &&
(!$this->server->op_endpoint)) {
return new Auth_OpenID_ServerError(null,
"server should be constructed with op_endpoint to " .
"respond to OpenID 2.0 messages.");
}
$server_url = $this->server->op_endpoint;
}
if ($allow) {
$mode = 'id_res';
} else if ($this->message->isOpenID1()) {
if ($this->immediate) {
$mode = 'id_res';
} else {
$mode = 'cancel';
}
} else {
if ($this->immediate) {
$mode = 'setup_needed';
} else {
$mode = 'cancel';
}
}
if (!$this->trustRootValid()) {
return new Auth_OpenID_UntrustedReturnURL(null,
$this->return_to,
$this->trust_root);
}
$response = new Auth_OpenID_ServerResponse($this);
if ($claimed_id &&
($this->message->isOpenID1())) {
return new Auth_OpenID_ServerError(null,
"claimed_id is new in OpenID 2.0 and not " .
"available for ".$this->namespace);
}
if ($identity && !$claimed_id) {
$claimed_id = $identity;
}
if ($allow) {
$response_claimed_id = '';
if ($this->identity == Auth_OpenID_IDENTIFIER_SELECT) {
if (!$identity) {
return new Auth_OpenID_ServerError(null,
"This request uses IdP-driven identifier selection. " .
"You must supply an identifier in the response.");
}
$response_identity = $identity;
$response_claimed_id = $claimed_id;
} else if ($this->identity) {
if ($identity &&
($this->identity != $identity)) {
$fmt = "Request was for %s, cannot reply with identity %s";
return new Auth_OpenID_ServerError(null,
sprintf($fmt, $this->identity, $identity));
}
$response_identity = $this->identity;
$response_claimed_id = $this->claimed_id;
} else {
if ($identity) {
return new Auth_OpenID_ServerError(null,
"This request specified no identity and " .
"you supplied ".$identity);
}
$response_identity = null;
}
if (($this->message->isOpenID1()) &&
($response_identity === null)) {
return new Auth_OpenID_ServerError(null,
"Request was an OpenID 1 request, so response must " .
"include an identifier.");
}
$response->fields->updateArgs(Auth_OpenID_OPENID_NS,
array('mode' => $mode,
'return_to' => $this->return_to,
'response_nonce' => Auth_OpenID_mkNonce()));
if (!$this->message->isOpenID1()) {
$response->fields->setArg(Auth_OpenID_OPENID_NS,
'op_endpoint', $server_url);
}
if ($response_identity !== null) {
$response->fields->setArg(
Auth_OpenID_OPENID_NS,
'identity',
$response_identity);
if ($this->message->isOpenID2()) {
$response->fields->setArg(
Auth_OpenID_OPENID_NS,
'claimed_id',
$response_claimed_id);
}
}
} else {
$response->fields->setArg(Auth_OpenID_OPENID_NS,
'mode', $mode);
if ($this->immediate) {
if (($this->message->isOpenID1()) &&
(!$server_url)) {
return new Auth_OpenID_ServerError(null,
'setup_url is required for $allow=false \
in OpenID 1.x immediate mode.');
}
$setup_request = new Auth_OpenID_CheckIDRequest(
$this->identity,
$this->return_to,
$this->trust_root,
false,
$this->assoc_handle,
$this->server,
$this->claimed_id);
$setup_request->message = $this->message;
$setup_url = $setup_request->encodeToURL($server_url);
if ($setup_url === null) {
return new Auth_OpenID_NoReturnToError();
}
$response->fields->setArg(Auth_OpenID_OPENID_NS,
'user_setup_url',
$setup_url);
}
}
return $response;
} | [
"function",
"answer",
"(",
"$",
"allow",
",",
"$",
"server_url",
"=",
"null",
",",
"$",
"identity",
"=",
"null",
",",
"$",
"claimed_id",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"return_to",
")",
"{",
"return",
"new",
"Auth_OpenID_No... | Respond to this request. Return either an
{@link Auth_OpenID_ServerResponse} or
{@link Auth_OpenID_ServerError}.
@param bool $allow Allow this user to claim this identity, and
allow the consumer to have this information?
@param string $server_url DEPRECATED. Passing $op_endpoint to
the {@link Auth_OpenID_Server} constructor makes this optional.
When an OpenID 1.x immediate mode request does not succeed, it
gets back a URL where the request may be carried out in a
not-so-immediate fashion. Pass my URL in here (the fully
qualified address of this server's endpoint, i.e.
http://example.com/server), and I will use it as a base for the
URL for a new request.
Optional for requests where {@link $immediate} is false or
$allow is true.
@param string $identity The OP-local identifier to answer with.
Only for use when the relying party requested identifier
selection.
@param string $claimed_id The claimed identifier to answer
with, for use with identifier selection in the case where the
claimed identifier and the OP-local identifier differ,
i.e. when the claimed_id uses delegation.
If $identity is provided but this is not, $claimed_id will
default to the value of $identity. When answering requests
that did not ask for identifier selection, the response
$claimed_id will default to that of the request.
This parameter is new in OpenID 2.0.
@return mixed | [
"Respond",
"to",
"this",
"request",
".",
"Return",
"either",
"an",
"{",
"@link",
"Auth_OpenID_ServerResponse",
"}",
"or",
"{",
"@link",
"Auth_OpenID_ServerError",
"}",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/Server.php#L1081-L1231 |
openid/php-openid | Auth/OpenID/Server.php | Auth_OpenID_ServerResponse.toFormMarkup | function toFormMarkup($form_tag_attrs=null)
{
return $this->fields->toFormMarkup($this->request->return_to,
$form_tag_attrs);
} | php | function toFormMarkup($form_tag_attrs=null)
{
return $this->fields->toFormMarkup($this->request->return_to,
$form_tag_attrs);
} | [
"function",
"toFormMarkup",
"(",
"$",
"form_tag_attrs",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"fields",
"->",
"toFormMarkup",
"(",
"$",
"this",
"->",
"request",
"->",
"return_to",
",",
"$",
"form_tag_attrs",
")",
";",
"}"
] | /*
Returns the form markup for this response.
@return str | [
"/",
"*",
"Returns",
"the",
"form",
"markup",
"for",
"this",
"response",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/Server.php#L1330-L1334 |
openid/php-openid | Auth/OpenID/Server.php | Auth_OpenID_Signatory.verify | function verify($assoc_handle, $message)
{
$assoc = $this->getAssociation($assoc_handle, true);
if (!$assoc) {
// oidutil.log("failed to get assoc with handle %r to verify sig %r"
// % (assoc_handle, sig))
return false;
}
return $assoc->checkMessageSignature($message);
} | php | function verify($assoc_handle, $message)
{
$assoc = $this->getAssociation($assoc_handle, true);
if (!$assoc) {
// oidutil.log("failed to get assoc with handle %r to verify sig %r"
// % (assoc_handle, sig))
return false;
}
return $assoc->checkMessageSignature($message);
} | [
"function",
"verify",
"(",
"$",
"assoc_handle",
",",
"$",
"message",
")",
"{",
"$",
"assoc",
"=",
"$",
"this",
"->",
"getAssociation",
"(",
"$",
"assoc_handle",
",",
"true",
")",
";",
"if",
"(",
"!",
"$",
"assoc",
")",
"{",
"// oidutil.log(\"failed to ge... | Verify, using a given association handle, a signature with
signed key-value pairs from an HTTP request.
@param string $assoc_handle
@param Auth_OpenID_Message $message
@return bool | [
"Verify",
"using",
"a",
"given",
"association",
"handle",
"a",
"signature",
"with",
"signed",
"key",
"-",
"value",
"pairs",
"from",
"an",
"HTTP",
"request",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/Server.php#L1451-L1461 |
openid/php-openid | Auth/OpenID/Server.php | Auth_OpenID_Signatory.sign | function sign($response)
{
$signed_response = $response;
/** @var Auth_OpenID_CheckIDRequest $request */
$request = $response->request;
$assoc_handle = $request->assoc_handle;
if ($assoc_handle) {
// normal mode
$assoc = $this->getAssociation($assoc_handle, false, false);
if (!$assoc || ($assoc->getExpiresIn() <= 0)) {
// fall back to dumb mode
$signed_response->fields->setArg(Auth_OpenID_OPENID_NS,
'invalidate_handle', $assoc_handle);
$assoc_type = ($assoc ? $assoc->assoc_type : 'HMAC-SHA1');
if ($assoc && ($assoc->getExpiresIn() <= 0)) {
$this->invalidate($assoc_handle, false);
}
$assoc = $this->createAssociation(true, $assoc_type);
}
} else {
// dumb mode.
$assoc = $this->createAssociation(true);
}
$signed_response->fields = $assoc->signMessage(
$signed_response->fields);
return $signed_response;
} | php | function sign($response)
{
$signed_response = $response;
/** @var Auth_OpenID_CheckIDRequest $request */
$request = $response->request;
$assoc_handle = $request->assoc_handle;
if ($assoc_handle) {
// normal mode
$assoc = $this->getAssociation($assoc_handle, false, false);
if (!$assoc || ($assoc->getExpiresIn() <= 0)) {
// fall back to dumb mode
$signed_response->fields->setArg(Auth_OpenID_OPENID_NS,
'invalidate_handle', $assoc_handle);
$assoc_type = ($assoc ? $assoc->assoc_type : 'HMAC-SHA1');
if ($assoc && ($assoc->getExpiresIn() <= 0)) {
$this->invalidate($assoc_handle, false);
}
$assoc = $this->createAssociation(true, $assoc_type);
}
} else {
// dumb mode.
$assoc = $this->createAssociation(true);
}
$signed_response->fields = $assoc->signMessage(
$signed_response->fields);
return $signed_response;
} | [
"function",
"sign",
"(",
"$",
"response",
")",
"{",
"$",
"signed_response",
"=",
"$",
"response",
";",
"/** @var Auth_OpenID_CheckIDRequest $request */",
"$",
"request",
"=",
"$",
"response",
"->",
"request",
";",
"$",
"assoc_handle",
"=",
"$",
"request",
"->",
... | Given a response, sign the fields in the response's 'signed'
list, and insert the signature into the response.
@param Auth_OpenID_ServerResponse $response
@return mixed | [
"Given",
"a",
"response",
"sign",
"the",
"fields",
"in",
"the",
"response",
"s",
"signed",
"list",
"and",
"insert",
"the",
"signature",
"into",
"the",
"response",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/Server.php#L1470-L1500 |
openid/php-openid | Auth/OpenID/Server.php | Auth_OpenID_Signatory.createAssociation | function createAssociation($dumb = true, $assoc_type = 'HMAC-SHA1')
{
$secret = Auth_OpenID_CryptUtil::getBytes(
Auth_OpenID_getSecretSize($assoc_type));
$uniq = base64_encode(Auth_OpenID_CryptUtil::getBytes(4));
$handle = sprintf('{%s}{%x}{%s}', $assoc_type, intval(time()), $uniq);
$assoc = Auth_OpenID_Association::fromExpiresIn(
$this->SECRET_LIFETIME, $handle, $secret, $assoc_type);
if ($dumb) {
$key = $this->dumb_key;
} else {
$key = $this->normal_key;
}
$this->store->storeAssociation($key, $assoc);
return $assoc;
} | php | function createAssociation($dumb = true, $assoc_type = 'HMAC-SHA1')
{
$secret = Auth_OpenID_CryptUtil::getBytes(
Auth_OpenID_getSecretSize($assoc_type));
$uniq = base64_encode(Auth_OpenID_CryptUtil::getBytes(4));
$handle = sprintf('{%s}{%x}{%s}', $assoc_type, intval(time()), $uniq);
$assoc = Auth_OpenID_Association::fromExpiresIn(
$this->SECRET_LIFETIME, $handle, $secret, $assoc_type);
if ($dumb) {
$key = $this->dumb_key;
} else {
$key = $this->normal_key;
}
$this->store->storeAssociation($key, $assoc);
return $assoc;
} | [
"function",
"createAssociation",
"(",
"$",
"dumb",
"=",
"true",
",",
"$",
"assoc_type",
"=",
"'HMAC-SHA1'",
")",
"{",
"$",
"secret",
"=",
"Auth_OpenID_CryptUtil",
"::",
"getBytes",
"(",
"Auth_OpenID_getSecretSize",
"(",
"$",
"assoc_type",
")",
")",
";",
"$",
... | Make a new association.
@param bool $dumb
@param string $assoc_type
@return Auth_OpenID_Association | [
"Make",
"a",
"new",
"association",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/Server.php#L1509-L1528 |
openid/php-openid | Auth/OpenID/Server.php | Auth_OpenID_Signatory.getAssociation | function getAssociation($assoc_handle, $dumb, $check_expiration=true)
{
if ($assoc_handle === null) {
return new Auth_OpenID_ServerError(null,
"assoc_handle must not be null");
}
if ($dumb) {
$key = $this->dumb_key;
} else {
$key = $this->normal_key;
}
$assoc = $this->store->getAssociation($key, $assoc_handle);
if (($assoc !== null) && ($assoc->getExpiresIn() <= 0)) {
if ($check_expiration) {
$this->store->removeAssociation($key, $assoc_handle);
$assoc = null;
}
}
return $assoc;
} | php | function getAssociation($assoc_handle, $dumb, $check_expiration=true)
{
if ($assoc_handle === null) {
return new Auth_OpenID_ServerError(null,
"assoc_handle must not be null");
}
if ($dumb) {
$key = $this->dumb_key;
} else {
$key = $this->normal_key;
}
$assoc = $this->store->getAssociation($key, $assoc_handle);
if (($assoc !== null) && ($assoc->getExpiresIn() <= 0)) {
if ($check_expiration) {
$this->store->removeAssociation($key, $assoc_handle);
$assoc = null;
}
}
return $assoc;
} | [
"function",
"getAssociation",
"(",
"$",
"assoc_handle",
",",
"$",
"dumb",
",",
"$",
"check_expiration",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"assoc_handle",
"===",
"null",
")",
"{",
"return",
"new",
"Auth_OpenID_ServerError",
"(",
"null",
",",
"\"assoc_han... | Given an association handle, get the association from the
store, or return a ServerError or null if something goes wrong.
@param string $assoc_handle
@param bool $dumb
@param bool $check_expiration
@return Auth_OpenID_Association|Auth_OpenID_ServerError|null | [
"Given",
"an",
"association",
"handle",
"get",
"the",
"association",
"from",
"the",
"store",
"or",
"return",
"a",
"ServerError",
"or",
"null",
"if",
"something",
"goes",
"wrong",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/Server.php#L1539-L1562 |
openid/php-openid | Auth/OpenID/Server.php | Auth_OpenID_Signatory.invalidate | function invalidate($assoc_handle, $dumb)
{
if ($dumb) {
$key = $this->dumb_key;
} else {
$key = $this->normal_key;
}
$this->store->removeAssociation($key, $assoc_handle);
} | php | function invalidate($assoc_handle, $dumb)
{
if ($dumb) {
$key = $this->dumb_key;
} else {
$key = $this->normal_key;
}
$this->store->removeAssociation($key, $assoc_handle);
} | [
"function",
"invalidate",
"(",
"$",
"assoc_handle",
",",
"$",
"dumb",
")",
"{",
"if",
"(",
"$",
"dumb",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"dumb_key",
";",
"}",
"else",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"normal_key",
";",
"}",
... | Invalidate a given association handle.
@param string $assoc_handle
@param bool $dumb | [
"Invalidate",
"a",
"given",
"association",
"handle",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/Server.php#L1570-L1578 |
openid/php-openid | Auth/OpenID/Server.php | Auth_OpenID_Encoder.encode | function encode($response)
{
$cls = $this->responseFactory;
$encode_as = $response->whichEncoding();
if ($encode_as == Auth_OpenID_ENCODE_KVFORM) {
$wr = new $cls(null, null, $response->encodeToKVForm());
if (is_a($response, 'Auth_OpenID_ServerError')) {
$wr->code = AUTH_OPENID_HTTP_ERROR;
}
} else if ($encode_as == Auth_OpenID_ENCODE_URL) {
$location = $response->encodeToURL();
$wr = new $cls(AUTH_OPENID_HTTP_REDIRECT,
array('location' => $location));
} else if ($encode_as == Auth_OpenID_ENCODE_HTML_FORM) {
$wr = new $cls(AUTH_OPENID_HTTP_OK, array(),
$response->toHTML());
} else {
return new Auth_OpenID_EncodingError($response);
}
/* Allow the response to carry a custom error code (ex: for Association errors) */
if(isset($response->code)) {
$wr->code = $response->code;
}
return $wr;
} | php | function encode($response)
{
$cls = $this->responseFactory;
$encode_as = $response->whichEncoding();
if ($encode_as == Auth_OpenID_ENCODE_KVFORM) {
$wr = new $cls(null, null, $response->encodeToKVForm());
if (is_a($response, 'Auth_OpenID_ServerError')) {
$wr->code = AUTH_OPENID_HTTP_ERROR;
}
} else if ($encode_as == Auth_OpenID_ENCODE_URL) {
$location = $response->encodeToURL();
$wr = new $cls(AUTH_OPENID_HTTP_REDIRECT,
array('location' => $location));
} else if ($encode_as == Auth_OpenID_ENCODE_HTML_FORM) {
$wr = new $cls(AUTH_OPENID_HTTP_OK, array(),
$response->toHTML());
} else {
return new Auth_OpenID_EncodingError($response);
}
/* Allow the response to carry a custom error code (ex: for Association errors) */
if(isset($response->code)) {
$wr->code = $response->code;
}
return $wr;
} | [
"function",
"encode",
"(",
"$",
"response",
")",
"{",
"$",
"cls",
"=",
"$",
"this",
"->",
"responseFactory",
";",
"$",
"encode_as",
"=",
"$",
"response",
"->",
"whichEncoding",
"(",
")",
";",
"if",
"(",
"$",
"encode_as",
"==",
"Auth_OpenID_ENCODE_KVFORM",
... | Encode an {@link Auth_OpenID_ServerResponse} and return an
{@link Auth_OpenID_WebResponse}.
@param Auth_OpenID_ServerResponse $response
@return Auth_OpenID_EncodingError | [
"Encode",
"an",
"{",
"@link",
"Auth_OpenID_ServerResponse",
"}",
"and",
"return",
"an",
"{",
"@link",
"Auth_OpenID_WebResponse",
"}",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/Server.php#L1598-L1623 |
openid/php-openid | Auth/OpenID/Server.php | Auth_OpenID_SigningEncoder.encode | function encode($response)
{
// the isinstance is a bit of a kludge... it means there isn't
// really an adapter to make the interfaces quite match.
if (!is_a($response, 'Auth_OpenID_ServerError') &&
$response->needsSigning()) {
if (!$this->signatory) {
return new Auth_OpenID_ServerError(null,
"Must have a store to sign request");
}
if ($response->fields->hasKey(Auth_OpenID_OPENID_NS, 'sig')) {
return new Auth_OpenID_AlreadySigned($response);
}
$response = $this->signatory->sign($response);
}
return parent::encode($response);
} | php | function encode($response)
{
// the isinstance is a bit of a kludge... it means there isn't
// really an adapter to make the interfaces quite match.
if (!is_a($response, 'Auth_OpenID_ServerError') &&
$response->needsSigning()) {
if (!$this->signatory) {
return new Auth_OpenID_ServerError(null,
"Must have a store to sign request");
}
if ($response->fields->hasKey(Auth_OpenID_OPENID_NS, 'sig')) {
return new Auth_OpenID_AlreadySigned($response);
}
$response = $this->signatory->sign($response);
}
return parent::encode($response);
} | [
"function",
"encode",
"(",
"$",
"response",
")",
"{",
"// the isinstance is a bit of a kludge... it means there isn't",
"// really an adapter to make the interfaces quite match.",
"if",
"(",
"!",
"is_a",
"(",
"$",
"response",
",",
"'Auth_OpenID_ServerError'",
")",
"&&",
"$",
... | Sign an {@link Auth_OpenID_ServerResponse} and return an
{@link Auth_OpenID_WebResponse}.
@param Auth_OpenID_ServerResponse $response
@return Auth_OpenID_AlreadySigned|Auth_OpenID_EncodingError|Auth_OpenID_ServerError | [
"Sign",
"an",
"{",
"@link",
"Auth_OpenID_ServerResponse",
"}",
"and",
"return",
"an",
"{",
"@link",
"Auth_OpenID_WebResponse",
"}",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/Server.php#L1653-L1672 |
openid/php-openid | Auth/OpenID/Server.php | Auth_OpenID_Decoder.decode | function decode($query)
{
if (!$query) {
return null;
}
$message = Auth_OpenID_Message::fromPostArgs($query);
if ($message === null) {
/*
* It's useful to have a Message attached to a
* ProtocolError, so we override the bad ns value to build
* a Message out of it. Kinda kludgy, since it's made of
* lies, but the parts that aren't lies are more useful
* than a 'None'.
*/
$old_ns = $query['openid.ns'];
$query['openid.ns'] = Auth_OpenID_OPENID2_NS;
$message = Auth_OpenID_Message::fromPostArgs($query);
return new Auth_OpenID_ServerError(
$message,
sprintf("Invalid OpenID namespace URI: %s", $old_ns));
}
$mode = $message->getArg(Auth_OpenID_OPENID_NS, 'mode');
if (!$mode) {
return new Auth_OpenID_ServerError($message,
"No mode value in message");
}
if (Auth_OpenID::isFailure($mode)) {
return new Auth_OpenID_ServerError($message,
$mode->message);
}
$handlerCls = Auth_OpenID::arrayGet($this->handlers, $mode,
$this->defaultDecoder($message));
if (!is_a($handlerCls, 'Auth_OpenID_ServerError')) {
return call_user_func_array(array($handlerCls, 'fromMessage'),
array($message, $this->server));
} else {
return $handlerCls;
}
} | php | function decode($query)
{
if (!$query) {
return null;
}
$message = Auth_OpenID_Message::fromPostArgs($query);
if ($message === null) {
/*
* It's useful to have a Message attached to a
* ProtocolError, so we override the bad ns value to build
* a Message out of it. Kinda kludgy, since it's made of
* lies, but the parts that aren't lies are more useful
* than a 'None'.
*/
$old_ns = $query['openid.ns'];
$query['openid.ns'] = Auth_OpenID_OPENID2_NS;
$message = Auth_OpenID_Message::fromPostArgs($query);
return new Auth_OpenID_ServerError(
$message,
sprintf("Invalid OpenID namespace URI: %s", $old_ns));
}
$mode = $message->getArg(Auth_OpenID_OPENID_NS, 'mode');
if (!$mode) {
return new Auth_OpenID_ServerError($message,
"No mode value in message");
}
if (Auth_OpenID::isFailure($mode)) {
return new Auth_OpenID_ServerError($message,
$mode->message);
}
$handlerCls = Auth_OpenID::arrayGet($this->handlers, $mode,
$this->defaultDecoder($message));
if (!is_a($handlerCls, 'Auth_OpenID_ServerError')) {
return call_user_func_array(array($handlerCls, 'fromMessage'),
array($message, $this->server));
} else {
return $handlerCls;
}
} | [
"function",
"decode",
"(",
"$",
"query",
")",
"{",
"if",
"(",
"!",
"$",
"query",
")",
"{",
"return",
"null",
";",
"}",
"$",
"message",
"=",
"Auth_OpenID_Message",
"::",
"fromPostArgs",
"(",
"$",
"query",
")",
";",
"if",
"(",
"$",
"message",
"===",
... | Given an HTTP query in an array (key-value pairs), decode it
into an Auth_OpenID_Request object.
@param array $query
@return Auth_OpenID_ServerError|mixed | [
"Given",
"an",
"HTTP",
"query",
"in",
"an",
"array",
"(",
"key",
"-",
"value",
"pairs",
")",
"decode",
"it",
"into",
"an",
"Auth_OpenID_Request",
"object",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/Server.php#L1709-L1754 |
openid/php-openid | Auth/OpenID/Server.php | Auth_OpenID_Server.handleRequest | function handleRequest($request)
{
if (method_exists($this, "openid_" . $request->mode)) {
$handler = array($this, "openid_" . $request->mode);
return call_user_func_array($handler, array($request));
}
return null;
} | php | function handleRequest($request)
{
if (method_exists($this, "openid_" . $request->mode)) {
$handler = array($this, "openid_" . $request->mode);
return call_user_func_array($handler, array($request));
}
return null;
} | [
"function",
"handleRequest",
"(",
"$",
"request",
")",
"{",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"\"openid_\"",
".",
"$",
"request",
"->",
"mode",
")",
")",
"{",
"$",
"handler",
"=",
"array",
"(",
"$",
"this",
",",
"\"openid_\"",
".",
"... | Handle a request. Given an {@link Auth_OpenID_Request} object,
call the appropriate {@link Auth_OpenID_Server} method to
process the request and generate a response.
@param Auth_OpenID_Request $request An {@link Auth_OpenID_Request}
returned by {@link Auth_OpenID_Server::decodeRequest()}.
@return Auth_OpenID_ServerResponse $response A response object
capable of generating a user-agent reply. | [
"Handle",
"a",
"request",
".",
"Given",
"an",
"{",
"@link",
"Auth_OpenID_Request",
"}",
"object",
"call",
"the",
"appropriate",
"{",
"@link",
"Auth_OpenID_Server",
"}",
"method",
"to",
"process",
"the",
"request",
"and",
"generate",
"a",
"response",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/Server.php#L1909-L1916 |
openid/php-openid | Auth/OpenID/Server.php | Auth_OpenID_Server.openid_associate | function openid_associate($request)
{
$assoc_type = $request->assoc_type;
$session_type = $request->session->session_type;
if ($this->negotiator->isAllowed($assoc_type, $session_type)) {
$assoc = $this->signatory->createAssociation(false,
$assoc_type);
return $request->answer($assoc);
} else {
$message = sprintf('Association type %s is not supported with '.
'session type %s', $assoc_type, $session_type);
list($preferred_assoc_type, $preferred_session_type) =
$this->negotiator->getAllowedType();
return $request->answerUnsupported($message,
$preferred_assoc_type,
$preferred_session_type);
}
} | php | function openid_associate($request)
{
$assoc_type = $request->assoc_type;
$session_type = $request->session->session_type;
if ($this->negotiator->isAllowed($assoc_type, $session_type)) {
$assoc = $this->signatory->createAssociation(false,
$assoc_type);
return $request->answer($assoc);
} else {
$message = sprintf('Association type %s is not supported with '.
'session type %s', $assoc_type, $session_type);
list($preferred_assoc_type, $preferred_session_type) =
$this->negotiator->getAllowedType();
return $request->answerUnsupported($message,
$preferred_assoc_type,
$preferred_session_type);
}
} | [
"function",
"openid_associate",
"(",
"$",
"request",
")",
"{",
"$",
"assoc_type",
"=",
"$",
"request",
"->",
"assoc_type",
";",
"$",
"session_type",
"=",
"$",
"request",
"->",
"session",
"->",
"session_type",
";",
"if",
"(",
"$",
"this",
"->",
"negotiator"... | The callback for 'associate' messages.
@param Auth_OpenID_AssociateRequest $request
@return mixed | [
"The",
"callback",
"for",
"associate",
"messages",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/Server.php#L1935-L1952 |
openid/php-openid | Auth/OpenID/Server.php | Auth_OpenID_Server.decodeRequest | function decodeRequest($query=null)
{
if ($query === null) {
$query = Auth_OpenID::getQuery();
}
return $this->decoder->decode($query);
} | php | function decodeRequest($query=null)
{
if ($query === null) {
$query = Auth_OpenID::getQuery();
}
return $this->decoder->decode($query);
} | [
"function",
"decodeRequest",
"(",
"$",
"query",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"query",
"===",
"null",
")",
"{",
"$",
"query",
"=",
"Auth_OpenID",
"::",
"getQuery",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"decoder",
"->",
"decode",
... | Decodes a query args array into the appropriate
{@link Auth_OpenID_Request} object.
@param array|null $query
@return Auth_OpenID_ServerError|mixed | [
"Decodes",
"a",
"query",
"args",
"array",
"into",
"the",
"appropriate",
"{",
"@link",
"Auth_OpenID_Request",
"}",
"object",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/Server.php#L1973-L1980 |
openid/php-openid | Auth/OpenID/PAPE.php | Auth_OpenID_PAPE_Request.getExtensionArgs | function getExtensionArgs($request = null)
{
$ns_args = array(
'preferred_auth_policies' =>
implode(' ', $this->preferred_auth_policies)
);
if ($this->max_auth_age !== null) {
$ns_args['max_auth_age'] = strval($this->max_auth_age);
}
return $ns_args;
} | php | function getExtensionArgs($request = null)
{
$ns_args = array(
'preferred_auth_policies' =>
implode(' ', $this->preferred_auth_policies)
);
if ($this->max_auth_age !== null) {
$ns_args['max_auth_age'] = strval($this->max_auth_age);
}
return $ns_args;
} | [
"function",
"getExtensionArgs",
"(",
"$",
"request",
"=",
"null",
")",
"{",
"$",
"ns_args",
"=",
"array",
"(",
"'preferred_auth_policies'",
"=>",
"implode",
"(",
"' '",
",",
"$",
"this",
"->",
"preferred_auth_policies",
")",
")",
";",
"if",
"(",
"$",
"this... | Get the string arguments that should be added to an OpenID
message for this extension.
@param Auth_OpenID_Request|null $request
@return null | [
"Get",
"the",
"string",
"arguments",
"that",
"should",
"be",
"added",
"to",
"an",
"OpenID",
"message",
"for",
"this",
"extension",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/PAPE.php#L79-L91 |
openid/php-openid | Auth/OpenID/PAPE.php | Auth_OpenID_PAPE_Request.fromOpenIDRequest | static function fromOpenIDRequest($request)
{
$obj = new Auth_OpenID_PAPE_Request();
$args = $request->message->getArgs(Auth_OpenID_PAPE_NS_URI);
if ($args === null || $args === array()) {
return null;
}
$obj->parseExtensionArgs($args);
return $obj;
} | php | static function fromOpenIDRequest($request)
{
$obj = new Auth_OpenID_PAPE_Request();
$args = $request->message->getArgs(Auth_OpenID_PAPE_NS_URI);
if ($args === null || $args === array()) {
return null;
}
$obj->parseExtensionArgs($args);
return $obj;
} | [
"static",
"function",
"fromOpenIDRequest",
"(",
"$",
"request",
")",
"{",
"$",
"obj",
"=",
"new",
"Auth_OpenID_PAPE_Request",
"(",
")",
";",
"$",
"args",
"=",
"$",
"request",
"->",
"message",
"->",
"getArgs",
"(",
"Auth_OpenID_PAPE_NS_URI",
")",
";",
"if",
... | Instantiate a Request object from the arguments in a checkid_*
OpenID message
@param Auth_OpenID_Request $request
@return Auth_OpenID_PAPE_Request|null | [
"Instantiate",
"a",
"Request",
"object",
"from",
"the",
"arguments",
"in",
"a",
"checkid_",
"*",
"OpenID",
"message"
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/PAPE.php#L100-L111 |
openid/php-openid | Auth/OpenID/PAPE.php | Auth_OpenID_PAPE_Request.parseExtensionArgs | function parseExtensionArgs($args)
{
// preferred_auth_policies is a space-separated list of policy
// URIs
$this->preferred_auth_policies = array();
$policies_str = Auth_OpenID::arrayGet($args, 'preferred_auth_policies');
if ($policies_str) {
foreach (explode(' ', $policies_str) as $uri) {
if (!in_array($uri, $this->preferred_auth_policies)) {
$this->preferred_auth_policies[] = $uri;
}
}
}
// max_auth_age is base-10 integer number of seconds
$max_auth_age_str = Auth_OpenID::arrayGet($args, 'max_auth_age');
if ($max_auth_age_str) {
$this->max_auth_age = Auth_OpenID::intval($max_auth_age_str);
} else {
$this->max_auth_age = null;
}
} | php | function parseExtensionArgs($args)
{
// preferred_auth_policies is a space-separated list of policy
// URIs
$this->preferred_auth_policies = array();
$policies_str = Auth_OpenID::arrayGet($args, 'preferred_auth_policies');
if ($policies_str) {
foreach (explode(' ', $policies_str) as $uri) {
if (!in_array($uri, $this->preferred_auth_policies)) {
$this->preferred_auth_policies[] = $uri;
}
}
}
// max_auth_age is base-10 integer number of seconds
$max_auth_age_str = Auth_OpenID::arrayGet($args, 'max_auth_age');
if ($max_auth_age_str) {
$this->max_auth_age = Auth_OpenID::intval($max_auth_age_str);
} else {
$this->max_auth_age = null;
}
} | [
"function",
"parseExtensionArgs",
"(",
"$",
"args",
")",
"{",
"// preferred_auth_policies is a space-separated list of policy",
"// URIs",
"$",
"this",
"->",
"preferred_auth_policies",
"=",
"array",
"(",
")",
";",
"$",
"policies_str",
"=",
"Auth_OpenID",
"::",
"arrayGet... | Set the state of this request to be that expressed in these
PAPE arguments
@param args: The PAPE arguments without a namespace | [
"Set",
"the",
"state",
"of",
"this",
"request",
"to",
"be",
"that",
"expressed",
"in",
"these",
"PAPE",
"arguments"
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/PAPE.php#L119-L141 |
openid/php-openid | Auth/OpenID/PAPE.php | Auth_OpenID_PAPE_Request.preferredTypes | function preferredTypes($supported_types)
{
$result = array();
foreach ($supported_types as $st) {
if (in_array($st, $this->preferred_auth_policies)) {
$result[] = $st;
}
}
return $result;
} | php | function preferredTypes($supported_types)
{
$result = array();
foreach ($supported_types as $st) {
if (in_array($st, $this->preferred_auth_policies)) {
$result[] = $st;
}
}
return $result;
} | [
"function",
"preferredTypes",
"(",
"$",
"supported_types",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"supported_types",
"as",
"$",
"st",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"st",
",",
"$",
"this",
"->",
"prefer... | Given a list of authentication policy URIs that a provider
supports, this method returns the subsequence of those types
that are preferred by the relying party.
@param supported_types: A sequence of authentication policy
type URIs that are supported by a provider
@return array The sub-sequence of the supported types that are
preferred by the relying party. This list will be ordered in
the order that the types appear in the supported_types
sequence, and may be empty if the provider does not prefer any
of the supported authentication types. | [
"Given",
"a",
"list",
"of",
"authentication",
"policy",
"URIs",
"that",
"a",
"provider",
"supports",
"this",
"method",
"returns",
"the",
"subsequence",
"of",
"those",
"types",
"that",
"are",
"preferred",
"by",
"the",
"relying",
"party",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/PAPE.php#L157-L167 |
openid/php-openid | Auth/OpenID/PAPE.php | Auth_OpenID_PAPE_Response.fromSuccessResponse | static function fromSuccessResponse($success_response)
{
$obj = new Auth_OpenID_PAPE_Response();
// PAPE requires that the args be signed.
$args = $success_response->getSignedNS(Auth_OpenID_PAPE_NS_URI);
if ($args === null || $args === array()) {
return null;
}
$result = $obj->parseExtensionArgs($args);
if ($result === false) {
return null;
} else {
return $obj;
}
} | php | static function fromSuccessResponse($success_response)
{
$obj = new Auth_OpenID_PAPE_Response();
// PAPE requires that the args be signed.
$args = $success_response->getSignedNS(Auth_OpenID_PAPE_NS_URI);
if ($args === null || $args === array()) {
return null;
}
$result = $obj->parseExtensionArgs($args);
if ($result === false) {
return null;
} else {
return $obj;
}
} | [
"static",
"function",
"fromSuccessResponse",
"(",
"$",
"success_response",
")",
"{",
"$",
"obj",
"=",
"new",
"Auth_OpenID_PAPE_Response",
"(",
")",
";",
"// PAPE requires that the args be signed.",
"$",
"args",
"=",
"$",
"success_response",
"->",
"getSignedNS",
"(",
... | Create an Auth_OpenID_PAPE_Response object from a successful
OpenID library response.
@param Auth_OpenID_SuccessResponse $success_response A SuccessResponse
from Auth_OpenID_Consumer::complete()
@return Auth_OpenID_PAPE_Response A provider authentication policy response from the
data that was supplied with the id_res response. | [
"Create",
"an",
"Auth_OpenID_PAPE_Response",
"object",
"from",
"a",
"successful",
"OpenID",
"library",
"response",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/PAPE.php#L223-L241 |
openid/php-openid | Auth/OpenID/PAPE.php | Auth_OpenID_PAPE_Response.parseExtensionArgs | function parseExtensionArgs($args, $strict=false)
{
$policies_str = Auth_OpenID::arrayGet($args, 'auth_policies');
if ($policies_str && $policies_str != "none") {
$this->auth_policies = explode(" ", $policies_str);
}
$nist_level_str = Auth_OpenID::arrayGet($args, 'nist_auth_level');
if ($nist_level_str !== null) {
$nist_level = Auth_OpenID::intval($nist_level_str);
if ($nist_level === false) {
if ($strict) {
return false;
} else {
$nist_level = null;
}
}
if (0 <= $nist_level && $nist_level < 5) {
$this->nist_auth_level = $nist_level;
} else if ($strict) {
return false;
}
}
$auth_time = Auth_OpenID::arrayGet($args, 'auth_time');
if ($auth_time !== null) {
if (preg_match(PAPE_TIME_VALIDATOR, $auth_time)) {
$this->auth_time = $auth_time;
} else if ($strict) {
return false;
}
}
return null;
} | php | function parseExtensionArgs($args, $strict=false)
{
$policies_str = Auth_OpenID::arrayGet($args, 'auth_policies');
if ($policies_str && $policies_str != "none") {
$this->auth_policies = explode(" ", $policies_str);
}
$nist_level_str = Auth_OpenID::arrayGet($args, 'nist_auth_level');
if ($nist_level_str !== null) {
$nist_level = Auth_OpenID::intval($nist_level_str);
if ($nist_level === false) {
if ($strict) {
return false;
} else {
$nist_level = null;
}
}
if (0 <= $nist_level && $nist_level < 5) {
$this->nist_auth_level = $nist_level;
} else if ($strict) {
return false;
}
}
$auth_time = Auth_OpenID::arrayGet($args, 'auth_time');
if ($auth_time !== null) {
if (preg_match(PAPE_TIME_VALIDATOR, $auth_time)) {
$this->auth_time = $auth_time;
} else if ($strict) {
return false;
}
}
return null;
} | [
"function",
"parseExtensionArgs",
"(",
"$",
"args",
",",
"$",
"strict",
"=",
"false",
")",
"{",
"$",
"policies_str",
"=",
"Auth_OpenID",
"::",
"arrayGet",
"(",
"$",
"args",
",",
"'auth_policies'",
")",
";",
"if",
"(",
"$",
"policies_str",
"&&",
"$",
"pol... | Parse the provider authentication policy arguments into the
internal state of this object
@param array $args unqualified provider authentication policy
arguments
@param bool $strict Whether to return false when bad data is
encountered
@return null|bool The data is parsed into the internal fields of
this object. | [
"Parse",
"the",
"provider",
"authentication",
"policy",
"arguments",
"into",
"the",
"internal",
"state",
"of",
"this",
"object"
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/PAPE.php#L256-L291 |
openid/php-openid | Auth/OpenID/PAPE.php | Auth_OpenID_PAPE_Response.getExtensionArgs | function getExtensionArgs($request = null)
{
$ns_args = array();
if (count($this->auth_policies) > 0) {
$ns_args['auth_policies'] = implode(' ', $this->auth_policies);
} else {
$ns_args['auth_policies'] = 'none';
}
if ($this->nist_auth_level !== null) {
if (!in_array($this->nist_auth_level, range(0, 4), true)) {
return false;
}
$ns_args['nist_auth_level'] = strval($this->nist_auth_level);
}
if ($this->auth_time !== null) {
if (!preg_match(PAPE_TIME_VALIDATOR, $this->auth_time)) {
return false;
}
$ns_args['auth_time'] = $this->auth_time;
}
return $ns_args;
} | php | function getExtensionArgs($request = null)
{
$ns_args = array();
if (count($this->auth_policies) > 0) {
$ns_args['auth_policies'] = implode(' ', $this->auth_policies);
} else {
$ns_args['auth_policies'] = 'none';
}
if ($this->nist_auth_level !== null) {
if (!in_array($this->nist_auth_level, range(0, 4), true)) {
return false;
}
$ns_args['nist_auth_level'] = strval($this->nist_auth_level);
}
if ($this->auth_time !== null) {
if (!preg_match(PAPE_TIME_VALIDATOR, $this->auth_time)) {
return false;
}
$ns_args['auth_time'] = $this->auth_time;
}
return $ns_args;
} | [
"function",
"getExtensionArgs",
"(",
"$",
"request",
"=",
"null",
")",
"{",
"$",
"ns_args",
"=",
"array",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"auth_policies",
")",
">",
"0",
")",
"{",
"$",
"ns_args",
"[",
"'auth_policies'",
"]"... | Get the string arguments that should be added to an OpenID
message for this extension.
@param Auth_OpenID_Request|null $request
@return null | [
"Get",
"the",
"string",
"arguments",
"that",
"should",
"be",
"added",
"to",
"an",
"OpenID",
"message",
"for",
"this",
"extension",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/PAPE.php#L300-L325 |
openid/php-openid | Auth/OpenID/TrustRoot.php | Auth_OpenID_TrustRoot.buildDiscoveryURL | static function buildDiscoveryURL($realm)
{
$parsed = Auth_OpenID_TrustRoot::_parse($realm);
if ($parsed === false) {
return false;
}
if ($parsed['wildcard']) {
// Use "www." in place of the star
if ($parsed['host'][0] != '.') {
return false;
}
$www_domain = 'www' . $parsed['host'];
return sprintf('%s://%s%s', $parsed['scheme'],
$www_domain, $parsed['path']);
} else {
return $parsed['unparsed'];
}
} | php | static function buildDiscoveryURL($realm)
{
$parsed = Auth_OpenID_TrustRoot::_parse($realm);
if ($parsed === false) {
return false;
}
if ($parsed['wildcard']) {
// Use "www." in place of the star
if ($parsed['host'][0] != '.') {
return false;
}
$www_domain = 'www' . $parsed['host'];
return sprintf('%s://%s%s', $parsed['scheme'],
$www_domain, $parsed['path']);
} else {
return $parsed['unparsed'];
}
} | [
"static",
"function",
"buildDiscoveryURL",
"(",
"$",
"realm",
")",
"{",
"$",
"parsed",
"=",
"Auth_OpenID_TrustRoot",
"::",
"_parse",
"(",
"$",
"realm",
")",
";",
"if",
"(",
"$",
"parsed",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"if",
"("... | /*
Return a discovery URL for this realm.
Return null if the realm could not be parsed or was not valid.
@param return_to The relying party return URL of the OpenID
authentication request
@return The URL upon which relying party discovery should be
run in order to verify the return_to URL | [
"/",
"*",
"Return",
"a",
"discovery",
"URL",
"for",
"this",
"realm",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/TrustRoot.php#L61-L82 |
openid/php-openid | Auth/OpenID/TrustRoot.php | Auth_OpenID_TrustRoot._parse | static function _parse($trust_root)
{
$trust_root = Auth_OpenID_urinorm($trust_root);
if ($trust_root === null) {
return false;
}
if (preg_match("/:\/\/[^:]+(:\d+){2,}(\/|$)/", $trust_root)) {
return false;
}
$parts = @parse_url($trust_root);
if ($parts === false) {
return false;
}
$required_parts = array('scheme', 'host');
$forbidden_parts = array('user', 'pass', 'fragment');
$keys = array_keys($parts);
if (array_intersect($keys, $required_parts) != $required_parts) {
return false;
}
if (array_intersect($keys, $forbidden_parts) != array()) {
return false;
}
if (!preg_match(Auth_OpenID___HostSegmentRe, $parts['host'])) {
return false;
}
$scheme = strtolower($parts['scheme']);
$allowed_schemes = array('http', 'https');
if (!in_array($scheme, $allowed_schemes)) {
return false;
}
$parts['scheme'] = $scheme;
$host = strtolower($parts['host']);
$hostparts = explode('*', $host);
switch (count($hostparts)) {
case 1:
$parts['wildcard'] = false;
break;
case 2:
if ($hostparts[0] ||
($hostparts[1] && substr($hostparts[1], 0, 1) != '.')) {
return false;
}
$host = $hostparts[1];
$parts['wildcard'] = true;
break;
default:
return false;
}
if (strpos($host, ':') !== false) {
return false;
}
$parts['host'] = $host;
if (isset($parts['path'])) {
$path = strtolower($parts['path']);
if (substr($path, 0, 1) != '/') {
return false;
}
} else {
$path = '/';
}
$parts['path'] = $path;
if (!isset($parts['port'])) {
$parts['port'] = false;
}
$parts['unparsed'] = $trust_root;
return $parts;
} | php | static function _parse($trust_root)
{
$trust_root = Auth_OpenID_urinorm($trust_root);
if ($trust_root === null) {
return false;
}
if (preg_match("/:\/\/[^:]+(:\d+){2,}(\/|$)/", $trust_root)) {
return false;
}
$parts = @parse_url($trust_root);
if ($parts === false) {
return false;
}
$required_parts = array('scheme', 'host');
$forbidden_parts = array('user', 'pass', 'fragment');
$keys = array_keys($parts);
if (array_intersect($keys, $required_parts) != $required_parts) {
return false;
}
if (array_intersect($keys, $forbidden_parts) != array()) {
return false;
}
if (!preg_match(Auth_OpenID___HostSegmentRe, $parts['host'])) {
return false;
}
$scheme = strtolower($parts['scheme']);
$allowed_schemes = array('http', 'https');
if (!in_array($scheme, $allowed_schemes)) {
return false;
}
$parts['scheme'] = $scheme;
$host = strtolower($parts['host']);
$hostparts = explode('*', $host);
switch (count($hostparts)) {
case 1:
$parts['wildcard'] = false;
break;
case 2:
if ($hostparts[0] ||
($hostparts[1] && substr($hostparts[1], 0, 1) != '.')) {
return false;
}
$host = $hostparts[1];
$parts['wildcard'] = true;
break;
default:
return false;
}
if (strpos($host, ':') !== false) {
return false;
}
$parts['host'] = $host;
if (isset($parts['path'])) {
$path = strtolower($parts['path']);
if (substr($path, 0, 1) != '/') {
return false;
}
} else {
$path = '/';
}
$parts['path'] = $path;
if (!isset($parts['port'])) {
$parts['port'] = false;
}
$parts['unparsed'] = $trust_root;
return $parts;
} | [
"static",
"function",
"_parse",
"(",
"$",
"trust_root",
")",
"{",
"$",
"trust_root",
"=",
"Auth_OpenID_urinorm",
"(",
"$",
"trust_root",
")",
";",
"if",
"(",
"$",
"trust_root",
"===",
"null",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"preg_match"... | Parse a URL into its trust_root parts.
@static
@access private
@param string $trust_root The url to parse
@return mixed $parsed Either an associative array of trust root
parts or false if parsing failed. | [
"Parse",
"a",
"URL",
"into",
"its",
"trust_root",
"parts",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/TrustRoot.php#L96-L175 |
openid/php-openid | Auth/OpenID/TrustRoot.php | Auth_OpenID_TrustRoot.isSane | static function isSane($trust_root)
{
$parts = Auth_OpenID_TrustRoot::_parse($trust_root);
if ($parts === false) {
return false;
}
// Localhost is a special case
if ($parts['host'] == 'localhost') {
return true;
}
$host_parts = explode('.', $parts['host']);
if ($parts['wildcard']) {
// Remove the empty string from the beginning of the array
array_shift($host_parts);
}
if ($host_parts && !$host_parts[count($host_parts) - 1]) {
array_pop($host_parts);
}
if (!$host_parts) {
return false;
}
// Don't allow adjacent dots
if (in_array('', $host_parts, true)) {
return false;
}
// Get the top-level domain of the host. If it is not a valid TLD,
// it's not sane.
preg_match(Auth_OpenID___TLDs, $parts['host'], $matches);
if (!$matches) {
return false;
}
$tld = $matches[1];
if (count($host_parts) == 1) {
return false;
}
if ($parts['wildcard']) {
// It's a 2-letter tld with a short second to last segment
// so there needs to be more than two segments specified
// (e.g. *.co.uk is insane)
$second_level = $host_parts[count($host_parts) - 2];
if (strlen($tld) == 2 && strlen($second_level) <= 3) {
return count($host_parts) > 2;
}
}
return true;
} | php | static function isSane($trust_root)
{
$parts = Auth_OpenID_TrustRoot::_parse($trust_root);
if ($parts === false) {
return false;
}
// Localhost is a special case
if ($parts['host'] == 'localhost') {
return true;
}
$host_parts = explode('.', $parts['host']);
if ($parts['wildcard']) {
// Remove the empty string from the beginning of the array
array_shift($host_parts);
}
if ($host_parts && !$host_parts[count($host_parts) - 1]) {
array_pop($host_parts);
}
if (!$host_parts) {
return false;
}
// Don't allow adjacent dots
if (in_array('', $host_parts, true)) {
return false;
}
// Get the top-level domain of the host. If it is not a valid TLD,
// it's not sane.
preg_match(Auth_OpenID___TLDs, $parts['host'], $matches);
if (!$matches) {
return false;
}
$tld = $matches[1];
if (count($host_parts) == 1) {
return false;
}
if ($parts['wildcard']) {
// It's a 2-letter tld with a short second to last segment
// so there needs to be more than two segments specified
// (e.g. *.co.uk is insane)
$second_level = $host_parts[count($host_parts) - 2];
if (strlen($tld) == 2 && strlen($second_level) <= 3) {
return count($host_parts) > 2;
}
}
return true;
} | [
"static",
"function",
"isSane",
"(",
"$",
"trust_root",
")",
"{",
"$",
"parts",
"=",
"Auth_OpenID_TrustRoot",
"::",
"_parse",
"(",
"$",
"trust_root",
")",
";",
"if",
"(",
"$",
"parts",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"// Localhost ... | Is this trust root sane?
A trust root is sane if it is syntactically valid and it has a
reasonable domain name. Specifically, the domain name must be
more than one level below a standard TLD or more than two
levels below a two-letter tld.
For example, '*.com' is not a sane trust root, but '*.foo.com'
is. '*.co.uk' is not sane, but '*.bbc.co.uk' is.
This check is not always correct, but it attempts to err on the
side of marking sane trust roots insane instead of marking
insane trust roots sane. For example, 'kink.fm' is marked as
insane even though it "should" (for some meaning of should) be
marked sane.
This function should be used when creating OpenID servers to
alert the users of the server when a consumer attempts to get
the user to accept a suspicious trust root.
@static
@param string $trust_root The trust root to check
@return bool $sanity Whether the trust root looks OK | [
"Is",
"this",
"trust",
"root",
"sane?"
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/TrustRoot.php#L202-L256 |
openid/php-openid | Auth/OpenID/TrustRoot.php | Auth_OpenID_TrustRoot.match | static function match($trust_root, $url)
{
$trust_root_parsed = Auth_OpenID_TrustRoot::_parse($trust_root);
$url_parsed = Auth_OpenID_TrustRoot::_parse($url);
if (!$trust_root_parsed || !$url_parsed) {
return false;
}
// Check hosts matching
if ($url_parsed['wildcard']) {
return false;
}
if ($trust_root_parsed['wildcard']) {
$host_tail = $trust_root_parsed['host'];
$host = $url_parsed['host'];
if ($host_tail &&
substr($host, -(strlen($host_tail))) != $host_tail &&
substr($host_tail, 1) != $host) {
return false;
}
} else {
if ($trust_root_parsed['host'] != $url_parsed['host']) {
return false;
}
}
// Check path and query matching
$base_path = $trust_root_parsed['path'];
$path = $url_parsed['path'];
if (!isset($trust_root_parsed['query'])) {
if ($base_path != $path) {
if (substr($path, 0, strlen($base_path)) != $base_path) {
return false;
}
if (substr($base_path, strlen($base_path) - 1, 1) != '/' &&
substr($path, strlen($base_path), 1) != '/') {
return false;
}
}
} else {
$base_query = $trust_root_parsed['query'];
$query = @$url_parsed['query'];
$qplus = substr($query, 0, strlen($base_query) + 1);
$bqplus = $base_query . '&';
if ($base_path != $path ||
($base_query != $query && $qplus != $bqplus)) {
return false;
}
}
// The port and scheme need to match exactly
return ($trust_root_parsed['scheme'] == $url_parsed['scheme'] &&
$url_parsed['port'] === $trust_root_parsed['port']);
} | php | static function match($trust_root, $url)
{
$trust_root_parsed = Auth_OpenID_TrustRoot::_parse($trust_root);
$url_parsed = Auth_OpenID_TrustRoot::_parse($url);
if (!$trust_root_parsed || !$url_parsed) {
return false;
}
// Check hosts matching
if ($url_parsed['wildcard']) {
return false;
}
if ($trust_root_parsed['wildcard']) {
$host_tail = $trust_root_parsed['host'];
$host = $url_parsed['host'];
if ($host_tail &&
substr($host, -(strlen($host_tail))) != $host_tail &&
substr($host_tail, 1) != $host) {
return false;
}
} else {
if ($trust_root_parsed['host'] != $url_parsed['host']) {
return false;
}
}
// Check path and query matching
$base_path = $trust_root_parsed['path'];
$path = $url_parsed['path'];
if (!isset($trust_root_parsed['query'])) {
if ($base_path != $path) {
if (substr($path, 0, strlen($base_path)) != $base_path) {
return false;
}
if (substr($base_path, strlen($base_path) - 1, 1) != '/' &&
substr($path, strlen($base_path), 1) != '/') {
return false;
}
}
} else {
$base_query = $trust_root_parsed['query'];
$query = @$url_parsed['query'];
$qplus = substr($query, 0, strlen($base_query) + 1);
$bqplus = $base_query . '&';
if ($base_path != $path ||
($base_query != $query && $qplus != $bqplus)) {
return false;
}
}
// The port and scheme need to match exactly
return ($trust_root_parsed['scheme'] == $url_parsed['scheme'] &&
$url_parsed['port'] === $trust_root_parsed['port']);
} | [
"static",
"function",
"match",
"(",
"$",
"trust_root",
",",
"$",
"url",
")",
"{",
"$",
"trust_root_parsed",
"=",
"Auth_OpenID_TrustRoot",
"::",
"_parse",
"(",
"$",
"trust_root",
")",
";",
"$",
"url_parsed",
"=",
"Auth_OpenID_TrustRoot",
"::",
"_parse",
"(",
... | Does this URL match the given trust root?
Return whether the URL falls under the given trust root. This
does not check whether the trust root is sane. If the URL or
trust root do not parse, this function will return false.
@param string $trust_root The trust root to match against
@param string $url The URL to check
@return bool $matches Whether the URL matches against the
trust root | [
"Does",
"this",
"URL",
"match",
"the",
"given",
"trust",
"root?"
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/TrustRoot.php#L272-L325 |
openid/php-openid | Auth/OpenID/Message.php | Auth_OpenID_Mapping.items | function items()
{
$temp = array();
for ($i = 0; $i < count($this->keys); $i++) {
$temp[] = array($this->keys[$i],
$this->values[$i]);
}
return $temp;
} | php | function items()
{
$temp = array();
for ($i = 0; $i < count($this->keys); $i++) {
$temp[] = array($this->keys[$i],
$this->values[$i]);
}
return $temp;
} | [
"function",
"items",
"(",
")",
"{",
"$",
"temp",
"=",
"array",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"this",
"->",
"keys",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"temp",
"[",
"]",
"=",
"... | Returns an array of (key, value) pairs in the mapping. | [
"Returns",
"an",
"array",
"of",
"(",
"key",
"value",
")",
"pairs",
"in",
"the",
"mapping",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/Message.php#L184-L193 |
openid/php-openid | Auth/OpenID/Message.php | Auth_OpenID_Mapping.set | function set($key, $value)
{
$index = array_search($key, $this->keys);
if ($index !== false) {
$this->values[$index] = $value;
} else {
$this->keys[] = $key;
$this->values[] = $value;
}
} | php | function set($key, $value)
{
$index = array_search($key, $this->keys);
if ($index !== false) {
$this->values[$index] = $value;
} else {
$this->keys[] = $key;
$this->values[] = $value;
}
} | [
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"index",
"=",
"array_search",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"keys",
")",
";",
"if",
"(",
"$",
"index",
"!==",
"false",
")",
"{",
"$",
"this",
"->",
"values",
"[",
... | Sets a key-value pair in the mapping. If the key already
exists, its value is replaced with the new value.
@param string $key
@param mixed $value | [
"Sets",
"a",
"key",
"-",
"value",
"pair",
"in",
"the",
"mapping",
".",
"If",
"the",
"key",
"already",
"exists",
"its",
"value",
"is",
"replaced",
"with",
"the",
"new",
"value",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/Message.php#L210-L220 |
openid/php-openid | Auth/OpenID/Message.php | Auth_OpenID_Mapping.get | function get($key, $default = null)
{
$index = array_search($key, $this->keys);
if ($index !== false) {
return $this->values[$index];
} else {
return $default;
}
} | php | function get($key, $default = null)
{
$index = array_search($key, $this->keys);
if ($index !== false) {
return $this->values[$index];
} else {
return $default;
}
} | [
"function",
"get",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"index",
"=",
"array_search",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"keys",
")",
";",
"if",
"(",
"$",
"index",
"!==",
"false",
")",
"{",
"return",
"$",
"thi... | Gets a specified value from the mapping, associated with the
specified key. If the key does not exist in the mapping,
$default is returned instead.
@param string $key
@param mixed $default
@return mixed|null | [
"Gets",
"a",
"specified",
"value",
"from",
"the",
"mapping",
"associated",
"with",
"the",
"specified",
"key",
".",
"If",
"the",
"key",
"does",
"not",
"exist",
"in",
"the",
"mapping",
"$default",
"is",
"returned",
"instead",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/Message.php#L231-L240 |
openid/php-openid | Auth/OpenID/Message.php | Auth_OpenID_Mapping.del | function del($key)
{
$index = array_search($key, $this->keys);
if ($index !== false) {
unset($this->keys[$index]);
unset($this->values[$index]);
$this->_reflow();
return true;
}
return false;
} | php | function del($key)
{
$index = array_search($key, $this->keys);
if ($index !== false) {
unset($this->keys[$index]);
unset($this->values[$index]);
$this->_reflow();
return true;
}
return false;
} | [
"function",
"del",
"(",
"$",
"key",
")",
"{",
"$",
"index",
"=",
"array_search",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"keys",
")",
";",
"if",
"(",
"$",
"index",
"!==",
"false",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"keys",
"[",
"$",
... | Deletes a key-value pair from the mapping with the specified
key.
@param string $key
@return bool | [
"Deletes",
"a",
"key",
"-",
"value",
"pair",
"from",
"the",
"mapping",
"with",
"the",
"specified",
"key",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/Message.php#L271-L282 |
openid/php-openid | contrib/signed_assertions/AP.php | Attribute_Provider.sign | function sign($openid,$attribute,$value)
{
$samlObj = new SAML();
$responseXmlString = $samlObj->createSamlAssertion($openid,
$this->notBefore,
$this->notOnOrAfter,
$this->rsadsa,
$this->acsURI,
$attribute,
sha1($value),
$this->assertionTemplate);
$signedAssertion=$samlObj->signAssertion($responseXmlString,
$this->private_key,
$this->public_key_certificate);
return $signedAssertion;
} | php | function sign($openid,$attribute,$value)
{
$samlObj = new SAML();
$responseXmlString = $samlObj->createSamlAssertion($openid,
$this->notBefore,
$this->notOnOrAfter,
$this->rsadsa,
$this->acsURI,
$attribute,
sha1($value),
$this->assertionTemplate);
$signedAssertion=$samlObj->signAssertion($responseXmlString,
$this->private_key,
$this->public_key_certificate);
return $signedAssertion;
} | [
"function",
"sign",
"(",
"$",
"openid",
",",
"$",
"attribute",
",",
"$",
"value",
")",
"{",
"$",
"samlObj",
"=",
"new",
"SAML",
"(",
")",
";",
"$",
"responseXmlString",
"=",
"$",
"samlObj",
"->",
"createSamlAssertion",
"(",
"$",
"openid",
",",
"$",
"... | Create the signed assertion.
@param string $openid - Openid of the entity being asserted.
@param string $attribute - The attribute name being asserted.
@param string $value - The attribute value being asserted. | [
"Create",
"the",
"signed",
"assertion",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/contrib/signed_assertions/AP.php#L62-L77 |
openid/php-openid | contrib/signed_assertions/AP.php | Attribute_Verifier.verify | function verify($responseXmlString)
{
$samlObj = new SAML();
$ret = $samlObj->verifyAssertion($responseXmlString,$this->rootcert);
return $ret;
} | php | function verify($responseXmlString)
{
$samlObj = new SAML();
$ret = $samlObj->verifyAssertion($responseXmlString,$this->rootcert);
return $ret;
} | [
"function",
"verify",
"(",
"$",
"responseXmlString",
")",
"{",
"$",
"samlObj",
"=",
"new",
"SAML",
"(",
")",
";",
"$",
"ret",
"=",
"$",
"samlObj",
"->",
"verifyAssertion",
"(",
"$",
"responseXmlString",
",",
"$",
"this",
"->",
"rootcert",
")",
";",
"re... | Verifies the certificate given the SAML document.
@param string - signed SAML assertion
return @boolean - true if verification is successful, false if unsuccessful. | [
"Verifies",
"the",
"certificate",
"given",
"the",
"SAML",
"document",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/contrib/signed_assertions/AP.php#L101-L106 |
openid/php-openid | contrib/signed_assertions/AP.php | AP_OP_StoreRequest.createStoreRequest | static function createStoreRequest(&$auth_request,&$attributeProvider,
$attribute,$value,$openid)
{
if(!$auth_request){
return null;
}
$signedAssertion=$attributeProvider->sign($openid,$attribute,$value);
$store_request=new Auth_OpenID_AX_StoreRequest;
$store_request->addValue($attribute,base64_encode($value));
$store_request->addValue($attribute.'/signature',
base64_encode($signedAssertion));
if($store_request) {
$auth_request->addExtension($store_request);
return $auth_request;
}
} | php | static function createStoreRequest(&$auth_request,&$attributeProvider,
$attribute,$value,$openid)
{
if(!$auth_request){
return null;
}
$signedAssertion=$attributeProvider->sign($openid,$attribute,$value);
$store_request=new Auth_OpenID_AX_StoreRequest;
$store_request->addValue($attribute,base64_encode($value));
$store_request->addValue($attribute.'/signature',
base64_encode($signedAssertion));
if($store_request) {
$auth_request->addExtension($store_request);
return $auth_request;
}
} | [
"static",
"function",
"createStoreRequest",
"(",
"&",
"$",
"auth_request",
",",
"&",
"$",
"attributeProvider",
",",
"$",
"attribute",
",",
"$",
"value",
",",
"$",
"openid",
")",
"{",
"if",
"(",
"!",
"$",
"auth_request",
")",
"{",
"return",
"null",
";",
... | Creates store request and adds it as an extension to AuthRequest object
passed to it.
@param &Auth_OpenID_AuthRequest &$auth_request - A reference to
the AuthRequest object.
@param &Attribute_Provider &$attributeProvider - A reference to the
Attribute Provider object.
@param string $attribute - The attribute name being asserted.
@param string $value - The attribute value being asserted.
@param string $openid - Openid of the entity being asserted.
@return &Auth_OpenID_AuthRequest - Auth_OpenID_AuthRequest object
returned with StoreRequest extension. | [
"Creates",
"store",
"request",
"and",
"adds",
"it",
"as",
"an",
"extension",
"to",
"AuthRequest",
"object",
"passed",
"to",
"it",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/contrib/signed_assertions/AP.php#L127-L142 |
openid/php-openid | contrib/signed_assertions/AP.php | RP_OP_Verify.verifyAssertion | function verifyAssertion(&$attributeVerifier,$response)
{
$ax_resp=Auth_OpenID_AX_FetchResponse::fromSuccessResponse($response);
if($ax_resp instanceof Auth_OpenID_AX_FetchResponse){
$ax_args=$ax_resp->getExtensionArgs();
if($ax_args) {
$value=base64_decode($ax_args['value.ext1.1']);
if($attributeVerifier->verify($value)){
return base64_decode($ax_args['value.ext0.1']);
} else {
return null;
}
} else {
return null;
}
} else {
return null;
}
} | php | function verifyAssertion(&$attributeVerifier,$response)
{
$ax_resp=Auth_OpenID_AX_FetchResponse::fromSuccessResponse($response);
if($ax_resp instanceof Auth_OpenID_AX_FetchResponse){
$ax_args=$ax_resp->getExtensionArgs();
if($ax_args) {
$value=base64_decode($ax_args['value.ext1.1']);
if($attributeVerifier->verify($value)){
return base64_decode($ax_args['value.ext0.1']);
} else {
return null;
}
} else {
return null;
}
} else {
return null;
}
} | [
"function",
"verifyAssertion",
"(",
"&",
"$",
"attributeVerifier",
",",
"$",
"response",
")",
"{",
"$",
"ax_resp",
"=",
"Auth_OpenID_AX_FetchResponse",
"::",
"fromSuccessResponse",
"(",
"$",
"response",
")",
";",
"if",
"(",
"$",
"ax_resp",
"instanceof",
"Auth_Op... | Verifies a given signed assertion.
@param &Attribute_Verifier &$attributeVerifier - An instance of the class
passed for the verification.
@param Auth_OpenID_Response - Response object for extraction.
@return boolean - true if successful, false if verification fails. | [
"Verifies",
"a",
"given",
"signed",
"assertion",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/contrib/signed_assertions/AP.php#L158-L176 |
openid/php-openid | Auth/Yadis/ParanoidHTTPFetcher.php | Auth_Yadis_ParanoidHTTPFetcher.supportsSSL | function supportsSSL()
{
$v = curl_version();
if(is_array($v)) {
return in_array('https', $v['protocols']);
} elseif (is_string($v)) {
return preg_match('/OpenSSL/i', $v);
} else {
return 0;
}
} | php | function supportsSSL()
{
$v = curl_version();
if(is_array($v)) {
return in_array('https', $v['protocols']);
} elseif (is_string($v)) {
return preg_match('/OpenSSL/i', $v);
} else {
return 0;
}
} | [
"function",
"supportsSSL",
"(",
")",
"{",
"$",
"v",
"=",
"curl_version",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"v",
")",
")",
"{",
"return",
"in_array",
"(",
"'https'",
",",
"$",
"v",
"[",
"'protocols'",
"]",
")",
";",
"}",
"elseif",
"(... | Does this fetcher support SSL URLs? | [
"Does",
"this",
"fetcher",
"support",
"SSL",
"URLs?"
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/Yadis/ParanoidHTTPFetcher.php#L76-L86 |
openid/php-openid | Auth/Yadis/HTTPFetcher.php | Auth_Yadis_HTTPFetcher.canFetchURL | function canFetchURL($url)
{
if ($this->isHTTPS($url) && !$this->supportsSSL()) {
Auth_OpenID::log("HTTPS URL unsupported fetching %s",
$url);
return false;
}
if (!$this->allowedURL($url)) {
Auth_OpenID::log("URL fetching not allowed for '%s'",
$url);
return false;
}
return true;
} | php | function canFetchURL($url)
{
if ($this->isHTTPS($url) && !$this->supportsSSL()) {
Auth_OpenID::log("HTTPS URL unsupported fetching %s",
$url);
return false;
}
if (!$this->allowedURL($url)) {
Auth_OpenID::log("URL fetching not allowed for '%s'",
$url);
return false;
}
return true;
} | [
"function",
"canFetchURL",
"(",
"$",
"url",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isHTTPS",
"(",
"$",
"url",
")",
"&&",
"!",
"$",
"this",
"->",
"supportsSSL",
"(",
")",
")",
"{",
"Auth_OpenID",
"::",
"log",
"(",
"\"HTTPS URL unsupported fetching %s\""... | Return whether a URL can be fetched. Returns false if the URL
scheme is not allowed or is not supported by this fetcher
implementation; returns true otherwise.
@param string $url
@return bool | [
"Return",
"whether",
"a",
"URL",
"can",
"be",
"fetched",
".",
"Returns",
"false",
"if",
"the",
"URL",
"scheme",
"is",
"not",
"allowed",
"or",
"is",
"not",
"supported",
"by",
"this",
"fetcher",
"implementation",
";",
"returns",
"true",
"otherwise",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/Yadis/HTTPFetcher.php#L62-L77 |
openid/php-openid | Auth/OpenID/FileStore.php | Auth_OpenID_FileStore._setup | function _setup()
{
return (Auth_OpenID::ensureDir($this->nonce_dir) &&
Auth_OpenID::ensureDir($this->association_dir) &&
Auth_OpenID::ensureDir($this->temp_dir));
} | php | function _setup()
{
return (Auth_OpenID::ensureDir($this->nonce_dir) &&
Auth_OpenID::ensureDir($this->association_dir) &&
Auth_OpenID::ensureDir($this->temp_dir));
} | [
"function",
"_setup",
"(",
")",
"{",
"return",
"(",
"Auth_OpenID",
"::",
"ensureDir",
"(",
"$",
"this",
"->",
"nonce_dir",
")",
"&&",
"Auth_OpenID",
"::",
"ensureDir",
"(",
"$",
"this",
"->",
"association_dir",
")",
"&&",
"Auth_OpenID",
"::",
"ensureDir",
... | Make sure that the directories in which we store our data
exist.
@access private | [
"Make",
"sure",
"that",
"the",
"directories",
"in",
"which",
"we",
"store",
"our",
"data",
"exist",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/FileStore.php#L96-L101 |
openid/php-openid | Auth/OpenID/FileStore.php | Auth_OpenID_FileStore._mktemp | function _mktemp()
{
$name = Auth_OpenID_FileStore::_mkstemp($dir = $this->temp_dir);
$file_obj = @fopen($name, 'wb');
if ($file_obj !== false) {
return array($file_obj, $name);
} else {
Auth_OpenID_FileStore::_removeIfPresent($name);
}
return array();
} | php | function _mktemp()
{
$name = Auth_OpenID_FileStore::_mkstemp($dir = $this->temp_dir);
$file_obj = @fopen($name, 'wb');
if ($file_obj !== false) {
return array($file_obj, $name);
} else {
Auth_OpenID_FileStore::_removeIfPresent($name);
}
return array();
} | [
"function",
"_mktemp",
"(",
")",
"{",
"$",
"name",
"=",
"Auth_OpenID_FileStore",
"::",
"_mkstemp",
"(",
"$",
"dir",
"=",
"$",
"this",
"->",
"temp_dir",
")",
";",
"$",
"file_obj",
"=",
"@",
"fopen",
"(",
"$",
"name",
",",
"'wb'",
")",
";",
"if",
"("... | Create a temporary file on the same filesystem as
$this->association_dir.
The temporary directory should not be cleaned if there are any
processes using the store. If there is no active process using
the store, it is safe to remove all of the files in the
temporary directory.
@return array ($fd, $filename)
@access private | [
"Create",
"a",
"temporary",
"file",
"on",
"the",
"same",
"filesystem",
"as",
"$this",
"-",
">",
"association_dir",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/FileStore.php#L115-L125 |
openid/php-openid | Auth/OpenID/FileStore.php | Auth_OpenID_FileStore.getAssociationFilename | function getAssociationFilename($server_url, $handle)
{
if (!$this->active) {
trigger_error("FileStore no longer active", E_USER_ERROR);
return null;
}
if (strpos($server_url, '://') === false) {
trigger_error(sprintf("Bad server URL: %s", $server_url),
E_USER_WARNING);
return null;
}
list($proto, $rest) = explode('://', $server_url, 2);
$parts = explode('/', $rest);
$domain = Auth_OpenID_FileStore::_filenameEscape($parts[0]);
$url_hash = Auth_OpenID_FileStore::_safe64($server_url);
if ($handle) {
$handle_hash = Auth_OpenID_FileStore::_safe64($handle);
} else {
$handle_hash = '';
}
$filename = sprintf('%s-%s-%s-%s', $proto, $domain, $url_hash,
$handle_hash);
return $this->association_dir. DIRECTORY_SEPARATOR . $filename;
} | php | function getAssociationFilename($server_url, $handle)
{
if (!$this->active) {
trigger_error("FileStore no longer active", E_USER_ERROR);
return null;
}
if (strpos($server_url, '://') === false) {
trigger_error(sprintf("Bad server URL: %s", $server_url),
E_USER_WARNING);
return null;
}
list($proto, $rest) = explode('://', $server_url, 2);
$parts = explode('/', $rest);
$domain = Auth_OpenID_FileStore::_filenameEscape($parts[0]);
$url_hash = Auth_OpenID_FileStore::_safe64($server_url);
if ($handle) {
$handle_hash = Auth_OpenID_FileStore::_safe64($handle);
} else {
$handle_hash = '';
}
$filename = sprintf('%s-%s-%s-%s', $proto, $domain, $url_hash,
$handle_hash);
return $this->association_dir. DIRECTORY_SEPARATOR . $filename;
} | [
"function",
"getAssociationFilename",
"(",
"$",
"server_url",
",",
"$",
"handle",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"active",
")",
"{",
"trigger_error",
"(",
"\"FileStore no longer active\"",
",",
"E_USER_ERROR",
")",
";",
"return",
"null",
";",
"... | Create a unique filename for a given server url and
handle. This implementation does not assume anything about the
format of the handle. The filename that is returned will
contain the domain name from the server URL for ease of human
inspection of the data directory.
@param string $server_url
@param string $handle
@return string $filename | [
"Create",
"a",
"unique",
"filename",
"for",
"a",
"given",
"server",
"url",
"and",
"handle",
".",
"This",
"implementation",
"does",
"not",
"assume",
"anything",
"about",
"the",
"format",
"of",
"the",
"handle",
".",
"The",
"filename",
"that",
"is",
"returned",... | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/FileStore.php#L160-L187 |
openid/php-openid | Auth/OpenID/FileStore.php | Auth_OpenID_FileStore.storeAssociation | function storeAssociation($server_url, $association)
{
if (!$this->active) {
trigger_error("FileStore no longer active", E_USER_ERROR);
return false;
}
$association_s = $association->serialize();
$filename = $this->getAssociationFilename($server_url,
$association->handle);
list($tmp_file, $tmp) = $this->_mktemp();
if (!$tmp_file) {
trigger_error("_mktemp didn't return a valid file descriptor",
E_USER_WARNING);
return false;
}
fwrite($tmp_file, $association_s);
fflush($tmp_file);
fclose($tmp_file);
if (@rename($tmp, $filename)) {
return true;
} else {
// In case we are running on Windows, try unlinking the
// file in case it exists.
@unlink($filename);
// Now the target should not exist. Try renaming again,
// giving up if it fails.
if (@rename($tmp, $filename)) {
return true;
}
}
// If there was an error, don't leave the temporary file
// around.
Auth_OpenID_FileStore::_removeIfPresent($tmp);
return false;
} | php | function storeAssociation($server_url, $association)
{
if (!$this->active) {
trigger_error("FileStore no longer active", E_USER_ERROR);
return false;
}
$association_s = $association->serialize();
$filename = $this->getAssociationFilename($server_url,
$association->handle);
list($tmp_file, $tmp) = $this->_mktemp();
if (!$tmp_file) {
trigger_error("_mktemp didn't return a valid file descriptor",
E_USER_WARNING);
return false;
}
fwrite($tmp_file, $association_s);
fflush($tmp_file);
fclose($tmp_file);
if (@rename($tmp, $filename)) {
return true;
} else {
// In case we are running on Windows, try unlinking the
// file in case it exists.
@unlink($filename);
// Now the target should not exist. Try renaming again,
// giving up if it fails.
if (@rename($tmp, $filename)) {
return true;
}
}
// If there was an error, don't leave the temporary file
// around.
Auth_OpenID_FileStore::_removeIfPresent($tmp);
return false;
} | [
"function",
"storeAssociation",
"(",
"$",
"server_url",
",",
"$",
"association",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"active",
")",
"{",
"trigger_error",
"(",
"\"FileStore no longer active\"",
",",
"E_USER_ERROR",
")",
";",
"return",
"false",
";",
"... | Store an association in the association directory.
@param string $server_url
@param Auth_OpenID_Association $association
@return bool | [
"Store",
"an",
"association",
"in",
"the",
"association",
"directory",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/FileStore.php#L196-L238 |
openid/php-openid | Auth/OpenID/FileStore.php | Auth_OpenID_FileStore.getAssociation | function getAssociation($server_url, $handle = null)
{
if (!$this->active) {
trigger_error("FileStore no longer active", E_USER_ERROR);
return null;
}
if ($handle === null) {
$handle = '';
}
// The filename with the empty handle is a prefix of all other
// associations for the given server URL.
$filename = $this->getAssociationFilename($server_url, $handle);
if ($handle) {
return $this->_getAssociation($filename);
} else {
$association_files =
Auth_OpenID_FileStore::_listdir($this->association_dir);
$matching_files = array();
// strip off the path to do the comparison
$name = basename($filename);
foreach ($association_files as $association_file) {
$base = basename($association_file);
if (strpos($base, $name) === 0) {
$matching_files[] = $association_file;
}
}
$matching_associations = array();
// read the matching files and sort by time issued
foreach ($matching_files as $full_name) {
$association = $this->_getAssociation($full_name);
if ($association !== null) {
$matching_associations[] = array($association->issued,
$association);
}
}
$issued = array();
$assocs = array();
foreach ($matching_associations as $key => $assoc) {
$issued[$key] = $assoc[0];
$assocs[$key] = $assoc[1];
}
array_multisort($issued, SORT_DESC, $assocs, SORT_DESC,
$matching_associations);
// return the most recently issued one.
if ($matching_associations) {
list(, $assoc) = $matching_associations[0];
return $assoc;
} else {
return null;
}
}
} | php | function getAssociation($server_url, $handle = null)
{
if (!$this->active) {
trigger_error("FileStore no longer active", E_USER_ERROR);
return null;
}
if ($handle === null) {
$handle = '';
}
// The filename with the empty handle is a prefix of all other
// associations for the given server URL.
$filename = $this->getAssociationFilename($server_url, $handle);
if ($handle) {
return $this->_getAssociation($filename);
} else {
$association_files =
Auth_OpenID_FileStore::_listdir($this->association_dir);
$matching_files = array();
// strip off the path to do the comparison
$name = basename($filename);
foreach ($association_files as $association_file) {
$base = basename($association_file);
if (strpos($base, $name) === 0) {
$matching_files[] = $association_file;
}
}
$matching_associations = array();
// read the matching files and sort by time issued
foreach ($matching_files as $full_name) {
$association = $this->_getAssociation($full_name);
if ($association !== null) {
$matching_associations[] = array($association->issued,
$association);
}
}
$issued = array();
$assocs = array();
foreach ($matching_associations as $key => $assoc) {
$issued[$key] = $assoc[0];
$assocs[$key] = $assoc[1];
}
array_multisort($issued, SORT_DESC, $assocs, SORT_DESC,
$matching_associations);
// return the most recently issued one.
if ($matching_associations) {
list(, $assoc) = $matching_associations[0];
return $assoc;
} else {
return null;
}
}
} | [
"function",
"getAssociation",
"(",
"$",
"server_url",
",",
"$",
"handle",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"active",
")",
"{",
"trigger_error",
"(",
"\"FileStore no longer active\"",
",",
"E_USER_ERROR",
")",
";",
"return",
"null",
... | Retrieve an association. If no handle is specified, return the
association with the most recent issue time.
@param string $server_url
@param string|null $handle
@return Auth_OpenID_Association|mixed|null | [
"Retrieve",
"an",
"association",
".",
"If",
"no",
"handle",
"is",
"specified",
"return",
"the",
"association",
"with",
"the",
"most",
"recent",
"issue",
"time",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/FileStore.php#L248-L307 |
openid/php-openid | Auth/OpenID/FileStore.php | Auth_OpenID_FileStore.removeAssociation | function removeAssociation($server_url, $handle)
{
if (!$this->active) {
trigger_error("FileStore no longer active", E_USER_ERROR);
return null;
}
$assoc = $this->getAssociation($server_url, $handle);
if ($assoc === null) {
return false;
} else {
$filename = $this->getAssociationFilename($server_url, $handle);
return Auth_OpenID_FileStore::_removeIfPresent($filename);
}
} | php | function removeAssociation($server_url, $handle)
{
if (!$this->active) {
trigger_error("FileStore no longer active", E_USER_ERROR);
return null;
}
$assoc = $this->getAssociation($server_url, $handle);
if ($assoc === null) {
return false;
} else {
$filename = $this->getAssociationFilename($server_url, $handle);
return Auth_OpenID_FileStore::_removeIfPresent($filename);
}
} | [
"function",
"removeAssociation",
"(",
"$",
"server_url",
",",
"$",
"handle",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"active",
")",
"{",
"trigger_error",
"(",
"\"FileStore no longer active\"",
",",
"E_USER_ERROR",
")",
";",
"return",
"null",
";",
"}",
... | Remove an association if it exists. Do nothing if it does not.
@param string $server_url
@param string $handle
@return bool $success | [
"Remove",
"an",
"association",
"if",
"it",
"exists",
".",
"Do",
"nothing",
"if",
"it",
"does",
"not",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/FileStore.php#L367-L381 |
openid/php-openid | Auth/OpenID/FileStore.php | Auth_OpenID_FileStore.useNonce | function useNonce($server_url, $timestamp, $salt)
{
global $Auth_OpenID_SKEW;
if (!$this->active) {
trigger_error("FileStore no longer active", E_USER_ERROR);
return null;
}
if ( abs($timestamp - time()) > $Auth_OpenID_SKEW ) {
return false;
}
if ($server_url) {
list($proto, $rest) = explode('://', $server_url, 2);
} else {
$proto = '';
$rest = '';
}
$parts = explode('/', $rest, 2);
$domain = $this->_filenameEscape($parts[0]);
$url_hash = $this->_safe64($server_url);
$salt_hash = $this->_safe64($salt);
$filename = sprintf('%08x-%s-%s-%s-%s', $timestamp, $proto,
$domain, $url_hash, $salt_hash);
$filename = $this->nonce_dir . DIRECTORY_SEPARATOR . $filename;
$result = @fopen($filename, 'x');
if ($result === false) {
return false;
} else {
fclose($result);
return true;
}
} | php | function useNonce($server_url, $timestamp, $salt)
{
global $Auth_OpenID_SKEW;
if (!$this->active) {
trigger_error("FileStore no longer active", E_USER_ERROR);
return null;
}
if ( abs($timestamp - time()) > $Auth_OpenID_SKEW ) {
return false;
}
if ($server_url) {
list($proto, $rest) = explode('://', $server_url, 2);
} else {
$proto = '';
$rest = '';
}
$parts = explode('/', $rest, 2);
$domain = $this->_filenameEscape($parts[0]);
$url_hash = $this->_safe64($server_url);
$salt_hash = $this->_safe64($salt);
$filename = sprintf('%08x-%s-%s-%s-%s', $timestamp, $proto,
$domain, $url_hash, $salt_hash);
$filename = $this->nonce_dir . DIRECTORY_SEPARATOR . $filename;
$result = @fopen($filename, 'x');
if ($result === false) {
return false;
} else {
fclose($result);
return true;
}
} | [
"function",
"useNonce",
"(",
"$",
"server_url",
",",
"$",
"timestamp",
",",
"$",
"salt",
")",
"{",
"global",
"$",
"Auth_OpenID_SKEW",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"active",
")",
"{",
"trigger_error",
"(",
"\"FileStore no longer active\"",
",",
"... | Return whether this nonce is present. As a side effect, mark it
as no longer present.
@param string $server_url
@param int $timestamp
@param string $salt
@return bool $present | [
"Return",
"whether",
"this",
"nonce",
"is",
"present",
".",
"As",
"a",
"side",
"effect",
"mark",
"it",
"as",
"no",
"longer",
"present",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/FileStore.php#L392-L429 |
openid/php-openid | Auth/OpenID/FileStore.php | Auth_OpenID_FileStore._allAssocs | function _allAssocs()
{
$all_associations = array();
$association_filenames =
Auth_OpenID_FileStore::_listdir($this->association_dir);
foreach ($association_filenames as $association_filename) {
$association_file = fopen($association_filename, 'rb');
if ($association_file !== false) {
$assoc_s = fread($association_file,
filesize($association_filename));
fclose($association_file);
// Remove expired or corrupted associations
$association =
Auth_OpenID_Association::deserialize(
'Auth_OpenID_Association', $assoc_s);
if ($association === null) {
Auth_OpenID_FileStore::_removeIfPresent(
$association_filename);
} else {
if ($association->getExpiresIn() == 0) {
$all_associations[] = array($association_filename,
$association);
}
}
}
}
return $all_associations;
} | php | function _allAssocs()
{
$all_associations = array();
$association_filenames =
Auth_OpenID_FileStore::_listdir($this->association_dir);
foreach ($association_filenames as $association_filename) {
$association_file = fopen($association_filename, 'rb');
if ($association_file !== false) {
$assoc_s = fread($association_file,
filesize($association_filename));
fclose($association_file);
// Remove expired or corrupted associations
$association =
Auth_OpenID_Association::deserialize(
'Auth_OpenID_Association', $assoc_s);
if ($association === null) {
Auth_OpenID_FileStore::_removeIfPresent(
$association_filename);
} else {
if ($association->getExpiresIn() == 0) {
$all_associations[] = array($association_filename,
$association);
}
}
}
}
return $all_associations;
} | [
"function",
"_allAssocs",
"(",
")",
"{",
"$",
"all_associations",
"=",
"array",
"(",
")",
";",
"$",
"association_filenames",
"=",
"Auth_OpenID_FileStore",
"::",
"_listdir",
"(",
"$",
"this",
"->",
"association_dir",
")",
";",
"foreach",
"(",
"$",
"association_... | Remove expired entries from the database. This is potentially
expensive, so only run when it is acceptable to take time.
@access private | [
"Remove",
"expired",
"entries",
"from",
"the",
"database",
".",
"This",
"is",
"potentially",
"expensive",
"so",
"only",
"run",
"when",
"it",
"is",
"acceptable",
"to",
"take",
"time",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/FileStore.php#L437-L470 |
openid/php-openid | Auth/OpenID/AX.php | Auth_OpenID_AX_Message._checkMode | function _checkMode($ax_args)
{
$mode = Auth_OpenID::arrayGet($ax_args, 'mode');
if ($mode != $this->mode) {
return new Auth_OpenID_AX_Error(
sprintf(
"Expected mode '%s'; got '%s'",
$this->mode, $mode));
}
return true;
} | php | function _checkMode($ax_args)
{
$mode = Auth_OpenID::arrayGet($ax_args, 'mode');
if ($mode != $this->mode) {
return new Auth_OpenID_AX_Error(
sprintf(
"Expected mode '%s'; got '%s'",
$this->mode, $mode));
}
return true;
} | [
"function",
"_checkMode",
"(",
"$",
"ax_args",
")",
"{",
"$",
"mode",
"=",
"Auth_OpenID",
"::",
"arrayGet",
"(",
"$",
"ax_args",
",",
"'mode'",
")",
";",
"if",
"(",
"$",
"mode",
"!=",
"$",
"this",
"->",
"mode",
")",
"{",
"return",
"new",
"Auth_OpenID... | Return Auth_OpenID_AX_Error if the mode in the attribute
exchange arguments does not match what is expected for this
class; true otherwise.
@access private
@param array $ax_args
@return Auth_OpenID_AX_Error|bool | [
"Return",
"Auth_OpenID_AX_Error",
"if",
"the",
"mode",
"in",
"the",
"attribute",
"exchange",
"arguments",
"does",
"not",
"match",
"what",
"is",
"expected",
"for",
"this",
"class",
";",
"true",
"otherwise",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/AX.php#L111-L122 |
openid/php-openid | Auth/OpenID/AX.php | Auth_OpenID_AX_AttrInfo.make | static function make($type_uri, $count=1, $required=false,
$alias=null)
{
if ($alias !== null) {
$result = Auth_OpenID_AX_checkAlias($alias);
if (Auth_OpenID_AX::isError($result)) {
return $result;
}
}
return new Auth_OpenID_AX_AttrInfo($type_uri, $count, $required,
$alias);
} | php | static function make($type_uri, $count=1, $required=false,
$alias=null)
{
if ($alias !== null) {
$result = Auth_OpenID_AX_checkAlias($alias);
if (Auth_OpenID_AX::isError($result)) {
return $result;
}
}
return new Auth_OpenID_AX_AttrInfo($type_uri, $count, $required,
$alias);
} | [
"static",
"function",
"make",
"(",
"$",
"type_uri",
",",
"$",
"count",
"=",
"1",
",",
"$",
"required",
"=",
"false",
",",
"$",
"alias",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"alias",
"!==",
"null",
")",
"{",
"$",
"result",
"=",
"Auth_OpenID_AX_che... | Construct an attribute information object. For parameter
details, see the constructor.
@param string $type_uri
@param int $count
@param bool $required
@param string|null $alias
@return Auth_OpenID_AX_AttrInfo|Auth_OpenID_AX_Error|bool | [
"Construct",
"an",
"attribute",
"information",
"object",
".",
"For",
"parameter",
"details",
"see",
"the",
"constructor",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/AX.php#L205-L218 |
openid/php-openid | Auth/OpenID/AX.php | Auth_OpenID_AX_FetchRequest.add | function add($attribute)
{
if ($this->contains($attribute->type_uri)) {
return new Auth_OpenID_AX_Error(
sprintf("The attribute %s has already been requested",
$attribute->type_uri));
}
$this->requested_attributes[$attribute->type_uri] = $attribute;
return true;
} | php | function add($attribute)
{
if ($this->contains($attribute->type_uri)) {
return new Auth_OpenID_AX_Error(
sprintf("The attribute %s has already been requested",
$attribute->type_uri));
}
$this->requested_attributes[$attribute->type_uri] = $attribute;
return true;
} | [
"function",
"add",
"(",
"$",
"attribute",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"contains",
"(",
"$",
"attribute",
"->",
"type_uri",
")",
")",
"{",
"return",
"new",
"Auth_OpenID_AX_Error",
"(",
"sprintf",
"(",
"\"The attribute %s has already been requested\"",... | Add an attribute to this attribute exchange request.
@param attribute: The attribute that is being requested
@return bool|Auth_OpenID_AX_Error | [
"Add",
"an",
"attribute",
"to",
"this",
"attribute",
"exchange",
"request",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/AX.php#L311-L322 |
openid/php-openid | Auth/OpenID/AX.php | Auth_OpenID_AX_FetchRequest.getExtensionArgs | function getExtensionArgs($request = null)
{
$aliases = new Auth_OpenID_NamespaceMap();
$required = array();
$if_available = array();
$ax_args = $this->_newArgs();
foreach ($this->requested_attributes as $type_uri => $attribute) {
if ($attribute->alias === null) {
$alias = $aliases->add($type_uri);
} else {
$alias = $aliases->addAlias($type_uri, $attribute->alias);
if ($alias === null) {
return new Auth_OpenID_AX_Error(
sprintf("Could not add alias %s for URI %s",
$attribute->alias, $type_uri
));
}
}
if ($attribute->required) {
$required[] = $alias;
} else {
$if_available[] = $alias;
}
if ($attribute->count != 1) {
$ax_args['count.' . $alias] = strval($attribute->count);
}
$ax_args['type.' . $alias] = $type_uri;
}
if ($required) {
$ax_args['required'] = implode(',', $required);
}
if ($if_available) {
$ax_args['if_available'] = implode(',', $if_available);
}
return $ax_args;
} | php | function getExtensionArgs($request = null)
{
$aliases = new Auth_OpenID_NamespaceMap();
$required = array();
$if_available = array();
$ax_args = $this->_newArgs();
foreach ($this->requested_attributes as $type_uri => $attribute) {
if ($attribute->alias === null) {
$alias = $aliases->add($type_uri);
} else {
$alias = $aliases->addAlias($type_uri, $attribute->alias);
if ($alias === null) {
return new Auth_OpenID_AX_Error(
sprintf("Could not add alias %s for URI %s",
$attribute->alias, $type_uri
));
}
}
if ($attribute->required) {
$required[] = $alias;
} else {
$if_available[] = $alias;
}
if ($attribute->count != 1) {
$ax_args['count.' . $alias] = strval($attribute->count);
}
$ax_args['type.' . $alias] = $type_uri;
}
if ($required) {
$ax_args['required'] = implode(',', $required);
}
if ($if_available) {
$ax_args['if_available'] = implode(',', $if_available);
}
return $ax_args;
} | [
"function",
"getExtensionArgs",
"(",
"$",
"request",
"=",
"null",
")",
"{",
"$",
"aliases",
"=",
"new",
"Auth_OpenID_NamespaceMap",
"(",
")",
";",
"$",
"required",
"=",
"array",
"(",
")",
";",
"$",
"if_available",
"=",
"array",
"(",
")",
";",
"$",
"ax_... | Get the serialized form of this attribute fetch request.
@param Auth_OpenID_Request|null $request
@return Auth_OpenID_AX_Error|Auth_OpenID_AX_FetchRequest The fetch request message parameters | [
"Get",
"the",
"serialized",
"form",
"of",
"this",
"attribute",
"fetch",
"request",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/AX.php#L330-L375 |
openid/php-openid | Auth/OpenID/AX.php | Auth_OpenID_AX_FetchRequest.getRequiredAttrs | function getRequiredAttrs()
{
$required = array();
foreach ($this->requested_attributes as $type_uri => $attribute) {
if ($attribute->required) {
$required[] = $type_uri;
}
}
return $required;
} | php | function getRequiredAttrs()
{
$required = array();
foreach ($this->requested_attributes as $type_uri => $attribute) {
if ($attribute->required) {
$required[] = $type_uri;
}
}
return $required;
} | [
"function",
"getRequiredAttrs",
"(",
")",
"{",
"$",
"required",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"requested_attributes",
"as",
"$",
"type_uri",
"=>",
"$",
"attribute",
")",
"{",
"if",
"(",
"$",
"attribute",
"->",
"required"... | Get the type URIs for all attributes that have been marked as
required.
@return array A list of the type URIs for attributes that have been
marked as required. | [
"Get",
"the",
"type",
"URIs",
"for",
"all",
"attributes",
"that",
"have",
"been",
"marked",
"as",
"required",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/AX.php#L384-L394 |
openid/php-openid | Auth/OpenID/AX.php | Auth_OpenID_AX_FetchRequest.fromOpenIDRequest | static function fromOpenIDRequest($request)
{
$m = $request->message;
$obj = new Auth_OpenID_AX_FetchRequest();
$ax_args = $m->getArgs($obj->ns_uri);
$result = $obj->parseExtensionArgs($ax_args);
if (Auth_OpenID_AX::isError($result)) {
return $result;
}
if ($obj->update_url) {
// Update URL must match the openid.realm of the
// underlying OpenID 2 message.
$realm = $m->getArg(Auth_OpenID_OPENID_NS, 'realm',
$m->getArg(
Auth_OpenID_OPENID_NS,
'return_to'));
if (!$realm) {
$obj = new Auth_OpenID_AX_Error(
sprintf("Cannot validate update_url %s " .
"against absent realm", $obj->update_url));
} else if (!Auth_OpenID_TrustRoot::match($realm,
$obj->update_url)) {
$obj = new Auth_OpenID_AX_Error(
sprintf("Update URL %s failed validation against realm %s",
$obj->update_url, $realm));
}
}
return $obj;
} | php | static function fromOpenIDRequest($request)
{
$m = $request->message;
$obj = new Auth_OpenID_AX_FetchRequest();
$ax_args = $m->getArgs($obj->ns_uri);
$result = $obj->parseExtensionArgs($ax_args);
if (Auth_OpenID_AX::isError($result)) {
return $result;
}
if ($obj->update_url) {
// Update URL must match the openid.realm of the
// underlying OpenID 2 message.
$realm = $m->getArg(Auth_OpenID_OPENID_NS, 'realm',
$m->getArg(
Auth_OpenID_OPENID_NS,
'return_to'));
if (!$realm) {
$obj = new Auth_OpenID_AX_Error(
sprintf("Cannot validate update_url %s " .
"against absent realm", $obj->update_url));
} else if (!Auth_OpenID_TrustRoot::match($realm,
$obj->update_url)) {
$obj = new Auth_OpenID_AX_Error(
sprintf("Update URL %s failed validation against realm %s",
$obj->update_url, $realm));
}
}
return $obj;
} | [
"static",
"function",
"fromOpenIDRequest",
"(",
"$",
"request",
")",
"{",
"$",
"m",
"=",
"$",
"request",
"->",
"message",
";",
"$",
"obj",
"=",
"new",
"Auth_OpenID_AX_FetchRequest",
"(",
")",
";",
"$",
"ax_args",
"=",
"$",
"m",
"->",
"getArgs",
"(",
"$... | Extract a FetchRequest from an OpenID message
@param Auth_OpenID_Request $request The OpenID request containing the attribute fetch request
@return Auth_OpenID_AX_FetchRequest|Auth_OpenID_AX_Error | [
"Extract",
"a",
"FetchRequest",
"from",
"an",
"OpenID",
"message"
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/AX.php#L403-L436 |
openid/php-openid | Auth/OpenID/AX.php | Auth_OpenID_AX_FetchRequest.parseExtensionArgs | function parseExtensionArgs($ax_args)
{
$result = $this->_checkMode($ax_args);
if (Auth_OpenID_AX::isError($result)) {
return $result;
}
$aliases = new Auth_OpenID_NamespaceMap();
foreach ($ax_args as $key => $value) {
if (strpos($key, 'type.') === 0) {
$alias = substr($key, 5);
$type_uri = $value;
$alias = $aliases->addAlias($type_uri, $alias);
if ($alias === null) {
return new Auth_OpenID_AX_Error(
sprintf("Could not add alias %s for URI %s",
$alias, $type_uri)
);
}
$count_s = Auth_OpenID::arrayGet($ax_args, 'count.' . $alias);
if ($count_s) {
$count = Auth_OpenID::intval($count_s);
if (($count === false) &&
($count_s === Auth_OpenID_AX_UNLIMITED_VALUES)) {
$count = $count_s;
}
} else {
$count = 1;
}
if ($count === false) {
return new Auth_OpenID_AX_Error(
sprintf("Integer value expected for %s, got %s",
'count.' . $alias, $count_s));
}
$attrinfo = Auth_OpenID_AX_AttrInfo::make($type_uri, $count,
false, $alias);
if (Auth_OpenID_AX::isError($attrinfo)) {
return $attrinfo;
}
$this->add($attrinfo);
}
}
$required = Auth_OpenID_AX_toTypeURIs($aliases,
Auth_OpenID::arrayGet($ax_args, 'required'));
foreach ($required as $type_uri) {
$attrib = $this->requested_attributes[$type_uri];
$attrib->required = true;
}
$if_available = Auth_OpenID_AX_toTypeURIs($aliases,
Auth_OpenID::arrayGet($ax_args, 'if_available'));
$all_type_uris = array_merge($required, $if_available);
foreach ($aliases->iterNamespaceURIs() as $type_uri) {
if (!in_array($type_uri, $all_type_uris)) {
return new Auth_OpenID_AX_Error(
sprintf('Type URI %s was in the request but not ' .
'present in "required" or "if_available"',
$type_uri));
}
}
$this->update_url = Auth_OpenID::arrayGet($ax_args, 'update_url');
return true;
} | php | function parseExtensionArgs($ax_args)
{
$result = $this->_checkMode($ax_args);
if (Auth_OpenID_AX::isError($result)) {
return $result;
}
$aliases = new Auth_OpenID_NamespaceMap();
foreach ($ax_args as $key => $value) {
if (strpos($key, 'type.') === 0) {
$alias = substr($key, 5);
$type_uri = $value;
$alias = $aliases->addAlias($type_uri, $alias);
if ($alias === null) {
return new Auth_OpenID_AX_Error(
sprintf("Could not add alias %s for URI %s",
$alias, $type_uri)
);
}
$count_s = Auth_OpenID::arrayGet($ax_args, 'count.' . $alias);
if ($count_s) {
$count = Auth_OpenID::intval($count_s);
if (($count === false) &&
($count_s === Auth_OpenID_AX_UNLIMITED_VALUES)) {
$count = $count_s;
}
} else {
$count = 1;
}
if ($count === false) {
return new Auth_OpenID_AX_Error(
sprintf("Integer value expected for %s, got %s",
'count.' . $alias, $count_s));
}
$attrinfo = Auth_OpenID_AX_AttrInfo::make($type_uri, $count,
false, $alias);
if (Auth_OpenID_AX::isError($attrinfo)) {
return $attrinfo;
}
$this->add($attrinfo);
}
}
$required = Auth_OpenID_AX_toTypeURIs($aliases,
Auth_OpenID::arrayGet($ax_args, 'required'));
foreach ($required as $type_uri) {
$attrib = $this->requested_attributes[$type_uri];
$attrib->required = true;
}
$if_available = Auth_OpenID_AX_toTypeURIs($aliases,
Auth_OpenID::arrayGet($ax_args, 'if_available'));
$all_type_uris = array_merge($required, $if_available);
foreach ($aliases->iterNamespaceURIs() as $type_uri) {
if (!in_array($type_uri, $all_type_uris)) {
return new Auth_OpenID_AX_Error(
sprintf('Type URI %s was in the request but not ' .
'present in "required" or "if_available"',
$type_uri));
}
}
$this->update_url = Auth_OpenID::arrayGet($ax_args, 'update_url');
return true;
} | [
"function",
"parseExtensionArgs",
"(",
"$",
"ax_args",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"_checkMode",
"(",
"$",
"ax_args",
")",
";",
"if",
"(",
"Auth_OpenID_AX",
"::",
"isError",
"(",
"$",
"result",
")",
")",
"{",
"return",
"$",
"result... | Given attribute exchange arguments, populate this FetchRequest.
@param array $ax_args
@return Auth_OpenID_AX_Error|bool if the data to be parsed
does not follow the attribute exchange specification. At least
when 'if_available' or 'required' is not specified for a
particular attribute type. Returns true otherwise. | [
"Given",
"attribute",
"exchange",
"arguments",
"populate",
"this",
"FetchRequest",
"."
] | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/AX.php#L447-L524 |
openid/php-openid | Auth/OpenID/AX.php | Auth_OpenID_AX_KeyValueMessage.addValue | function addValue($type_uri, $value)
{
if (!array_key_exists($type_uri, $this->data)) {
$this->data[$type_uri] = array();
}
$values =& $this->data[$type_uri];
$values[] = $value;
} | php | function addValue($type_uri, $value)
{
if (!array_key_exists($type_uri, $this->data)) {
$this->data[$type_uri] = array();
}
$values =& $this->data[$type_uri];
$values[] = $value;
} | [
"function",
"addValue",
"(",
"$",
"type_uri",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"type_uri",
",",
"$",
"this",
"->",
"data",
")",
")",
"{",
"$",
"this",
"->",
"data",
"[",
"$",
"type_uri",
"]",
"=",
"array",
... | Add a single value for the given attribute type to the
message. If there are already values specified for this type,
this value will be sent in addition to the values already
specified.
@param type_uri: The URI for the attribute
@param value: The value to add to the response to the relying
party for this attribute | [
"Add",
"a",
"single",
"value",
"for",
"the",
"given",
"attribute",
"type",
"to",
"the",
"message",
".",
"If",
"there",
"are",
"already",
"values",
"specified",
"for",
"this",
"type",
"this",
"value",
"will",
"be",
"sent",
"in",
"addition",
"to",
"the",
"... | train | https://github.com/openid/php-openid/blob/99d24177dbad21d13878ac653bbfb1ed18b66114/Auth/OpenID/AX.php#L574-L582 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.