ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilWACToken Class Reference

Class ilWACToken. More...

+ Collaboration diagram for ilWACToken:

Public Member Functions

 __construct ($path, $client, $timestamp=null, $ttl=null)
 ilWACToken constructor. More...
 
 generateToken ()
 
 getSessionId ()
 
 setSessionId ($session_id)
 
 getTimestamp ()
 
 setTimestamp ($timestamp)
 
 getIp ()
 
 setIp ($ip)
 
 getToken ()
 
 setToken ($token)
 
 getPath ()
 
 setPath ($path)
 
 getId ()
 
 getHashedId ()
 
 setId ($id)
 
 getClient ()
 
 setClient ($client)
 
 getTTL ()
 
 setTTL ($ttl)
 
 getRawToken ()
 
 setRawToken ($raw_token)
 

Static Public Member Functions

static getSALT ()
 
static setSALT ($SALT)
 

Data Fields

const DEBUG = false
 
const TYPE_FILE = ilWACSignedPath::TYPE_FILE
 
const TYPE_FOLDER = ilWACSignedPath::TYPE_FOLDER
 

Protected Member Functions

 getSaltFilePath ()
 
 initSalt ()
 
 generateSaltFile ()
 

Static Protected Member Functions

static isDEBUG ()
 

Protected Attributes

 $session_id = ''
 
 $timestamp = 0
 
 $ip = ''
 
 $token = ''
 
 $raw_token = ''
 
 $path = ''
 
 $id = ''
 
 $client = ''
 
 $ttl = 0
 

Static Protected Attributes

static $SALT = ''
 

Detailed Description

Class ilWACToken.

Author
Fabian Schmid fs@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch
Version
1.0.0

Definition at line 10 of file class.ilWACToken.php.

Constructor & Destructor Documentation

◆ __construct()

ilWACToken::__construct (   $path,
  $client,
  $timestamp = null,
  $ttl = null 
)

ilWACToken constructor.

Parameters
$path
$client
null$timestamp

Definition at line 64 of file class.ilWACToken.php.

References $_SERVER, $client, $path, $session_id, $timestamp, $ttl, generateToken(), getPath(), ilWACSignedPath\getTokenMaxLifetimeInSeconds(), setClient(), setId(), setIp(), setPath(), setSessionId(), setTimestamp(), setTTL(), and time.

64  {
65  $this->setClient($client);
66  $this->setPath($path);
67  $session_id = session_id();
68  $this->setSessionId($session_id ? $session_id : '-');
69  if (isset($_SERVER['REMOTE_ADDR'])) {
70  $this->setIp($_SERVER['REMOTE_ADDR']);
71  }
72  $this->setTimestamp($timestamp ? $timestamp : time());
74  $this->setTTL($ttl); // since we do not know the type at this poit we choose the shorter duration for security reasons
75  $this->generateToken();
76  $this->setId($this->getPath());
77  }
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
setTimestamp($timestamp)
setSessionId($session_id)
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
static getTokenMaxLifetimeInSeconds()
setClient($client)
+ Here is the call graph for this function:

Member Function Documentation

◆ generateSaltFile()

ilWACToken::generateSaltFile ( )
protected

Definition at line 127 of file class.ilWACToken.php.

References ilWACException\DATA_DIR_NON_WRITEABLE, getSaltFilePath(), and time.

Referenced by initSalt().

127  {
128  if (is_file($this->getSaltFilePath())) {
129  unlink($this->getSaltFilePath());
130  }
131  $template = file_get_contents('./Services/WebAccessChecker/wacsalt.php.template');
132  $salt = md5(time() * rand(1000, 9999) . $this->getSaltFilePath());
133  self::setSALT($salt);
134  $template = str_replace('INSERT_SALT', $salt, $template);
135  if (is_writable(dirname($this->getSaltFilePath()))) {
136  file_put_contents($this->getSaltFilePath(), $template);
137  } else {
139  }
140  }
Class ilWACException.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ generateToken()

ilWACToken::generateToken ( )

Definition at line 88 of file class.ilWACToken.php.

References $token, array, getClient(), getTimestamp(), getTTL(), initSalt(), setRawToken(), and setToken().

Referenced by __construct().

88  {
89  $this->initSalt();
90  $token = implode('-', array(
91  self::getSALT(),
92  $this->getClient(),
93  $this->getTimestamp(),
94  $this->getTTL(),
95  ));
96  $this->setRawToken($token);
97  $token = sha1($token);
98  $this->setToken($token);
99  }
setRawToken($raw_token)
Create styles array
The data for the language used.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getClient()

