FOSSology  4.4.0
Open Source License Compliance by Open Source Software
Fossology\UI\Api\Helper\RestHelper Class Reference

Provides various DAO helper functions for REST api. More...

Collaboration diagram for Fossology\UI\Api\Helper\RestHelper:
Collaboration graph

Public Member Functions

 __construct (UploadPermissionDao $uploadPermissionDao, UploadDao $uploadDao, UserDao $userDao, FolderDao $folderDao, DbHelper $dbHelper, AuthHelper $authHelper, JobDao $jobDao, ShowJobsDao $showJobDao)
 RestHelper constructor. More...
 
 getUserId ()
 
 getGroupId ()
 
 getUploadDao ()
 
 getUserDao ()
 
 getFolderDao ()
 
 getUploadPermissionDao ()
 
 getAuthHelper ()
 
 getDbHelper ()
 
 getJobDao ()
 
 getShowJobDao ()
 
 getPlugin ($pluginName)
 A safe wrapper around plugin_find. More...
 
 validateTokenRequest ($tokenExpire, $tokenName, $tokenScope)
 Check if the token request contains valid parameters. More...
 
 validateNewOauthClient ($userId, $clientName, $clientScope, $clientId)
 Check if the new oauth client is valid. More...
 

Public Attributes

const VALID_SCOPES = ["read", "write"]
 
const SCOPE_DB_MAP = ["read" => "r", "write" => "w"]
 
const TOKEN_KEY_LENGTH = 40
 

Private Attributes

 $uploadDao
 
 $dbHelper
 
 $uploadPermissionDao
 
 $folderDao
 
 $userDao
 
 $jobDao
 
 $showJobDao
 
 $authHelper
 

Detailed Description

Provides various DAO helper functions for REST api.

Definition at line 31 of file RestHelper.php.

Constructor & Destructor Documentation

◆ __construct()

Fossology\UI\Api\Helper\RestHelper::__construct ( UploadPermissionDao  $uploadPermissionDao,
UploadDao  $uploadDao,
UserDao  $userDao,
FolderDao  $folderDao,
DbHelper  $dbHelper,
AuthHelper  $authHelper,
JobDao  $jobDao,
ShowJobsDao  $showJobDao 
)

RestHelper constructor.

This constructor initialize all the members

Definition at line 94 of file RestHelper.php.

Member Function Documentation

◆ getAuthHelper()

Fossology\UI\Api\Helper\RestHelper::getAuthHelper ( )
Returns
AuthHelper

Definition at line 162 of file RestHelper.php.

◆ getDbHelper()

Fossology\UI\Api\Helper\RestHelper::getDbHelper ( )
Returns
DbHelper

Definition at line 170 of file RestHelper.php.

◆ getFolderDao()

Fossology\UI\Api\Helper\RestHelper::getFolderDao ( )
Returns
FolderDao

Definition at line 146 of file RestHelper.php.

◆ getGroupId()

Fossology\UI\Api\Helper\RestHelper::getGroupId ( )
Returns
integer Current group id

Definition at line 121 of file RestHelper.php.

◆ getJobDao()

Fossology\UI\Api\Helper\RestHelper::getJobDao ( )
Returns
JobDao

Definition at line 178 of file RestHelper.php.

◆ getPlugin()

Fossology\UI\Api\Helper\RestHelper::getPlugin (   $pluginName)

A safe wrapper around plugin_find.

Get the FOSSology plugin from the plugin array.

Parameters
string$pluginNameThe required plugin
Returns
Plugin The required plugin if found, else throws an exception.
Exceptions

Definition at line 239 of file RestHelper.php.

◆ getShowJobDao()

Fossology\UI\Api\Helper\RestHelper::getShowJobDao ( )
Returns
ShowJobsDao

Definition at line 186 of file RestHelper.php.

◆ getUploadDao()

Fossology\UI\Api\Helper\RestHelper::getUploadDao ( )
Returns
UploadDao

Definition at line 130 of file RestHelper.php.

◆ getUploadPermissionDao()

