Skip to content

Instantly share code, notes, and snippets.

@Kallin
Created June 22, 2012 18:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kallin/2974275 to your computer and use it in GitHub Desktop.
Save Kallin/2974275 to your computer and use it in GitHub Desktop.
SamlAuthenticationProvider.groovy
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