try {
  def user = inargs['UserID'] ?: session['ch.adnovum.nevisidm.user.extId'] ?: 'unknown'
  def techuser = session['agov.techuser.extId'] ?: 'unknown'
  def sourceIp = request.getTransportLayerInformation().getRemoteIP() ?: 'unknown'
  def credentialType = request.getResource().replaceAll("\\/nevisauth\\/services\\/sts\\/(.+)\\/", "\$1").toUpperCase()
  def lasterrorinfo = notes.getProperty('lasterrorinfo', '-')
  def lasterror = notes.getProperty('lasterror', '-')

  if (credentialType=='SAML') {
    credentialType = 'PASSWORD'
  }
  LOG.warn("Event='TKNFAILED', Techuser=${techuser}, User=${user}, CredentialType='${credentialType}', SourceIp=${sourceIp}, lasterrorinfo='${lasterrorinfo}', lasterror=${lasterror}")
} catch (Exception e) {
  LOG.warn("Exception in Script: ${e}")
} finally {
  response.setResult('ok')
}