| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | declare(strict_types=1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * The MIT License (MIT) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * Copyright (c) 2014-2018 Spomky-Labs | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * This software may be modified and distributed under the terms | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * of the MIT license.  See the LICENSE file for details. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | namespace OAuth2Framework\Component\OpenIdConnect\Rule; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use OAuth2Framework\Component\ClientRule\Rule; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use OAuth2Framework\Component\Core\Client\ClientId; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | use OAuth2Framework\Component\Core\DataBag\DataBag; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 20 |  |  | final class UserParametersRule implements Rule | 
            
                                                                        
                            
            
                                    
            
            
                | 21 |  |  | { | 
            
                                                                        
                            
            
                                    
            
            
                | 22 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 23 |  |  |      * {@inheritdoc} | 
            
                                                                        
                            
            
                                    
            
            
                | 24 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     public function handle(ClientId $clientId, DataBag $commandParameters, DataBag $validatedParameters, callable $next): DataBag | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |         if ($commandParameters->has('require_auth_time')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |             $require_auth_time = $commandParameters->get('require_auth_time'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |             if (!is_bool($require_auth_time)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |                 throw new \InvalidArgumentException('The parameter "require_auth_time" must be a boolean.'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |             $validatedParameters = $validatedParameters->with('require_auth_time', $require_auth_time); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |         if ($commandParameters->has('default_max_age')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |             $default_max_age = $commandParameters->get('default_max_age'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |             if (!is_int($default_max_age) || $default_max_age < 0) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |                 throw new \InvalidArgumentException('The parameter "default_max_age" must be a positive integer.'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |             $validatedParameters = $validatedParameters->with('default_max_age', $default_max_age); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |         if ($commandParameters->has('default_acr_values')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |             $default_acr_values = $commandParameters->get('default_acr_values'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |             if (!is_array($default_acr_values)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |                 throw new \InvalidArgumentException('The parameter "default_acr_values" must be an array of strings.'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |             array_map(function ($default_acr_value) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |                 if (!is_string($default_acr_value)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |                     throw new \InvalidArgumentException('The parameter "default_acr_values" must be an array of strings.'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |             }, $default_acr_values); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |             $validatedParameters = $validatedParameters->with('default_acr_values', $default_acr_values); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |         return $next($clientId, $commandParameters, $validatedParameters); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 55 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 56 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 57 |  |  |  |