ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
OAuthServer Class Reference
+ Collaboration diagram for OAuthServer:

Public Member Functions

 __construct ($data_store)
 
 add_signature_method ($signature_method)
 
 fetch_request_token (&$request)
 process a request_token request returns the request token on success More...
 
 fetch_access_token (&$request)
 process an access_token request returns the access token on success More...
 
 verify_request (&$request)
 verify an api call, checks all the parameters More...
 

Protected Attributes

 $timestamp_threshold = 300
 
 $version = 1.0
 
 $signature_methods = array()
 
 $data_store
 

Private Member Functions

 get_version (&$request)
 version 1 More...
 
 get_signature_method (&$request)
 figure out the signature with some defaults More...
 
 get_consumer (&$request)
 try to find the consumer for the provided request's consumer key More...
 
 get_token (&$request, $consumer, $token_type="access")
 try to find the token for the provided request's token key More...
 
 check_signature (&$request, $consumer, $token)
 all-in-one function to check the signature on a request should guess the signature method appropriately More...
 
 check_timestamp ($timestamp)
 check that the timestamp is new enough More...
 
 check_nonce ($consumer, $token, $nonce, $timestamp)
 check that the nonce is not repeated More...
 

Detailed Description

Definition at line 494 of file OAuth.php.

Constructor & Destructor Documentation

◆ __construct()

OAuthServer::__construct (   $data_store)

Definition at line 502 of file OAuth.php.

503 {
504 $this->data_store = $data_store;
505 }

References $data_store.

Member Function Documentation

◆ add_signature_method()

OAuthServer::add_signature_method (   $signature_method)

Definition at line 507 of file OAuth.php.

508 {
509 $this->signature_methods[$signature_method->get_name()] =
510 $signature_method;
511 }

◆ check_nonce()

OAuthServer::check_nonce (   $consumer,
  $token,
  $nonce,
  $timestamp 
)
private

check that the nonce is not repeated

Definition at line 699 of file OAuth.php.

700 {
701 // verify that the nonce is uniqueish
702 $found = $this->data_store->lookup_nonce(
703 $consumer,
704 $token,
705 $nonce,
707 );
708 if ($found) {
709 throw new OAuthException("Nonce already used: $nonce");
710 }
711 }
foreach($mandatory_scripts as $file) $timestamp
Definition: buildRTE.php:81
$token
Definition: xapitoken.php:57

References $timestamp, and $token.

Referenced by check_signature().

+ Here is the caller graph for this function:

◆ check_signature()

OAuthServer::check_signature ( $request,
  $consumer,
  $token 
)
private

all-in-one function to check the signature on a request should guess the signature method appropriately

Definition at line 651 of file OAuth.php.

652 {
653 // this should probably be in a different method
656
657 $timestamp = @$request->get_parameter('oauth_timestamp');
658 $nonce = @$request->get_parameter('oauth_nonce');
659
661 $this->check_nonce($consumer, $token, $nonce, $timestamp);
662
663 $signature_method = $this->get_signature_method($request);
664
665 $signature = $request->get_parameter('oauth_signature');
666 $valid_sig = $signature_method->check_signature(
667 $request,
668 $consumer,
669 $token,
670 $signature
671 );
672
673 if (!$valid_sig) {
674 $ex_text = "Invalid signature";
676 $ex_text = $ex_text . " ours= $OAuth_last_computed_signature yours=$signature";
677 }
678 throw new OAuthException($ex_text);
679 }
680 }
$OAuth_last_computed_signature
http://oauth.googlecode.com/svn/code/php/
Definition: OAuth.php:8
check_nonce($consumer, $token, $nonce, $timestamp)
check that the nonce is not repeated
Definition: OAuth.php:699
check_timestamp($timestamp)
check that the timestamp is new enough
Definition: OAuth.php:685
get_signature_method(&$request)
figure out the signature with some defaults
Definition: OAuth.php:589

References $OAuth_last_computed_signature, $timestamp, $token, check_nonce(), check_timestamp(), and get_signature_method().

Referenced by fetch_access_token(), fetch_request_token(), and verify_request().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ check_timestamp()

OAuthServer::check_timestamp (   $timestamp)
private

check that the timestamp is new enough

Definition at line 685 of file OAuth.php.

686 {
687 // verify that timestamp is recentish
688 $now = time();
689 if ($now - $timestamp > $this->timestamp_threshold) {
690 throw new OAuthException(
691 "Expired timestamp, yours $timestamp, ours $now"
692 );
693 }
694 }

References $timestamp.

Referenced by check_signature().

+ Here is the caller graph for this function:

◆ fetch_access_token()

OAuthServer::fetch_access_token ( $request)

process an access_token request returns the access token on success

Definition at line 539 of file OAuth.php.

