IBM Verify

IBM Verify

Join this online user group to communicate across Security product users and IBM experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  error importing java.util.Date class

    Posted Tue February 16, 2021 09:25 AM
    Hi everyone,

    We are at ISAV 10.0.0.1

    In an API protection mapping rule (pre & post token) I am trying to import java.util.Date:

    importClass(Packages.java.util.Date);

    I get the following error:

    tivoli.am.fim.oauth20.protocol.delegates.OAuth20BaseDelegate I returnError com.ibm.security.access.javascript.JSCodeRuntimeException
    Caused by: org.mozilla.javascript.EvaluatorException: Cannot import "Date" since a property by that name is already defined. (xxx-apiPreTokenGeneration#10)

    I just need to instanciate a Date object. Any ideas?

    ------------------------------
    Louis Beaudry
    Access Management
    Intact Financial Corporation
    ------------------------------


  • 2.  RE: error importing java.util.Date class

    Posted Wed February 17, 2021 10:19 AM
    (thanks Leo for the clarification!)

    We're hitting a clash between the java util Date impl and the built in javascript type

    References to the java date type should work - if they are fully qualify. IE:

    var myDate = new java.util.Date()

    Another way to go is to consider using the built in javascript type: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
    which is what I've done and it works very well:

    var myDate = Date.now();

    Cheers,
    Louis

    ------------------------------
    Louis Beaudry
    Access Management
    Intact Financial Corporation
    ------------------------------