1 <?php
2 /**
3 * @package Joomla.Platform
4 * @subpackage Crypt
5 *
6 * @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
7 * @license GNU General Public License version 2 or later; see LICENSE
8 */
9
10 defined('JPATH_PLATFORM') or die;
11
12 /**
13 * Encryption key object for the Joomla Platform.
14 *
15 * @property-read string $type The key type.
16 *
17 * @since 12.1
18 */
19 class JCryptKey
20 {
21 /**
22 * @var string The private key.
23 * @since 12.1
24 */
25 public $private;
26
27 /**
28 * @var string The public key.
29 * @since 12.1
30 */
31 public $public;
32
33 /**
34 * @var string The key type.
35 * @since 12.1
36 */
37 protected $type;
38
39 /**
40 * Constructor.
41 *
42 * @param string $type The key type.
43 * @param string $private The private key.
44 * @param string $public The public key.
45 *
46 * @since 12.1
47 */
48 public function __construct($type, $private = null, $public = null)
49 {
50 // Set the key type.
51 $this->type = (string) $type;
52
53 // Set the optional public/private key strings.
54 $this->private = isset($private) ? (string) $private : null;
55 $this->public = isset($public) ? (string) $public : null;
56 }
57
58 /**
59 * Magic method to return some protected property values.
60 *
61 * @param string $name The name of the property to return.
62 *
63 * @return mixed
64 *
65 * @since 12.1
66 */
67 public function __get($name)
68 {
69 if ($name == 'type')
70 {
71 return $this->type;
72 }
73
74 trigger_error('Cannot access property ' . __CLASS__ . '::' . $name, E_USER_WARNING);
75 }
76 }
77