Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
namespace Illuminate\Session;
4
 
5
use Illuminate\Contracts\Encryption\DecryptException;
6
use Illuminate\Contracts\Encryption\Encrypter as EncrypterContract;
7
use SessionHandlerInterface;
8
 
9
class EncryptedStore extends Store
10
{
11
    /**
12
     * The encrypter instance.
13
     *
14
     * @var \Illuminate\Contracts\Encryption\Encrypter
15
     */
16
    protected $encrypter;
17
 
18
    /**
19
     * Create a new session instance.
20
     *
21
     * @param  string  $name
22
     * @param  \SessionHandlerInterface  $handler
23
     * @param  \Illuminate\Contracts\Encryption\Encrypter  $encrypter
24
     * @param  string|null  $id
25
     * @param  string  $serialization
26
     * @return void
27
     */
28
    public function __construct($name, SessionHandlerInterface $handler, EncrypterContract $encrypter, $id = null, $serialization = 'php')
29
    {
30
        $this->encrypter = $encrypter;
31
 
32
        parent::__construct($name, $handler, $id, $serialization);
33
    }
34
 
35
    /**
36
     * Prepare the raw string data from the session for unserialization.
37
     *
38
     * @param  string  $data
39
     * @return string
40
     */
41
    protected function prepareForUnserialize($data)
42
    {
43
        try {
44
            return $this->encrypter->decrypt($data);
45
        } catch (DecryptException $e) {
46
            return $this->serialization === 'json' ? json_encode([]) : serialize([]);
47
        }
48
    }
49
 
50
    /**
51
     * Prepare the serialized session data for storage.
52
     *
53
     * @param  string  $data
54
     * @return string
55
     */
56
    protected function prepareForStorage($data)
57
    {
58
        return $this->encrypter->encrypt($data);
59
    }
60
 
61
    /**
62
     * Get the encrypter instance.
63
     *
64
     * @return \Illuminate\Contracts\Encryption\Encrypter
65
     */
66
    public function getEncrypter()
67
    {
68
        return $this->encrypter;
69
    }
70
}