ilWACToken::getClient ( )
Returns
string

Definition at line 266 of file class.ilWACToken.php.

References $client.

Referenced by generateToken().

266  {
267  return $this->client;
268  }
+ Here is the caller graph for this function:

◆ getHashedId()

ilWACToken::getHashedId ( )
Returns
string

Definition at line 234 of file class.ilWACToken.php.

234  {
235  return md5($this->id);
236  }

◆ getId()

ilWACToken::getId ( )
Returns
string

Definition at line 226 of file class.ilWACToken.php.

References $id.

226  {
227  return $this->id;
228  }

◆ getIp()

ilWACToken::getIp ( )
Returns
string

Definition at line 178 of file class.ilWACToken.php.

References $ip.

178  {
179  return $this->ip;
180  }

◆ getPath()

ilWACToken::getPath ( )
Returns
string

Definition at line 210 of file class.ilWACToken.php.

References $path.

Referenced by __construct().

210  {
211  return $this->path;
212  }
+ Here is the caller graph for this function:

◆ getRawToken()

ilWACToken::getRawToken ( )
Returns
string

Definition at line 298 of file class.ilWACToken.php.

References $raw_token.

298  {
299  return $this->raw_token;
300  }

◆ getSALT()

static ilWACToken::getSALT ( )
static
Returns
string

Definition at line 250 of file class.ilWACToken.php.

Referenced by ilWACTokenTest\testTokenGeneration().

250  {
251  return self::$SALT;
252  }
+ Here is the caller graph for this function:

◆ getSaltFilePath()

ilWACToken::getSaltFilePath ( )
protected
Returns
string

Definition at line 105 of file class.ilWACToken.php.

Referenced by generateSaltFile(), and initSalt().

105  {
106  $salt_file = './data/wacsalt.php';
107 
108  return $salt_file;
109  }
+ Here is the caller graph for this function:

◆ getSessionId()

ilWACToken::getSessionId ( )
Returns
string

Definition at line 146 of file class.ilWACToken.php.

References $session_id.

146  {
147  return $this->session_id;
148  }

◆ getTimestamp()

ilWACToken::getTimestamp ( )
Returns
int

Definition at line 162 of file class.ilWACToken.php.

References $timestamp.

Referenced by generateToken().

162  {
163  return $this->timestamp;
164  }
+ Here is the caller graph for this function:

◆ getToken()

ilWACToken::getToken ( )
Returns
string

Definition at line 194 of file class.ilWACToken.php.

References $token.

194  {
195  return $this->token;
196  }

◆ getTTL()

ilWACToken::getTTL ( )
Returns
int

Definition at line 282 of file class.ilWACToken.php.

References $ttl.

Referenced by generateToken().

282  {
283  return $this->ttl;
284  }
+ Here is the caller graph for this function:

◆ initSalt()

ilWACToken::initSalt ( )
protected

Definition at line 112 of file class.ilWACToken.php.

References generateSaltFile(), and getSaltFilePath().

Referenced by generateToken().

