} finally {
try {
// if the destination is null, probably because some error occur during authentication, use the AuthnRequest
// AssertionConsumerServiceURL as the destination
if (destination == null && samlObject instanceof AuthnRequestType) {
AuthnRequestType authRequest = (AuthnRequestType) samlObject;
destination = authRequest.getAssertionConsumerServiceURL().toASCIIString();
}
// if destination is still empty redirect the user to the identity url. If the user is already authenticated he
// will be probably redirected to the idp hosted page.
if (destination == null) {