Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14

Thread: login by code

  1. #11
    Join Date
    Jan 2005
    Location
    Phoenix, AZ
    Posts
    139

    Default Update for Spring 2.5

    I apologize for resurrecting a thread that's over three years old now, but this is the only thread I saw for this particular topic (programmatic login after a user self-registration) and there's an update for Spring 2.5. The technique described still works just fine, but "Context" has become "SecurityContext" and "ContextHolder" has become "SecurityContextHolder". (Both in package org.acegisecurity.context.) Everything else is the same. So here is the code that I used:

    Code:
    UsernamePasswordAuthenticationToken upat =
        new UsernamePasswordAuthenticationToken(username, password);
    Authentication auth = authMgr.authenticate(upat);
    SecurityContext ctx = SecurityContextHolder.getContext();
    ctx.setAuthentication(auth);
    Hope somebody finds that useful.
    Willie Wheeler
    Author, Spring in Practice (Manning Publications)
    Spring stuff: Tutorials | Blog

  2. #12
    Luke Taylor is offline Senior Member Acegi Security System TeamSpring Team
    Join Date
    Aug 2004
    Location
    Glasgow, Scotland
    Posts
    3,449

    Default

    Spring 2.5? These changes were made in Acegi Security 0.9

    http://acegisecurity.org/upgrade/upgrade-080-090.html

    :-)

  3. #13
    Join Date
    Feb 2008
    Posts
    169

    Default

    Has anything else been updated in the last several years to make this extremely common signup verification and forgotten password technique easier to implement with ACEGI?

  4. #14
    Join Date
    Oct 2007
    Posts
    1

    Default

    An other way to bypass double encoding is simply to change it just before login

    Code:
    DaoAuthenticationProvider daoProvider = ((DaoAuthenticationProvider)SpringApplicationContext.getBean("daoAuthenticationProvider"));
    daoProvider.setPasswordEncoder((PasswordEncoder)SpringApplicationContext.getBean("plainTextPasswordEncoder"));
    daoProvider.setSaltSource(null);
    and then reactive it :

    Code:
    daoProvider.setPasswordEncoder((PasswordEncoder)SpringApplicationContext.getBean("md5PasswordEncoder"));
    daoProvider.setSaltSource((SaltSource)SpringApplicationContext.getBean("reflectionSaltSource"));

Similar Threads

  1. Replies: 13
    Last Post: Oct 24th, 2007, 10:55 AM
  2. Replies: 4
    Last Post: Jun 20th, 2007, 11:06 AM
  3. EHCaching Hibernate
    By dencamel in forum Data
    Replies: 3
    Last Post: Sep 6th, 2005, 09:03 PM
  4. Acegi - Login Tapestry
    By john017 in forum Security
    Replies: 1
    Last Post: Feb 4th, 2005, 01:11 AM
  5. Please help! Unit testing code for JPetStore
    By lakershen in forum Container
    Replies: 4
    Last Post: Jan 13th, 2005, 05:00 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •