I don’t know if this qualifies as a proof-of-concept, but here is a repost of some simple code I wrote to bind CAS authentication to spring authentication for some specific use cases. It implements a CAS AuthenticationHandler using any Spring Security AuthenticationManager. This simple implementation only handles “UsernamePasswordCredentials”.
package com.emc.shared.security.cas.spring; import org.jasig.cas.authentication.principal.Credentials; import org.jasig.cas.authentication.principal.UsernamePasswordCredentials; import org.jasig.cas.authentication.handler.AuthenticationHandler; import org.jasig.cas.authentication.handler.AuthenticationException; import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.crypto.password.StandardPasswordEncoder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; class UsernamePasswordAuthenticationHandler implements AuthenticationHandler { final private Logger logger_ = LoggerFactory.getLogger(UsernamePasswordAuthenticationHandler.class); private AuthenticationManager authManager_; public static void main(String [] args) { StandardPasswordEncoder encoder = new StandardPasswordEncoder(); System.out.println(encoder.encode(args[0])); } public void setAuthenticationManager(AuthenticationManager am) { authManager_ = am; } public AuthenticationManager getAuthenticationManager() { return authManager_; } public boolean supports(final Credentials credentials) { return credentials != null && UsernamePasswordCredentials.class.isAssignableFrom(credentials.getClass()); } public boolean authenticate(Credentials credentials) throws AuthenticationException { try { UsernamePasswordCredentials upCredentials = (UsernamePasswordCredentials) credentials; UsernamePasswordAuthenticationToken upToken = new UsernamePasswordAuthenticationToken(upCredentials.getUsername(), upCredentials.getPassword()); authManager_.authenticate(upToken); upToken.eraseCredentials(); return true; } catch (Exception ex) { logger_.info(ex.toString()); return false; } } } From: Marvin Addison [mailto:marvin.addi...@gmail.com] Sent: Thursday, December 04, 2014 10:07 AM To: cas-dev@lists.jasig.org Subject: Re: [cas-dev] Reducing CASImpl's complexity: ArgExtractors and more There might need to be a detailed comparison and some small proof-of-concepts in order to choose the best. +1 M -- You are currently subscribed to cas-dev@lists.jasig.org<mailto:cas-dev@lists.jasig.org> as: david.oh...@emc.com<mailto:david.oh...@emc.com> To unsubscribe, change settings or access archives, see http://www.ja-sig.org/wiki/display/JSG/cas-dev -- You are currently subscribed to cas-dev@lists.jasig.org as: arch...@mail-archive.com To unsubscribe, change settings or access archives, see http://www.ja-sig.org/wiki/display/JSG/cas-dev