540 {
541 $this->get_version($request);
542
543 $consumer = $this->get_consumer($request);
544
545 // requires authorized request token
546 $token = $this->get_token($request, $consumer, "request");
547
548
549 $this->check_signature($request, $consumer, $token);
550
551 $new_token = $this->data_store->new_access_token($token, $consumer);
552
553 return $new_token;
554 }
check_signature(&$request, $consumer, $token)
all-in-one function to check the signature on a request should guess the signature method appropriate...
Definition: OAuth.php:651
get_token(&$request, $consumer, $token_type="access")
try to find the token for the provided request's token key
Definition: OAuth.php:630
get_consumer(&$request)
try to find the consumer for the provided request's consumer key
Definition: OAuth.php:612
get_version(&$request)
version 1
Definition: OAuth.php:574

References $token, check_signature(), get_consumer(), get_token(), and get_version().

+ Here is the call graph for this function:

◆ fetch_request_token()

OAuthServer::fetch_request_token ( $request)

process a request_token request returns the request token on success

Definition at line 519 of file OAuth.php.

520 {
521 $this->get_version($request);
522
523 $consumer = $this->get_consumer($request);
524
525 // no token required for the initial token request
526 $token = null;
527
528 $this->check_signature($request, $consumer, $token);
529
530 $new_token = $this->data_store->new_request_token($consumer);
531
532 return $new_token;
533 }

References $token, check_signature(), get_consumer(), and get_version().

+ Here is the call graph for this function:

◆ get_consumer()

OAuthServer::get_consumer ( $request)
private

try to find the consumer for the provided request's consumer key

Definition at line 612 of file OAuth.php.

613 {
614 $consumer_key = @$request->get_parameter("oauth_consumer_key");
615 if (!$consumer_key) {
616 throw new OAuthException("Invalid consumer key");
617 }
618
619 $consumer = $this->data_store->lookup_consumer($consumer_key);
620 if (!$consumer) {
621 throw new OAuthException("Invalid consumer");
622 }
623
624 return $consumer;
625 }

Referenced by fetch_access_token(), fetch_request_token(), and verify_request().

+ Here is the caller graph for this function:

◆ get_signature_method()

OAuthServer::get_signature_method ( $request)
private

figure out the signature with some defaults

Definition at line 589 of file OAuth.php.

590 {
591 $signature_method =
592 @$request->get_parameter("oauth_signature_method");
593 if (!$signature_method) {
594 $signature_method = "PLAINTEXT";
595 }
596 if (!in_array(
597 $signature_method,
598 array_keys($this->signature_methods)
599 )) {
600 throw new OAuthException(
601 "Signature method '$signature_method' not supported " .
602 "try one of the following: " .
603 implode(", ", array_keys($this->signature_methods))
604 );
605 }
606 return $this->signature_methods[$signature_method];
607 }

Referenced by check_signature().

+ Here is the caller graph for this function:

◆ get_token()

OAuthServer::get_token ( $request,
  $consumer,
  $token_type = "access" 
)
private

try to find the token for the provided request's token key

Definition at line 630 of file OAuth.php.

631 {
632 $token_field = @$request->get_parameter('oauth_token');
633 if (!$token_field) {
634 return false;
635 }
636 $token = $this->data_store->lookup_token(
637 $consumer,
638 $token_type,
639 $token_field
640 );
641 if (!$token) {
642 throw new OAuthException("Invalid $token_type token: $token_field");
643 }
644 return $token;
645 }

References $token.

Referenced by fetch_access_token(), and verify_request().

+ Here is the caller graph for this function:

◆ get_version()

OAuthServer::get_version ( $request)
private

version 1

Definition at line 574 of file OAuth.php.

575 {
576 $version = $request->get_parameter("oauth_version");
577 if (!$version) {
578 $version = 1.0;
579 }
580 if ($version && $version != $this->version) {
581 throw new OAuthException("OAuth version '$version' not supported");
582 }
583 return $version;
584 }

References $version.

Referenced by fetch_access_token(), fetch_request_token(), and verify_request().

+ Here is the caller graph for this function:

◆ verify_request()

OAuthServer::verify_request ( $request)

verify an api call, checks all the parameters

Definition at line 559 of file OAuth.php.

560 {
563 $this->get_version($request);
564 $consumer = $this->get_consumer($request);
565 $token = $this->get_token($request, $consumer, "access");
566 $this->check_signature($request, $consumer, $token);
567 return array($consumer, $token);
568 }

References $OAuth_last_computed_signature, $token, check_signature(), get_consumer(), get_token(), and get_version().

+ Here is the call graph for this function:

Field Documentation

◆ $data_store

OAuthServer::$data_store
protected

Definition at line 500 of file OAuth.php.

Referenced by __construct().

◆ $signature_methods

OAuthServer::$signature_methods = array()
protected

Definition at line 498 of file OAuth.php.

◆ $timestamp_threshold

OAuthServer::$timestamp_threshold = 300
protected

Definition at line 496 of file OAuth.php.

◆ $version

OAuthServer::$version = 1.0
protected

Definition at line 497 of file OAuth.php.

Referenced by get_version().


The documentation for this class was generated from the following file: