webfingerresource.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * WebFinger resource parent class
  4. *
  5. * @package GNUsocial
  6. * @author Mikael Nordfeldth
  7. * @copyright 2013 Free Software Foundation, Inc.
  8. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
  9. * @link http://status.net/
  10. */
  11. abstract class WebFingerResource
  12. {
  13. protected $identities = array();
  14. protected $object = null;
  15. protected $type = null;
  16. public function __construct(Managed_DataObject $object)
  17. {
  18. $this->object = $object;
  19. }
  20. public function getObject()
  21. {
  22. if ($this->object === null) {
  23. throw new ServerException('Object is not set');
  24. }
  25. return $this->object;
  26. }
  27. public function getAliases()
  28. {
  29. $aliases = $this->object->getAliasesWithIDs();
  30. // Some sites have changed from http to https and still want
  31. // (because remote sites look for it) verify that they are still
  32. // the same identity as they were on HTTP. Should NOT be used if
  33. // you've run HTTPS all the time!
  34. if (common_config('fix', 'legacy_http')) {
  35. foreach ($aliases as $alias=>$id) {
  36. if (!strtolower(parse_url($alias, PHP_URL_SCHEME)) === 'https') {
  37. continue;
  38. }
  39. $aliases[preg_replace('/^https:/i', 'http:', $alias, 1)] = $id;
  40. }
  41. }
  42. // return a unique set of aliases by extracting only the keys
  43. return array_keys($aliases);
  44. }
  45. abstract public function updateXRD(XML_XRD $xrd);
  46. }