112  {
113  if (self::getSALT()) {
114  return true;
115  }
116  $salt = null;
117  if (is_file($this->getSaltFilePath())) {
118  include($this->getSaltFilePath());
119  }
120  self::setSALT($salt);
121  if (!$salt) {
122  $this->generateSaltFile();
123  }
124  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isDEBUG()

static ilWACToken::isDEBUG ( )
staticprotected
Returns
bool

Definition at line 83 of file class.ilWACToken.php.

References DEBUG, and ilWebAccessChecker\isDEBUG().

83  {
85  }
const DEBUG
+ Here is the call graph for this function:

◆ setClient()

ilWACToken::setClient (   $client)
Parameters
string$client

Definition at line 274 of file class.ilWACToken.php.

References $client.

Referenced by __construct().

274  {
275  $this->client = $client;
276  }
+ Here is the caller graph for this function:

◆ setId()

ilWACToken::setId (   $id)
Parameters
string$id

Definition at line 242 of file class.ilWACToken.php.

References $id.

Referenced by __construct().

242  {
243  $this->id = $id;
244  }
+ Here is the caller graph for this function:

◆ setIp()

ilWACToken::setIp (   $ip)
Parameters
string$ip

Definition at line 186 of file class.ilWACToken.php.

References $ip.

Referenced by __construct(), and ilWACTokenTest\testTokenGeneration().

186  {
187  $this->ip = $ip;
188  }
+ Here is the caller graph for this function:

◆ setPath()

ilWACToken::setPath (   $path)
Parameters
string$path

Definition at line 218 of file class.ilWACToken.php.

References $path.

Referenced by __construct().

218  {
219  $this->path = $path;
220  }
+ Here is the caller graph for this function:

◆ setRawToken()

ilWACToken::setRawToken (   $raw_token)
Parameters
string$raw_token

Definition at line 306 of file class.ilWACToken.php.

References $raw_token.

Referenced by generateToken().

306  {
307  $this->raw_token = $raw_token;
308  }
+ Here is the caller graph for this function:

◆ setSALT()

static ilWACToken::setSALT (   $SALT)
static
Parameters
string$SALT

Definition at line 258 of file class.ilWACToken.php.

References $SALT.

Referenced by ilWACCheckingInstanceTest\setUp(), and ilWACTokenTest\setUp().

258  {
259  self::$SALT = $SALT;
260  }
+ Here is the caller graph for this function:

◆ setSessionId()

ilWACToken::setSessionId (   $session_id)
Parameters
string$session_id

Definition at line 154 of file class.ilWACToken.php.

References $session_id.

Referenced by __construct().

154  {
155  $this->session_id = $session_id;
156  }
+ Here is the caller graph for this function:

◆ setTimestamp()

ilWACToken::setTimestamp (   $timestamp)
Parameters
int$timestamp

Definition at line 170 of file class.ilWACToken.php.

References $timestamp.

Referenced by __construct().

170  {
171  $this->timestamp = $timestamp;
172  }
+ Here is the caller graph for this function:

◆ setToken()

ilWACToken::setToken (   $token)
Parameters
string$token

Definition at line 202 of file class.ilWACToken.php.

References $token.

Referenced by generateToken().

202  {
203  $this->token = $token;
204  }
+ Here is the caller graph for this function:

◆ setTTL()

ilWACToken::setTTL (   $ttl)
Parameters
int$ttl

Definition at line 290 of file class.ilWACToken.php.

References $ttl.

Referenced by __construct().

290  {
291  $this->ttl = $ttl;
292  }
+ Here is the caller graph for this function:

Field Documentation

◆ $client

ilWACToken::$client = ''
protected

Definition at line 50 of file class.ilWACToken.php.

Referenced by __construct(), getClient(), and setClient().

◆ $id

ilWACToken::$id = ''
protected

Definition at line 46 of file class.ilWACToken.php.

Referenced by getId(), and setId().

◆ $ip

ilWACToken::$ip = ''
protected

Definition at line 30 of file class.ilWACToken.php.

Referenced by getIp(), and setIp().

◆ $path

ilWACToken::$path = ''
protected

Definition at line 42 of file class.ilWACToken.php.

Referenced by __construct(), getPath(), and setPath().

◆ $raw_token

ilWACToken::$raw_token = ''
protected

Definition at line 38 of file class.ilWACToken.php.

Referenced by getRawToken(), and setRawToken().

◆ $SALT

ilWACToken::$SALT = ''
staticprotected

Definition at line 18 of file class.ilWACToken.php.

Referenced by setSALT().

◆ $session_id

ilWACToken::$session_id = ''
protected

Definition at line 22 of file class.ilWACToken.php.

Referenced by __construct(), getSessionId(), and setSessionId().

◆ $timestamp

ilWACToken::$timestamp = 0
protected

Definition at line 26 of file class.ilWACToken.php.

Referenced by __construct(), getTimestamp(), and setTimestamp().

◆ $token

ilWACToken::$token = ''
protected

Definition at line 34 of file class.ilWACToken.php.

Referenced by generateToken(), getToken(), and setToken().

◆ $ttl

ilWACToken::$ttl = 0
protected

Definition at line 54 of file class.ilWACToken.php.

Referenced by __construct(), getTTL(), and setTTL().

◆ DEBUG

const ilWACToken::DEBUG = false

Definition at line 12 of file class.ilWACToken.php.

Referenced by ilWACTokenTest\testSomeBasics().

◆ TYPE_FILE

const ilWACToken::TYPE_FILE = ilWACSignedPath::TYPE_FILE

Definition at line 13 of file class.ilWACToken.php.

◆ TYPE_FOLDER

const ilWACToken::TYPE_FOLDER = ilWACSignedPath::TYPE_FOLDER

Definition at line 14 of file class.ilWACToken.php.


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