import ch.nevis.esauth.auth.engine.AuthResponse

if (inargs['SAMLResponse']) {
  response.setNote('SAMLResponse', inargs['SAMLResponse'])
  request.getInArgs().remove('SAMLResponse')
  response.setResult('processResponse')
  return
}


if (inargs['back'] && inargs['back'] == 'go') {
  response.setStatus(AuthResponse.AUTH_ERROR)
  if (session['ch.nevis.auth.saml.assertion.authnContextClassRef'] && session['ch.nevis.auth.saml.assertion.authnContextClassRef'] == 'urn:qa.agov.ch:names:tc:ac:classes:recovery') {
    response.setTransferDestination(parameters['idp-recovery-url'])
  } else {
    response.setTransferDestination(parameters['idp-sso-url'])
  }
  response.setIsRedirectTransfer(true)
  return
}

// if we reach this line, display the GUI
response.setStatus(AuthResponse.AUTH_CONTINUE)