First, thanks a lot for all replies to my question.
I find the this way to be the simplest.
(Please let us know if you see any problems with this solution)

1. Download and compile the attached code (rename to .java)
2. Deploy .class to $CAS_HOME/WEB-INF/classes  (in this case to package 
'classes/se/gu/cas/')
3. Edit $CAS_HOME/WEB-INF/deployerConfigContext.xml
   Comment out:
   <bean 
class="org.jasig.cas.authentication.principal.UsernamePasswordCredentialsToPrincipalResolver"
 
/>
   Replace with our new bean:
   <bean 
class="se.gu.cas.CustomUsernamePasswordCredentialsToPrincipalResolver" />
4. Restart server and test!

Done!



Pablo Millet
University of Gothenburg
Running CAS 3.3



Pablo Millet wrote:
> As LDAP binding is not case-sensitive users can login with uppercase as 
> userid and run in to problems later on when navigating to other 
> case-sensitive CAS-clients.
>
> I use org.jasig.cas.adaptors.ldap.FastBindLdapAuthenticationHandler as 
> authenticationhandler.
> With CAS2 I solved it simply by doing toLowerCase on 
> TicketGrantingTicket creation.
>
> Question;
> I need to convert userid's toLowerCase in CAS3.
> Before I go ahead I'd like to ask you if you done this already and if 
> you have any recommendations or 'best practice' on where and how to do 
> the lower-case convertion?
> Can I do this the "Spring" way somehow... any examples?
>
> Thanx
> - Pablo
> Running CAS 3.3
>
>
>
>   


-- 
____________________________________________
Pablo Millet
IT-Service
Göteborgs universitet

Tel.: 031 – 786 5342
Mob.: 0707 - 10 40 70
www.it.gu.se


-- 
You are currently subscribed to [email protected] as: 
[email protected]
To unsubscribe, change settings or access archives, see 
http://www.ja-sig.org/wiki/display/JSG/cas-user

package se.gu.cas;

import org.jasig.cas.authentication.principal.*;

/**
 * CustomUsernamePasswordCredentialsToPrincipalResolver
 *
 */

public class CustomUsernamePasswordCredentialsToPrincipalResolver extends 
AbstractPersonDirectoryCredentialsToPrincipalResolver {
    
    protected String extractPrincipalId(final Credentials credentials) {

        
        // Lowercase, trim and finally return userid.
        final UsernamePasswordCredentials usernamePasswordCredentials = 
(UsernamePasswordCredentials) credentials;
        return usernamePasswordCredentials.getUsername().toLowerCase().trim();

        
        /* The following rows does the same as above */
        
        /* Get credentials */
        //final UsernamePasswordCredentials usernamePasswordCredentials = 
(UsernamePasswordCredentials) credentials;
        
        /* From here you can do whatever you like with 'userid'. */
        //String userid =  
usernamePasswordCredentials.getUsername().toLowerCase().trim();
        
        /* Example: convert to lowercase */
        //userid = userid.toLowerCase();
        
        /* Example: delete whitespace before and after */
        //userid = userid.trim();
        
        /* return new userid */
        //return userid;
        
    }

    public boolean supports(final Credentials credentials) {
        return credentials != null && 
UsernamePasswordCredentials.class.isAssignableFrom(credentials.getClass());
    }
    
}

Reply via email to