ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 ()
 
 setId ($id)
 
 getClient ()
 
 setClient ($client)
 
 getTTL ()
 
 setTTL ($ttl)
 

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 = ''
 
 $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 60 of file class.ilWACToken.php.

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

60  {
61  $this->setClient($client);
62  $parts = parse_url($path);
63  $this->setPath($parts['path']);
64  $session_id = session_id();
65  $this->setSessionId($session_id ? $session_id : '-');
66  if (isset($_SERVER['REMOTE_ADDR'])) {
67  $this->setIp($_SERVER['REMOTE_ADDR']);
68  }
69  $this->setTimestamp($timestamp ? $timestamp : time());
71  $this->setTTL($ttl); // since we do not know the type at this poit we choose the shorter duration for security reasons
72  $this->generateToken();
73  self::isDEBUG() ? $this->setId($this->getPath()) : $this->setId(md5($this->getPath()));
74  }
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
setTimestamp($timestamp)
setSessionId($session_id)
static getTokenMaxLifetimeInSeconds()
setClient($client)
+ Here is the call graph for this function:

Member Function Documentation

◆ generateSaltFile()

ilWACToken::generateSaltFile ( )
protected

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

References ilWACException\DATA_DIR_NON_WRITEABLE, and getSaltFilePath().

Referenced by initSalt().

118  {
119  if (is_file($this->getSaltFilePath())) {
120  unlink($this->getSaltFilePath());
121  }
122  $template = file_get_contents('./Services/WebAccessChecker/wacsalt.php.template');
123  $salt = md5(time() * rand(1000, 9999) . $this->getSaltFilePath());
124  self::setSALT($salt);
125  $template = str_replace('INSERT_SALT', $salt, $template);
126  if (is_writable(dirname($this->getSaltFilePath()))) {
127  file_put_contents($this->getSaltFilePath(), $template);
128  } else {
130  }
131  }
Class ilWACException.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ generateToken()

ilWACToken::generateToken ( )

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

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

Referenced by __construct().

85  {
86  $this->initSalt();
87  $token = implode('-', array( self::getSALT(), $this->getIp(), $this->getClient(), $this->getTimestamp(), $this->getTTL() ));
88  $token = self::isDEBUG() ? $token : sha1($token);
89  $this->setToken($token);
90  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getClient()

ilWACToken::getClient ( )
Returns
string

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

References $client.

Referenced by generateToken().

249  {
250  return $this->client;
251  }
+ Here is the caller graph for this function:

◆ getId()

ilWACToken::getId ( )
Returns
string

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

References $id.

217  {
218  return $this->id;
219  }

◆ getIp()

ilWACToken::getIp ( )
Returns
string

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

References $ip.

Referenced by generateToken().

169  {
170  return $this->ip;
171  }
+ Here is the caller graph for this function:

◆ getPath()

ilWACToken::getPath ( )
Returns
string

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

References $path.

Referenced by __construct().

201  {
202  return $this->path;
203  }
+ Here is the caller graph for this function:

◆ getSALT()

static ilWACToken::getSALT ( )
static
Returns
string

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

233  {
234  return self::$SALT;
235  }

◆ getSaltFilePath()

ilWACToken::getSaltFilePath ( )
protected
Returns
string

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

Referenced by generateSaltFile(), and initSalt().

96  {
97  $salt_file = './data/wacsalt.php';
98 
99  return $salt_file;
100  }
+ Here is the caller graph for this function:

◆ getSessionId()

ilWACToken::getSessionId ( )
Returns
string

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

References $session_id.

137  {
138  return $this->session_id;
139  }

◆ getTimestamp()

ilWACToken::getTimestamp ( )
Returns
int

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

References $timestamp.

Referenced by generateToken().

153  {
154  return $this->timestamp;
155  }
+ Here is the caller graph for this function:

◆ getToken()

ilWACToken::getToken ( )
Returns
string

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

References $token.

185  {
186  return $this->token;
187  }

◆ getTTL()

ilWACToken::getTTL ( )
Returns
int

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

References $ttl.

Referenced by generateToken().

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

◆ initSalt()

ilWACToken::initSalt ( )
protected

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

References generateSaltFile(), and getSaltFilePath().

Referenced by generateToken().

103  {
104  if (self::getSALT()) {
105  return true;
106  }
107  $salt = null;
108  if (is_file($this->getSaltFilePath())) {
109  include($this->getSaltFilePath());
110  }
111  self::setSALT($salt);
112  if (!$salt) {
113  $this->generateSaltFile();
114  }
115  }
+ 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 80 of file class.ilWACToken.php.

References DEBUG, and ilWebAccessChecker\isDEBUG().

80  {
82  }
const DEBUG
+ Here is the call graph for this function:

◆ setClient()

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

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

References $client.

Referenced by __construct().

257  {
258  $this->client = $client;
259  }
+ Here is the caller graph for this function:

◆ setId()

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

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

References $id.

Referenced by __construct().

225  {
226  $this->id = $id;
227  }
+ Here is the caller graph for this function:

◆ setIp()

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

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

References $ip.

Referenced by __construct().

177  {
178  $this->ip = $ip;
179  }
+ Here is the caller graph for this function:

◆ setPath()

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

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

References $path.

Referenced by __construct().

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

◆ setSALT()

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

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

References $SALT.

241  {
242  self::$SALT = $SALT;
243  }

◆ setSessionId()

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

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

References $session_id.

Referenced by __construct().

145  {
146  $this->session_id = $session_id;
147  }
+ Here is the caller graph for this function:

◆ setTimestamp()

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

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

References $timestamp.

Referenced by __construct().

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

◆ setToken()

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

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

References $token.

Referenced by generateToken().

193  {
194  $this->token = $token;
195  }
+ Here is the caller graph for this function:

◆ setTTL()

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

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

References $ttl.

Referenced by __construct().

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

Field Documentation

◆ $client

ilWACToken::$client = ''
protected

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

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

◆ $id

ilWACToken::$id = ''
protected

Definition at line 42 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 38 of file class.ilWACToken.php.

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

◆ $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 50 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.

◆ 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: