Bug #24809 ยป 17309.diff

Administrator Admin, 2011-01-25 18:46

View differences:

t3lib/class.t3lib_befunc.php 2011-01-25 18:23:47.000000000 +0100
3332 3332
	 * @return string a URL GET variable including ampersand
3333 3333
	 */
3334 3334
	public static function getUrlToken($formName = 'securityToken', $tokenName = 'formToken') {
3335
		$formprotection = t3lib_formprotection_Factory::get();
3335
		$formprotection = t3lib_formprotection::get();
3336 3336
		return '&' . $tokenName . '=' . $formprotection->generateToken($formName);
3337 3337
	}
3338 3338

  
t3lib/class.t3lib_pagerenderer.php 2011-01-25 18:23:49.000000000 +0100
947 947
	public function addExtDirectCode() {
948 948
		$token = '';
949 949
		if (TYPO3_MODE === 'BE') {
950
			$formprotection = t3lib_formprotection_Factory::get();
950
			$formprotection = t3lib_formprotection::get();
951 951
			$token = $formprotection->generateToken('extDirect');
952 952
		}
953 953

  
t3lib/class.t3lib_tceforms.php 2011-01-25 18:23:48.000000000 +0100
4982 4982
	 * @return string a complete input field
4983 4983
	 */
4984 4984
	public static function getHiddenTokenField($formName = 'securityToken', $tokenName = 'formToken') {
4985
		$formprotection = t3lib_formprotection_Factory::get();
4985
		$formprotection = t3lib_formprotection::get();
4986 4986
		return '<input type="hidden" name="' .$tokenName . '" value="' . $formprotection->generateToken($formName) . '" />';
4987 4987
	}
4988 4988

  
t3lib/extjs/class.t3lib_extjs_extdirectrouter.php 2011-01-25 18:23:47.000000000 +0100
89 89
			$token = array_pop($singleRequest->data);
90 90
			if ($firstCall) {
91 91
				$firstCall = FALSE;
92
				$formprotection = t3lib_formprotection_Factory::get();
92
				$formprotection = t3lib_formprotection::get();
93 93
				$validToken = $formprotection->validateToken($token, 'extDirect');
94 94
			}
95 95

  
t3lib/formprotection/class.t3lib_formprotection_backendformprotection.php 2011-01-25 18:23:48.000000000 +0100
35 35
 * matter; you only need it to get the form token for verifying it.
36 36
 *
37 37
 * <pre>
38
 * $formToken = t3lib_formprotection_Factory::get(
39
 *	 t3lib_formprotection_Factory::TYPE_BACK_END
38
 * $formToken = t3lib_formprotection::get(
39
 *	 t3lib_formprotection::TYPE_BACK_END
40 40
 * )->generateToken(
41 41
 *	 'BE user setup', 'edit'
42 42
 * );
......
53 53
 * For editing a tt_content record, the call could look like this:
54 54
 *
55 55
 * <pre>
56
 * $formToken = t3lib_formprotection_Factory::get(
57
 *	 t3lib_formprotection_Factory::TYPE_BACK_END
56
 * $formToken = t3lib_formprotection::get(
57
 *	 t3lib_formprotection::TYPE_BACK_END
58 58
 * )->getFormProtection()->generateToken(
59 59
 *	'tt_content', 'edit', $uid
60 60
 * );
......
64 64
 * generated tokens get saved, and also that removed tokens stay removed:
65 65
 *
66 66
 * <pre>
67
 * t3lib_formprotection_Factory::get(
68
 *	 t3lib_formprotection_Factory::TYPE_BACK_END
67
 * t3lib_formprotection::get(
68
 *	 t3lib_formprotection::TYPE_BACK_END
69 69
 * )->persistTokens();
70 70
 * </pre>
71 71
 *
......
78 78
 * that the form token is valid like this:
79 79
 *
80 80
 * <pre>
81
 * if ($dataHasBeenSubmitted && t3lib_formprotection_Factory::get(
82
 *		 t3lib_formprotection_Factory::TYPE_BACK_END
81
 * if ($dataHasBeenSubmitted && t3lib_formprotection::get(
82
 *		 t3lib_formprotection::TYPE_BACK_END
83 83
 *	 )->validateToken(
84 84
 *		 (string) t3lib_div::_POST('formToken'),
85 85
 *		 'BE user setup', 'edit
t3lib/formprotection/class.t3lib_formprotection_factory.php 2011-01-25 18:23:47.000000000 +0100
23 23
 ***************************************************************/
24 24

  
25 25
/**
26
 * Class t3lib_formprotection_Factory.
26
 * Class t3lib_formprotection.
27 27
 *
28 28
 * This class creates and manages instances of the various form protection
29 29
 * classes.
......
33 33
 * Usage for the back-end form protection:
34 34
 *
35 35
 * <pre>
36
 * $formProtection = t3lib_formprotection_Factory::get(
36
 * $formProtection = t3lib_formprotection::get(
37 37
 *	 't3lib_formProtection_BackEnd'
38 38
 * );
39 39
 * </pre>
......
41 41
 * Usage for the install tool form protection:
42 42
 *
43 43
 * <pre>
44
 * $formProtection = t3lib_formprotection_Factory::get(
44
 * $formProtection = t3lib_formprotection::get(
45 45
 *	 'tx_install_formprotection'
46 46
 * );
47 47
 * $formProtection->injectInstallTool($this);
......
55 55
 * @author Oliver Klee <typo3-coding@oliverklee.de>
56 56
 * @author Ernesto Baschny <ernst@cron-it.de>
57 57
 */
58
final class t3lib_formprotection_Factory {
58
final class t3lib_formprotection {
59 59
	/**
60 60
	 * created instances of form protections using the type as array key
61 61
	 *
tests/t3lib/formprotection/t3lib_formprotection_FactoryTest.php 2011-01-25 18:23:47.000000000 +0100
25 25
require_once('fixtures/class.t3lib_formprotection_testing.php');
26 26

  
27 27
/**
28
 * Testcase for the t3lib_formprotection_Factory class.
28
 * Testcase for the t3lib_formprotection class.
29 29
 *
30 30
 * $Id$
31 31
 *
......
35 35
 * @author Oliver Klee <typo3-coding@oliverklee.de>
36 36
 * @author Ernesto Baschny <ernst@cron-it.de>
37 37
 */
38
class t3lib_formprotection_FactoryTest extends tx_phpunit_testcase {
38
class t3lib_formprotectionTest extends tx_phpunit_testcase {
39 39
	public function setUp() {
40 40
	}
41 41

  
42 42
	public function tearDown() {
43
		t3lib_formprotection_Factory::purgeInstances();
43
		t3lib_formprotection::purgeInstances();
44 44
	}
45 45

  
46 46

  
......
54 54
	 * @expectedException InvalidArgumentException
55 55
	 */
56 56
	public function getForInexistentClassThrowsException() {
57
		t3lib_formprotection_Factory::get('noSuchClass');
57
		t3lib_formprotection::get('noSuchClass');
58 58
	}
59 59

  
60 60
	/**
......
63 63
	 * @expectedException InvalidArgumentException
64 64
	 */
65 65
	public function getForClassThatIsNoFormProtectionSubclassThrowsException() {
66
		t3lib_formprotection_Factory::get('t3lib_formprotection_FactoryTest');
66
		t3lib_formprotection::get('t3lib_formprotectionTest');
67 67
	}
68 68

  
69 69
	/**
......
71 71
	 */
72 72
	public function getForTypeBackEndWithExistingBackEndReturnsBackEndFormProtection() {
73 73
		$this->assertTrue(
74
			t3lib_formprotection_Factory::get(
74
			t3lib_formprotection::get(
75 75
				't3lib_formprotection_BackendFormProtection'
76 76
			) instanceof t3lib_formprotection_BackendFormProtection
77 77
		);
......
82 82
	 */
83 83
	public function getForTypeBackEndCalledTwoTimesReturnsTheSameInstance() {
84 84
		$this->assertSame(
85
			t3lib_formprotection_Factory::get(
85
			t3lib_formprotection::get(
86 86
				't3lib_formprotection_BackendFormProtection'
87 87
			),
88
			t3lib_formprotection_Factory::get(
88
			t3lib_formprotection::get(
89 89
				't3lib_formprotection_BackendFormProtection'
90 90
			)
91 91
		);
......
96 96
	 */
97 97
	public function getForTypeInstallToolReturnsInstallToolFormProtection() {
98 98
		$this->assertTrue(
99
			t3lib_formprotection_Factory::get(
99
			t3lib_formprotection::get(
100 100
				't3lib_formprotection_InstallToolFormProtection'
101 101
			) instanceof t3lib_formprotection_InstallToolFormProtection
102 102
		);
......
107 107
	 */
108 108
	public function getForTypeInstallToolCalledTwoTimesReturnsTheSameInstance() {
109 109
		$this->assertSame(
110
			t3lib_formprotection_Factory::get(
110
			t3lib_formprotection::get(
111 111
				't3lib_formprotection_InstallToolFormProtection'
112 112
			),
113
			t3lib_formprotection_Factory::get(
113
			t3lib_formprotection::get(
114 114
				't3lib_formprotection_InstallToolFormProtection'
115 115
			)
116 116
		);
......
121 121
	 */
122 122
	public function getForTypesInstallToolAndBackEndReturnsDifferentInstances() {
123 123
		$this->assertNotSame(
124
			t3lib_formprotection_Factory::get(
124
			t3lib_formprotection::get(
125 125
				't3lib_formprotection_InstallToolFormProtection'
126 126
			),
127
			t3lib_formprotection_Factory::get(
127
			t3lib_formprotection::get(
128 128
				't3lib_formprotection_BackendFormProtection'
129 129
			)
130 130
		);
......
140 140
	 */
141 141
	public function setSetsInstanceForType() {
142 142
		$instance = new t3lib_formProtection_Testing();
143
		t3lib_formprotection_Factory::set(
143
		t3lib_formprotection::set(
144 144
			't3lib_formprotection_BackendFormProtection', $instance
145 145
		);
146 146

  
147 147
		$this->assertSame(
148 148
			$instance,
149
			t3lib_formprotection_Factory::get(
149
			t3lib_formprotection::get(
150 150
				't3lib_formprotection_BackendFormProtection'
151 151
			)
152 152
		);
......
157 157
	 */
158 158
	public function setNotSetsInstanceForOtherType() {
159 159
		$instance = new t3lib_formProtection_Testing();
160
		t3lib_formprotection_Factory::set(
160
		t3lib_formprotection::set(
161 161
			't3lib_formprotection_BackendFormProtection', $instance
162 162
		);
163 163

  
164 164
		$this->assertNotSame(
165 165
			$instance,
166
			t3lib_formprotection_Factory::get(
166
			t3lib_formprotection::get(
167 167
				't3lib_formprotection_InstallToolFormProtection'
168 168
			)
169 169
		);
typo3/alt_doc.php 2011-01-25 18:23:49.000000000 +0100
1491 1491
// Preprocessing, storing data if submitted to
1492 1492
$SOBE->preInit();
1493 1493

  
1494
$formprotection = t3lib_formprotection_Factory::get();
1494
$formprotection = t3lib_formprotection::get();
1495 1495

  
1496 1496
if ($SOBE->doProcessData())	{		// Checks, if a save button has been clicked (or the doSave variable is sent)
1497 1497
	if ($formprotection->validateToken(t3lib_div::_GP('formToken'), 'editRecord')) {
typo3/classes/class.ajaxlogin.php 2011-01-25 18:23:48.000000000 +0100
44 44
	 */
45 45
	public function login(array $parameters, TYPO3AJAX $ajaxObj) {
46 46
		if ($GLOBALS['BE_USER']->user['uid']) {
47
			$formprotection = t3lib_formprotection_Factory::get();
47
			$formprotection = t3lib_formprotection::get();
48 48
			$token = $formprotection->generateToken('extDirect');
49 49

  
50 50
			$json = array(
typo3/classes/class.clearcachemenu.php 2011-01-25 18:23:48.000000000 +0100
115 115
			}
116 116
		}
117 117

  
118
		t3lib_formprotection_Factory::get()->persistTokens();
118
		t3lib_formprotection::get()->persistTokens();
119 119
	}
120 120

  
121 121
	/**
typo3/index.php 2011-01-25 18:23:48.000000000 +0100
397 397
			if (!$this->loginRefresh)	{
398 398
				t3lib_utility_Http::redirect($this->redirectToURL);
399 399
			} else {
400
				$formprotection = t3lib_formprotection_Factory::get();
400
				$formprotection = t3lib_formprotection::get();
401 401
				$token = $formprotection->generateToken('extDirect');
402 402
				$TBE_TEMPLATE->JScode.=$TBE_TEMPLATE->wrapScriptTags('
403 403
					if (parent.opener && (parent.opener.busy || parent.opener.TYPO3.loginRefresh)) {
typo3/tce_db.php 2011-01-25 18:23:48.000000000 +0100
246 246
// Include files?
247 247
foreach($SOBE->include_once as $INC_FILE)	include_once($INC_FILE);
248 248

  
249
$formprotection = t3lib_formprotection_Factory::get();
249
$formprotection = t3lib_formprotection::get();
250 250

  
251 251
if ($formprotection->validateToken(t3lib_div::_GP('formToken'), 'tceAction')) {
252 252
	$SOBE->initClipboard();
typo3/template.php 2011-01-25 18:23:48.000000000 +0100
926 926

  
927 927
<!-- Wrapping DIV-section for whole page END -->
928 928
</div>':'') . $this->endOfPageJsBlock ;
929
			t3lib_formprotection_Factory::get()->persistTokens();
929
			t3lib_formprotection::get()->persistTokens();
930 930
		}
931 931

  
932 932

  
    (1-1/1)