Topic
  • 8 replies
  • Latest Post - ‏2012-03-28T19:59:41Z by tmparker
JohnDRazz
JohnDRazz
34 Posts

Pinned topic Setting a global variable based on connection information

‏2012-02-02T16:24:18Z |
I have an application that allows users to either signon through the normal signon screen or to use a profile in the user list, in which case I inspect a session key. To do this, two different connections are configured - one with a user list/connection macro and one without. For security, I need make sure that a session key is passed whenever the user list profile is supplied.

My first attempt was to try an extract in the connection macro to set a global variable. But HATS barked that it does not allow global variables to be set by extracts in connection macros.

Is there another way to do this? If I could retrieve the user list to see if it is empty, that would be sufficient. But I do not know how to do this. Another idea I had was to set a global variable in the connection itself -under Advanced settings. Is this possible?

Looking for options and ideas... Thanks in advance...

This is HATS 8.0, WebSphere 8.0 connecting to an System i host.
Updated on 2012-03-28T19:59:41Z at 2012-03-28T19:59:41Z by tmparker
  • JohnDRazz
    JohnDRazz
    34 Posts

    Re: Setting a global variable based on connection information

    ‏2012-02-08T21:59:33Z  
    Any ideas?
  • tmparker
    tmparker
    518 Posts

    Re: Setting a global variable based on connection information

    ‏2012-02-08T22:35:12Z  
    • JohnDRazz
    • ‏2012-02-08T21:59:33Z
    Any ideas?
    Hi John,

    So I'm not sure if I am entirely clear on what you need to accomplish here. You need to set a GV as a flag to indicate that you are going down some certain path, is that correct? Or do you need to extract the session key and store that in the GV? I guess I am not clear as to how you are setting up these 2 paths in your application to allow users to either signon normally or to use a user list. Is this using separate URLs or some other logic? If you are controlling this behavior prior to the starting of the HATS app then you could always create a GV in the URL so that HATS will create it when it starts. Not sure if that helps at all.

    Thanks
    Tim
  • JohnDRazz
    JohnDRazz
    34 Posts

    Re: Setting a global variable based on connection information

    ‏2012-02-24T21:49:28Z  
    • tmparker
    • ‏2012-02-08T22:35:12Z
    Hi John,

    So I'm not sure if I am entirely clear on what you need to accomplish here. You need to set a GV as a flag to indicate that you are going down some certain path, is that correct? Or do you need to extract the session key and store that in the GV? I guess I am not clear as to how you are setting up these 2 paths in your application to allow users to either signon normally or to use a user list. Is this using separate URLs or some other logic? If you are controlling this behavior prior to the starting of the HATS app then you could always create a GV in the URL so that HATS will create it when it starts. Not sure if that helps at all.

    Thanks
    Tim
    Hi Tim!

    I am trying to use multiple connections. Connection 1 uses a trusted signon with a connection macro, Connection 2 uses the normal signon screen. I want to know which connection a user came in on so I can set a Global variable flag. Then I can use the global variable to determine which events to trigger.

    For example, if a user came in on Connection 1 and did not supply a session key, I want to throw them out. But If they came in on connection 2, I will present the signon screen. I tried setting a global variable via the connection macro, but HATS did like it.
  • tmparker
    tmparker
    518 Posts

    Re: Setting a global variable based on connection information

    ‏2012-02-24T22:55:47Z  
    • JohnDRazz
    • ‏2012-02-24T21:49:28Z
    Hi Tim!

    I am trying to use multiple connections. Connection 1 uses a trusted signon with a connection macro, Connection 2 uses the normal signon screen. I want to know which connection a user came in on so I can set a Global variable flag. Then I can use the global variable to determine which events to trigger.

    For example, if a user came in on Connection 1 and did not supply a session key, I want to throw them out. But If they came in on connection 2, I will present the signon screen. I tried setting a global variable via the connection macro, but HATS did like it.
    Hi John,

    You can take a look at this post (https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14508033) I did a while back which showed a customer how to use business logic to look at the URL the user comes in on and set a global variable based on some criteria. You could also use this to check session attributes if you needed to from the request object. If you run this in the Start event you could filter the requests and for bad ones you could even redirect them to some other page. This would give you the flexibility to set any global variables before you even connect.

    Let me know if this works for you.

    Thanks
    Tim
  • JohnDRazz
    JohnDRazz
    34 Posts

    Re: Setting a global variable based on connection information

    ‏2012-03-28T17:02:04Z  
    • tmparker
    • ‏2012-02-24T22:55:47Z
    Hi John,

    You can take a look at this post (https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14508033) I did a while back which showed a customer how to use business logic to look at the URL the user comes in on and set a global variable based on some criteria. You could also use this to check session attributes if you needed to from the request object. If you run this in the Start event you could filter the requests and for bad ones you could even redirect them to some other page. This would give you the flexibility to set any global variables before you even connect.

    Let me know if this works for you.

    Thanks
    Tim
    Thanks Tim.

    "You could also use this to check session attributes if you needed to from the request object."

    Could you show a sample of this? What attributes are available?
  • tmparker
    tmparker
    518 Posts

    Re: Setting a global variable based on connection information

    ‏2012-03-28T19:10:30Z  
    • JohnDRazz
    • ‏2012-03-28T17:02:04Z
    Thanks Tim.

    "You could also use this to check session attributes if you needed to from the request object."

    Could you show a sample of this? What attributes are available?
    Hi John,

    Since you are relying on this session key to determine what kind of connection it is, can you tell me where this session key is set? Is it part of the URL in the query string or is it internal in a session attribute? The example I pointed to above, in the previous post I did, showed how to read the URL and you can read the query string to determine what parameters were passed in. Let me know how you need to recognize this and I can help you out.

    Thanks
    Tim
  • JohnDRazz
    JohnDRazz
    34 Posts

    Re: Setting a global variable based on connection information

    ‏2012-03-28T19:23:22Z  
    • tmparker
    • ‏2012-03-28T19:10:30Z
    Hi John,

    Since you are relying on this session key to determine what kind of connection it is, can you tell me where this session key is set? Is it part of the URL in the query string or is it internal in a session attribute? The example I pointed to above, in the previous post I did, showed how to read the URL and you can read the query string to determine what parameters were passed in. Let me know how you need to recognize this and I can help you out.

    Thanks
    Tim
    Tim,

    I shouldn't have used "session key" to describe the data, even though that is what we are calling it. A more exact name is "Host Session Key".

    In this project, HATS is called from a parent application that is message based (and does not use HATS). Before it calls HATS it sends a message to the host which return a Host Session Key. It calls HATS, which is pooled, passing the Host Session Key and Userid, to validate the request. The request is examined on the host. If it is valid, the Host Session Key/Userid is deleted and the user can continue. Otherwise they are forced to exit.

    So I need to know if this particular request is going to a pooled connection - which requires the "Host Session Key", or the non-pooled connection which has come in from the signon screen.
  • tmparker
    tmparker
    518 Posts

    Re: Setting a global variable based on connection information

    ‏2012-03-28T19:59:41Z  
    • JohnDRazz
    • ‏2012-03-28T19:23:22Z
    Tim,

    I shouldn't have used "session key" to describe the data, even though that is what we are calling it. A more exact name is "Host Session Key".

    In this project, HATS is called from a parent application that is message based (and does not use HATS). Before it calls HATS it sends a message to the host which return a Host Session Key. It calls HATS, which is pooled, passing the Host Session Key and Userid, to validate the request. The request is examined on the host. If it is valid, the Host Session Key/Userid is deleted and the user can continue. Otherwise they are forced to exit.

    So I need to know if this particular request is going to a pooled connection - which requires the "Host Session Key", or the non-pooled connection which has come in from the signon screen.
    When you say, "It calls HATS, which is pooled, passing the Host Session Key and Userid, to validate the request." How exactly is this information passed to HATS? Is it in the URL itself?