Fossology\UI\Api\Helper\RestHelper::getUploadPermissionDao ( )
Returns
UploadPermissionDao

Definition at line 154 of file RestHelper.php.

◆ getUserDao()

Fossology\UI\Api\Helper\RestHelper::getUserDao ( )
Returns
UserDao

Definition at line 138 of file RestHelper.php.

◆ getUserId()

Fossology\UI\Api\Helper\RestHelper::getUserId ( )
Returns
integer Current user id

Definition at line 112 of file RestHelper.php.

◆ validateNewOauthClient()

Fossology\UI\Api\Helper\RestHelper::validateNewOauthClient (   $userId,
  $clientName,
  $clientScope,
  $clientId 
)

Check if the new oauth client is valid.

The function checks for following properties:

  • The length of client name should be between 0 and 40.
  • The scope of client should be valid.
  • Same client should not exist for the user.
Parameters
integer$userIdUser id
string$clientNameThe name of the new client.
string$clientScopeThe scope of the new client.
string$clientIdNew client id.
Returns
void
Exceptions
HttpBadRequestExceptionIf request is invalid.

Definition at line 300 of file RestHelper.php.

◆ validateTokenRequest()

Fossology\UI\Api\Helper\RestHelper::validateTokenRequest (   $tokenExpire,
  $tokenName,
  $tokenScope 
)

Check if the token request contains valid parameters.

The function checks for following properties:

  • The format of expiry parameter should be YYYY-MM-DD and should be +1 from now().
  • The length of token name should be between 0 and 40.
  • The scope of token should be valid.
Parameters
string$tokenExpireThe expiry of token requested.
string$tokenNameThe name of the token requested.
string$tokenScopeThe scope of the token requested.
Returns
void
Exceptions
HttpBadRequestExceptionIf request is invalid.

Definition at line 264 of file RestHelper.php.

Member Data Documentation

◆ $authHelper

AuthHelper Fossology\UI\Api\Helper\RestHelper::$authHelper
private

Auth helper to provide authentication

Definition at line 87 of file RestHelper.php.

◆ $dbHelper

DbHelper Fossology\UI\Api\Helper\RestHelper::$dbHelper
private

DB helper object

Definition at line 57 of file RestHelper.php.

◆ $folderDao

FolderDao Fossology\UI\Api\Helper\RestHelper::$folderDao
private

Folder DAO object

Definition at line 67 of file RestHelper.php.

◆ $jobDao

JobDao Fossology\UI\Api\Helper\RestHelper::$jobDao
private

Job DAO object

Definition at line 77 of file RestHelper.php.

◆ $showJobDao

ShowJobsDao Fossology\UI\Api\Helper\RestHelper::$showJobDao
private

Show job DAO object

Definition at line 82 of file RestHelper.php.

◆ $uploadDao

UploadDao Fossology\UI\Api\Helper\RestHelper::$uploadDao
private

Upload DAO object

Definition at line 52 of file RestHelper.php.

◆ $uploadPermissionDao

UploadPermissionDao Fossology\UI\Api\Helper\RestHelper::$uploadPermissionDao
private

Upload permission DAO object

Definition at line 62 of file RestHelper.php.

◆ $userDao

UserDao Fossology\UI\Api\Helper\RestHelper::$userDao
private

User DAO object

Definition at line 72 of file RestHelper.php.

◆ SCOPE_DB_MAP

array Fossology\UI\Api\Helper\RestHelper::SCOPE_DB_MAP = ["read" => "r", "write" => "w"]

Maps a user readable scope to DB value.

Definition at line 42 of file RestHelper.php.

◆ TOKEN_KEY_LENGTH

int Fossology\UI\Api\Helper\RestHelper::TOKEN_KEY_LENGTH = 40

Length of the token secret key.

Definition at line 47 of file RestHelper.php.

◆ VALID_SCOPES

array Fossology\UI\Api\Helper\RestHelper::VALID_SCOPES = ["read", "write"]

Valid scopes for REST authentication tokens.

Definition at line 37 of file RestHelper.php.


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