- * @package OMB
- * @author Adrian Lang <mail@adrianlang.de>
- * @copyright 2009 Adrian Lang
- * @license http://www.gnu.org/licenses/agpl.html GNU AGPL 3.0
- **/
-
-class OMB_Service_Provider {
- protected $user; /* An OMB_Profile representing the user */
- protected $datastore; /* AN OMB_Datastore */
-
- protected $remote_user; /* An OMB_Profile representing the remote user during
- the authorization process */
-
- protected $oauth_server; /* An OAuthServer; should only be accessed via
- getOAuthServer. */
-
- /**
- * Initialize an OMB_Service_Provider object
- *
- * Constructs an OMB_Service_Provider instance that provides OMB services
- * referring to a particular user.
- *
- * @param OMB_Profile $user An OMB_Profile; mandatory for XRDS
- * output, user auth handling and OMB
- * action performing
- * @param OMB_Datastore $datastore An OMB_Datastore; mandatory for
- * everything but XRDS output
- * @param OAuthServer $oauth_server An OAuthServer; used for token writing
- * and OMB action handling; will use
- * default value if not set
- *
- * @access public
- **/
- public function __construct ($user = null, $datastore = null, $oauth_server = null) {
- $this->user = $user;
- $this->datastore = $datastore;
- $this->oauth_server = $oauth_server;
- }
-
- public function getRemoteUser() {
- return $this->remote_user;
- }
-
- /**
- * Write a XRDS document
- *
- * Writes a XRDS document specifying the OMB service. Optionally uses a
- * given object of a class implementing OMB_XRDS_Writer for output. Else
- * OMB_Plain_XRDS_Writer is used.
- *
- * @param OMB_XRDS_Mapper $xrds_mapper An object mapping actions to URLs
- * @param OMB_XRDS_Writer $xrds_writer Optional; The OMB_XRDS_Writer used to
- * write the XRDS document
- *
- * @access public
- *
- * @return mixed Depends on the used OMB_XRDS_Writer; OMB_Plain_XRDS_Writer
- * returns nothing.
- **/
- public function writeXRDS($xrds_mapper, $xrds_writer = null) {
- if ($xrds_writer == null) {
- require_once 'plain_xrds_writer.php';
- $xrds_writer = new OMB_Plain_XRDS_Writer();
- }
- return $xrds_writer->writeXRDS($this->user, $xrds_mapper);
- }
-
- /**
- * Echo a request token
- *
- * Outputs an unauthorized request token for the query found in $_GET or
- * $_POST.
- *
- * @access public
- **/
- public function writeRequestToken() {
- OMB_Helper::removeMagicQuotesFromRequest();
- echo $this->getOAuthServer()->fetch_request_token(OAuthRequest::from_request());
- }
-
- /**
- * Handle an user authorization request.
- *
- * Parses an authorization request. This includes OAuth and OMB verification.
- * Throws exceptions on failures. Returns an OMB_Profile object representing
- * the remote user.
- *
- * The OMB_Profile passed to the constructor of OMB_Service_Provider should
- * not represent the user specified in the authorization request, but the one
- * currently logged in to the service. This condition being satisfied,
- * handleUserAuth will check whether the listener specified in the request is
- * identical to the logged in user.
- *
- * @access public
- *
- * @return OMB_Profile The profile of the soon-to-be subscribed, i. e. remote
- * user
- **/
- public function handleUserAuth() {
- OMB_Helper::removeMagicQuotesFromRequest();
-
- /* Verify the request token. */
-
- $this->token = $this->datastore->lookup_token(null, "request", $_GET['oauth_token']);
- if (is_null($this->token)) {
- throw new OAuthException('The given request token has not been issued ' .
- 'by this service.');
+ * @package OMB
+ * @author Adrian Lang <mail@adrianlang.de>
+ * @license http://www.gnu.org/licenses/agpl.html GNU AGPL 3.0
+ * @version 0.1a-20090828
+ * @link http://adrianlang.de/libomb
+ */
+
+require_once 'constants.php';
+require_once 'helper.php';
+require_once 'notice.php';
+require_once 'remoteserviceexception.php';
+
+/**
+ * OMB service realization
+ *
+ * This class realizes a complete, simple OMB service.
+ */
+class OMB_Service_Provider
+{
+ protected $user; /* An OMB_Profile representing the user */
+ protected $datastore; /* AN OMB_Datastore */
+
+ protected $remote_user; /* An OMB_Profile representing the remote user
+ during the authorization process */
+
+ protected $oauth_server; /* An OAuthServer; should only be accessed via
+ getOAuthServer. */
+
+ /**
+ * Initialize an OMB_Service_Provider object
+ *
+ * Constructs an OMB_Service_Provider instance that provides OMB services
+ * referring to a particular user.
+ *
+ * @param OMB_Profile $user An OMB_Profile; mandatory for XRDS
+ * output, user auth handling and OMB
+ * action performing
+ * @param OMB_Datastore $datastore An OMB_Datastore; mandatory for
+ * everything but XRDS output
+ * @param OAuthServer $oauth_server An OAuthServer; used for token writing
+ * and OMB action handling; will use
+ * default value if not set
+ *
+ * @access public
+ */
+ public function __construct ($user = null, $datastore = null,
+ $oauth_server = null)
+ {
+ $this->user = $user;
+ $this->datastore = $datastore;
+ $this->oauth_server = $oauth_server;