@@ -36,28 +36,30 @@ public function __construct($config, $reserved)
3636
3737 public function process (&$ state )
3838 {
39- assert ('is_array($state) ' );
40- if (! array_key_exists ($ this ->as_config ['nameId_attribute_name ' ], $ state ['Attributes ' ])) {
41- throw new SimpleSAML_Error_Exception (
42- "Configuration error: There is no attribute named: "
43- .$ this ->as_config ['nameId_attribute_name ' ]
44- ." in state['Attributes'] array. "
45- );
39+ try {
40+ assert ('is_array($state) ' );
41+ if (! array_key_exists ($ this ->as_config ['nameId_attribute_name ' ], $ state ['Attributes ' ])) {
42+ throw new SimpleSAML_Error_Exception (
43+ "Configuration error: There is no attribute named: ' "
44+ .$ this ->as_config ['nameId_attribute_name ' ]
45+ ."'' in \$state['Attributes'] array. "
46+ );
47+ }
48+ $ nameId = $ state ['Attributes ' ][$ this ->as_config ['nameId_attribute_name ' ]][0 ];
49+ $ this ->config = SimpleSAML_Configuration::getInstance ();
50+ $ new_attributes = $ this ->getAttributes ($ nameId );
51+ $ state ['Attributes ' ][key ($ new_attributes )][0 ] = $ new_attributes [key ($ new_attributes )];
52+ } catch (\Exception $ e ) {
53+ $ this ->showException ($ e );
4654 }
47- $ nameId = $ state ['Attributes ' ][$ this ->as_config ['nameId_attribute_name ' ]][0 ];
48- $ this ->config = SimpleSAML_Configuration::getInstance ();
49- $ new_attributes = $ this ->getAttributes ($ nameId );
50- $ state ['Attributes ' ][key ($ new_attributes )][0 ] = $ new_attributes [key ($ new_attributes )];
55+
5156 }
5257
5358 public function getAttributes ($ nameId , $ attributes = array ())
5459 {
5560
5661 // Set up config
5762 $ config = $ this ->config ;
58- $ retarray = array ();
59-
60- // Make the call
6163
6264 // Setup cURL
6365 $ url = $ this ->as_config ['api_url ' ].'/ ' .$ nameId ;
@@ -92,4 +94,13 @@ public function getAttributes($nameId, $attributes = array())
9294 $ attributes = $ data ['data ' ];
9395 return $ attributes ;
9496 }
97+
98+ private function showException ($ e )
99+ {
100+ $ globalConfig = SimpleSAML_Configuration::getInstance ();
101+ $ t = new SimpleSAML_XHTML_Template ($ globalConfig , 'attributefromrestapi:exception.tpl.php ' );
102+ $ t ->data ['e ' ] = $ e ->getMessage ();
103+ $ t ->show ();
104+ exit ();
105+ }
95106}
0 commit comments