Message Image  

IBM Security Verify

 View Only
Expand all | Collapse all

Is there anyway I can make asynchronously in ISAM Infomap javascript??

  • 1.  Is there anyway I can make asynchronously in ISAM Infomap javascript??

    Posted Mon November 23, 2020 09:51 AM

    <lightning-formatted-text data-aura-rendered-by="2:907;a">

    <lightning-formatted-text data-aura-rendered-by="2:958;a"> The ISAM infomap Authentication Mechanism require to make a asynchronously httpclient request call to insert a logging record without expecting the response coming back. I wasn't<lightning-formatted-text data-aura-rendered-by="2:907;a"><lightning-formatted-text data-aura-rendered-by="2:907;a"> able to make because it doesn't support setTimeout(func, 0);.</lightning-formatted-text></lightning-formatted-text></lightning-formatted-text>

    Is there anyway I can make asynchronously in ISAM Infomap? What is the syntax to make a asynchronously ?

    <lightning-formatted-text data-aura-rendered-by="2:907;a">Below I have the javascirpt infomap snippet code trying to implement the asynchronously that doesn't work. 

    </lightning-formatted-text>

    importClass(Packages.com.tivoli.am.fim.fedmgr2.trust.util.LocalSTSClient);
    importClass(Packages.com.tivoli.am.fim.trustserver.sts.utilities.IDMappingExtUtils);
    importClass(Packages.com.tivoli.am.fim.base64.BASE64Utility);
    importClass(Packages.com.tivoli.am.fim.trustserver.sts.STSUniversalUser);

    importClass(Packages.com.ibm.security.access.httpclient.HttpClient);
    importClass(Packages.com.ibm.security.access.httpclient.HttpResponse);
    importClass(Packages.com.ibm.security.access.httpclient.Headers);
    importClass(Packages.com.ibm.security.access.httpclient.Parameters);

    var debug = true;
    var TAG = "EssloggingDebug:- ";

    function printString(traceString) {

    if (debug == true) {
    IDMappingExtUtils.traceString(TAG + traceString);
    }

    }

    function executeAsync(func) {
    setTimeout(func, 0);
    }

    executeAsync(function() {


    var jsonData ="";

    var isam_kdb_ssl = "isam_mob";
    printString("isam_kdb_ssl : " + isam_kdb_ssl);

    var personal_cert_cn = "isam_mob";
    printString("personal_cert_cn : " + personal_cert_cn);

    var hr = new HttpResponse();
    var headersPost = new Headers();

    var url = "https://domain:8443/ESS/services/";
    printString("url : " + url);

    var strJson = '{'
    +'"ess_process_timestamp": "2020-08-14 19:25:31.344Z",'
    +'"trace_id": "69b97f1b69077eff",'
    +'"event_channel_code": ""'
    +'}';
    try{

    printTraceString(DEBUG, "strJson : " + strJson);

    headersPost.addHeader("Content-Type", "application/json");
    headersPost.addHeader("event_timestamp", "2020-08-14 19:25:30Z");
    headersPost.addHeader("source_application_code", "ABCD");

    // https://www.stephen-swann.co.uk/javadoc/sam9.0/com.ibm.security.access.common/com/ibm/security/access/httpclient/HttpClient.html
    // httpPost(java.lang.String urlstr,
    // Headers headers,
    // java.lang.String body,
    // java.lang.String httpsTrustStore,
    // java.lang.String basicAuthUsername,
    // java.lang.String basicAuthPassword,
    // java.lang.String clientKeyStore,
    // java.lang.String clientKeyAlias)

    hr = HttpClient.httpPost(url, headersPost, strJson, isam_kdb_ssl, null, null, isam_kdb_ssl, personal_cert_cn);


    }catch(err){
    printTraceString(DEBUG, "esslog catched error : " + err);
    }
    });</lightning-formatted-text>[Less]



    ------------------------------
    Bet Ming Chong
    ------------------------------


  • 2.  RE: Is there anyway I can make asynchronously in ISAM Infomap javascript??

    Posted Mon November 23, 2020 11:10 AM
    Hello Bet Ming,

    I don't think it is possible to have an asynchronous call within the JavaScript code that runs in the InfoMap rules.

    However, there is a version of the HTTP call which includes a timeout parameter:

    httpPost(java.lang.String urlstr, Headers headers, Parameters params, java.lang.String httpsTrustStore, java.lang.String basicAuthUsername, java.lang.String basicAuthPassword, java.lang.String clientKeyStore, java.lang.String clientKeyAlias, java.lang.String protocol, boolean throwException, int timeout)

    The timeout is in seconds.  If you set timeout to 1, perhaps that would cause the code to continue after 1 second even if no response returned.  Would that help you?

    One warning on this.  The HttpClient helper has a built-in retry loop which makes 3 attempts.  This might be triggered by the timeout (meaning a total wait of 3 seconds) which would not be good for you.  If you are using Verify Access v10 then there is also HttpClientV2 helper which has an advanced property which allows retry to be disabled.

    https://www.ibm.com/support/knowledgecenter/SSPREK_10.0.0/com.ibm.isva.doc/config/reference/ref_fed_override_configs.htm#advconfig__d246e2597

    I'm not sure any of this will help but it is all I can suggest.  Your alternative will be to have some external system which responds to these HTTP requests immediately and then queues them for transmission to the real endpoint.

    Since you're looking at audit/log type processing here, I'd also say that Verify Access has built in support for remote syslog which is asynchronous.  You could use this by writing an audit message from your InfoMap and then send audit log to rsyslog server.

    Jon.

    ------------------------------
    Jon Harry
    Consulting IT Security Specialist
    IBM
    ------------------------------