Hi,
The code checks whether user has authenticated with any possible method (including the 'anonymous' or 'remember me' authentication when enabled). In case you want to check whether SAML SSO (and no other authentication) took place, something like this might work instead:
Code:
public boolean isLoggedInWithSAML() {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication == null) {
return false;
} else if (authentication.isAuthenticated() && (authentication.getCredentials() != null && authentication.getCredentials().equals(SAMLCredential.class))) {
return true;
} else {
return false;
}
}
Vladi