Created
June 22, 2012 18:05
-
-
Save Kallin/2974275 to your computer and use it in GitHub Desktop.
SamlAuthenticationProvider.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.springframework.security.authentication.dao.DaoAuthenticationProvider | |
import org.springframework.security.core.Authentication | |
import sonicg.authentication.SAMLAuthenticationService | |
class SamlAuthenticationProvider extends DaoAuthenticationProvider { | |
@Override | |
Authentication authenticate(Authentication authentication) { | |
def token = (SamlAuthenticationToken) authentication | |
def user = // define user if credentials check out | |
if (user){ | |
def userDetails = userDetailsService.loadUserByUsername(user.username) | |
def token1 = new SamlAuthenticationToken(userDetails, token.samlResponse) | |
return token1 | |
}else{ | |
return null | |
} | |
} | |
@Override | |
public boolean supports(Class<? extends Object> authentication) { | |
return (SamlAuthenticationToken.class.isAssignableFrom(authentication)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment