Odyssey
webLanding.prg
1 <?php
2 /**
3  * File: ssoLanding.prg
4  * Purpose: Provide a script the apps can call if necessary to create a
5  * cookie before launching a browser external to the app.
6  *
7  */
8 
9  // ** SET HOMECU FLAGS - no menu, limited branding
10  $serviceShowInfo = false;
11  $serviceLoadMenu = false;
12  $serviceShowMenu = false;
13  $serviceSkipSecurity = true;
14  $serviceSkipCredentials = true; // we don't have the Ticket set up yet
15  $serviceAllowReadonly = true;
16 
17 require_once(dirname(__FILE__) . '/../library/hcuService.i');
18 
19  try {
20 
21  // decrypt it
22  $inputPayload = filter_input( INPUT_GET, "payload", FILTER_SANITIZE_STRING );
23  if ( strlen( $inputPayload ) == 0 ) {
24  throw new Exception("Invalid parameters.");
25  }
26 
27  // quick test to make sure the nonce is part of the payload (should have a "|")
28  $parts = explode( "|", $inputPayload );
29  if ( count( $parts ) != 2 ) {
30  throw new Exception("Badly formed parameters.");
31  }
32 
33  $payload = DecryptPayloadData( $inputPayload, GetPayloadEncryptionKey(32) );
34  if ( strlen( $payload ) == 0 ) {
35  throw new Exception("Invalid payload.");
36  }
37 
38  $parts = json_decode( $payload, true );
39  if ( !is_array( $parts ) ) {
40  throw new Exception("Invalid decoded payload parts.");
41  }
42 
43  $url = trim( $parts["url"] );
44  $parameters = trim( urldecode( $parts["parameters"] ) );
45  $cookies = $parts["cookies"];
46 
47  // set any cookies
48  // NOTE: the Ticket cookie string is encoded, so need to decode it first
49  if ( count( $cookies ) > 0 ) {
50  $cookieNames = array_keys( $cookies );
51 
52  for ( $i = 0; $i < count( $cookieNames ); $i++ ) {
53  $lEnvSet = HCU_array_key_value('SYSENV', $HB_ENV);
54  HCU_setcookie_env($lEnvSet, trim( $cookieNames[$i] ), urldecode( $cookies[$cookieNames[$i]] ), 0);
55  }
56  }
57 
58  $fullURL = $url;
59  if ( strlen( $parameters ) > 0 ) {
60  $fullURL .= "?" . $parameters;
61  }
62 
63  header( "Location: $fullURL" );
64  exit;
65 
66  } catch( Exception $e ) {
67  $message = $e->getMessage();
68  print "Unable to resolve targets. $message";
69  }
70 
71