44
55namespace SimpleSAML \Module \casserver \Cas ;
66
7+ use ErrorException ;
78use SimpleSAML \Configuration ;
89use SimpleSAML \Logger ;
910use SimpleSAML \Module \casserver \Codebooks \OverrideConfigPropertiesEnum ;
1415 */
1516class ServiceValidator
1617{
17- /**
18- * @var \SimpleSAML\Configuration
19- */
20- private Configuration $ mainConfig ;
21-
2218 /**
2319 * ServiceValidator constructor.
24- * @param Configuration $mainConfig
20+ * @param \SimpleSAML\ Configuration $mainConfig
2521 */
26- public function __construct (Configuration $ mainConfig )
27- {
28- $ this -> mainConfig = $ mainConfig ;
22+ public function __construct (
23+ protected Configuration $ mainConfig ,
24+ ) {
2925 }
3026
27+
3128 /**
3229 * Check that the $service is allowed, and if so return the configuration to use.
3330 *
3431 * @param string $service The service url. Assume to already be url decoded
3532 *
36- * @return Configuration|null Return the configuration to use for this service, or null if service is not allowed
33+ * @return \SimpleSAML\Configuration|null Return the configuration to use for this service,
34+ * or null if service is not allowed
3735 * @throws \ErrorException
3836 */
3937 public function checkServiceURL (string $ service ): ?Configuration
@@ -82,6 +80,7 @@ public function checkServiceURL(string $service): ?Configuration
8280 return Configuration::loadFromArray ($ serviceConfig );
8381 }
8482
83+
8584 /**
8685 * @param string $legalUrl The string or regex to use for comparison
8786 * @param string $service The service to compare
@@ -96,14 +95,14 @@ protected function validateServiceIsLegal(string $legalUrl, string $service): bo
9695 // Since "If the regex pattern passed does not compile to a valid regex, an E_WARNING is emitted. "
9796 // we will throw an exception if the warning is emitted and use try-catch to handle it
9897 set_error_handler (static function ($ severity , $ message , $ file , $ line ) {
99- throw new \ ErrorException ($ message , $ severity , $ severity , $ file , $ line );
98+ throw new ErrorException ($ message , $ severity , $ severity , $ file , $ line );
10099 }, E_WARNING );
101100
102101 try {
103102 if (preg_match ($ legalUrl , $ service ) === 1 ) {
104103 $ isValid = true ;
105104 }
106- } catch (\ ErrorException $ e ) {
105+ } catch (ErrorException $ e ) {
107106 // do nothing
108107 Logger::warning ("Invalid CAS legal service url ' $ legalUrl'. Error " . preg_last_error_msg ());
109108 } finally {
0 commit comments