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.

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 }
static getTokenMaxLifetimeInSeconds()
setSessionId($session_id)
setTimestamp($timestamp)
setClient($client)
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']

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

+ Here is the call graph for this function:

Member Function Documentation

◆ generateSaltFile()

ilWACToken::generateSaltFile ( )
protected

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

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.
static setSALT($SALT)

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

Referenced by initSalt().

+ 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.

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)

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

Referenced by __construct().

+ 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.

266 {
267 return $this->client;
268 }

References $client.

Referenced by generateToken().

+ 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.

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

References $id.

◆ getIp()

ilWACToken::getIp ( )
Returns
string

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

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

References $ip.

◆ getPath()

ilWACToken::getPath ( )
Returns
string

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

210 {
211 return $this->path;
212 }

References $path.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ getRawToken()

ilWACToken::getRawToken ( )
Returns
string

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

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

References $raw_token.

◆ getSALT()

static ilWACToken::getSALT ( )
static
Returns
string

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

250 {
251 return self::$SALT;
252 }

References $SALT.

Referenced by ilWACTokenTest\testTokenGeneration().

+ Here is the caller graph for this function:

◆ getSaltFilePath()

ilWACToken::getSaltFilePath ( )
protected
Returns
string

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

105 {
106 $salt_file = './data/wacsalt.php';
107
108 return $salt_file;
109 }

Referenced by generateSaltFile(), and initSalt().

+ Here is the caller graph for this function:

◆ getSessionId()

ilWACToken::getSessionId ( )
Returns
string

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

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

References $session_id.

◆ getTimestamp()

ilWACToken::getTimestamp ( )
Returns
int

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

162 {
163 return $this->timestamp;
164 }

References $timestamp.

Referenced by generateToken().

+ Here is the caller graph for this function:

◆ getToken()

ilWACToken::getToken ( )
Returns
string

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

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

References $token.

◆ getTTL()

ilWACToken::getTTL ( )
Returns
int

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

282 {
283 return $this->ttl;
284 }

References $ttl.

Referenced by generateToken().

+ Here is the caller graph for this function:

◆ initSalt()

ilWACToken::initSalt ( )
protected

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

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 }

References generateSaltFile(), getSaltFilePath(), and setSALT().

Referenced by generateToken().

+ 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.

83 {
85 }
const DEBUG

References DEBUG, and ilWebAccessChecker\isDEBUG().

+ Here is the call graph for this function:

◆ setClient()

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

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

274 {
275 $this->client = $client;
276 }

References $client.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setId()

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

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

242 {
243 $this->id = $id;
244 }

References $id.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setIp()

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

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

186 {
187 $this->ip = $ip;
188 }

References $ip.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setPath()

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

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

218 {
219 $this->path = $path;
220 }

References $path.

Referenced by __construct().

+ 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.

306 {
307 $this->raw_token = $raw_token;
308 }

References $raw_token.

Referenced by generateToken().

+ 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.

258 {
259 self::$SALT = $SALT;
260 }

References $SALT.

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

+ 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.

154 {
155 $this->session_id = $session_id;
156 }

References $session_id.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setTimestamp()

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

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

170 {
171 $this->timestamp = $timestamp;
172 }

References $timestamp.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setToken()

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

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

202 {
203 $this->token = $token;
204 }

References $token.

Referenced by generateToken().

+ Here is the caller graph for this function:

◆ setTTL()

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

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

290 {
291 $this->ttl = $ttl;
292 }

References $ttl.

Referenced by __construct().

+ 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 getSALT(), and 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: