|
25 | 25 |
|
26 | 26 | use Facebook\Authentication\AccessToken; |
27 | 27 | use Facebook\Authentication\OAuth2Client; |
28 | | -use Facebook\Url\UrlDetectionInterface; |
29 | | -use Facebook\Url\FacebookUrlDetectionHandler; |
30 | | -use Facebook\Url\FacebookUrlManipulator; |
31 | | -use Facebook\PersistentData\PersistentDataInterface; |
| 28 | +use Facebook\Exceptions\FacebookSDKException; |
32 | 29 | use Facebook\PersistentData\FacebookSessionPersistentDataHandler; |
| 30 | +use Facebook\PersistentData\PersistentDataInterface; |
| 31 | +use Facebook\PseudoRandomString\PseudoRandomStringGeneratorFactory; |
33 | 32 | use Facebook\PseudoRandomString\PseudoRandomStringGeneratorInterface; |
34 | | -use Facebook\PseudoRandomString\McryptPseudoRandomStringGenerator; |
35 | | -use Facebook\PseudoRandomString\OpenSslPseudoRandomStringGenerator; |
36 | | -use Facebook\PseudoRandomString\UrandomPseudoRandomStringGenerator; |
37 | | -use Facebook\Exceptions\FacebookSDKException; |
| 33 | +use Facebook\Url\FacebookUrlDetectionHandler; |
| 34 | +use Facebook\Url\FacebookUrlManipulator; |
| 35 | +use Facebook\Url\UrlDetectionInterface; |
38 | 36 |
|
39 | 37 | /** |
40 | 38 | * Class FacebookRedirectLoginHelper |
@@ -79,7 +77,7 @@ public function __construct(OAuth2Client $oAuth2Client, PersistentDataInterface |
79 | 77 | $this->oAuth2Client = $oAuth2Client; |
80 | 78 | $this->persistentDataHandler = $persistentDataHandler ?: new FacebookSessionPersistentDataHandler(); |
81 | 79 | $this->urlDetectionHandler = $urlHandler ?: new FacebookUrlDetectionHandler(); |
82 | | - $this->pseudoRandomStringGenerator = $prsg ?: $this->detectPseudoRandomStringGenerator(); |
| 80 | + $this->pseudoRandomStringGenerator = PseudoRandomStringGeneratorFactory::createPseudoRandomStringGenerator($prsg); |
83 | 81 | } |
84 | 82 |
|
85 | 83 | /** |
@@ -112,32 +110,6 @@ public function getPseudoRandomStringGenerator() |
112 | 110 | return $this->pseudoRandomStringGenerator; |
113 | 111 | } |
114 | 112 |
|
115 | | - /** |
116 | | - * Detects which pseudo-random string generator to use. |
117 | | - * |
118 | | - * @return PseudoRandomStringGeneratorInterface |
119 | | - * |
120 | | - * @throws FacebookSDKException |
121 | | - */ |
122 | | - public function detectPseudoRandomStringGenerator() |
123 | | - { |
124 | | - // Since openssl_random_pseudo_bytes() can sometimes return non-cryptographically |
125 | | - // secure pseudo-random strings (in rare cases), we check for mcrypt_create_iv() first. |
126 | | - if (function_exists('mcrypt_create_iv')) { |
127 | | - return new McryptPseudoRandomStringGenerator(); |
128 | | - } |
129 | | - |
130 | | - if (function_exists('openssl_random_pseudo_bytes')) { |
131 | | - return new OpenSslPseudoRandomStringGenerator(); |
132 | | - } |
133 | | - |
134 | | - if (!ini_get('open_basedir') && is_readable('/dev/urandom')) { |
135 | | - return new UrandomPseudoRandomStringGenerator(); |
136 | | - } |
137 | | - |
138 | | - throw new FacebookSDKException('Unable to detect a cryptographically secure pseudo-random string generator.'); |
139 | | - } |
140 | | - |
141 | 113 | /** |
142 | 114 | * Stores CSRF state and returns a URL to which the user should be sent to in order to continue the login process with Facebook. |
143 | 115 | * |
|
0 commit comments