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

Thread: Custom authorization - 0.8.2 to 0.9 upgrade woes

  1. #11
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    If you put your code in [ code] [ /code] tags, it's sooooo much easier to read. You now need to extend JdbcDaoImpl and override the initMappingSqlQueries method.

    Code:
        /**
         * Extension point to allow other MappingSqlQuery objects to be substituted in a subclass
         */
        protected void initMappingSqlQueries() {
            this.usersByUsernameMapping = new UsersByUsernameMapping(getDataSource());
            this.authoritiesByUsernameMapping = new AuthoritiesByUsernameMapping(getDataSource());
        }

  2. #12
    Join Date
    Feb 2007
    Posts
    8

    Default

    Quote Originally Posted by karldmoore View Post
    If you put your code in [ code] [ /code] tags, it's sooooo much easier to read. You now need to extend JdbcDaoImpl and override the initMappingSqlQueries method.

    Code:
        /**
         * Extension point to allow other MappingSqlQuery objects to be substituted in a subclass
         */
        protected void initMappingSqlQueries() {
            this.usersByUsernameMapping = new UsersByUsernameMapping(getDataSource());
            this.authoritiesByUsernameMapping = new AuthoritiesByUsernameMapping(getDataSource());
        }
    Now I am one step ahead, everything is working fine now except one thing that is when I log in with correct username and password I get the following error message:

    Code:
     
    Reason: SQL 'SELECT LoginName, UserPassword, Email, FirstName, LastName FROM Users WHERE LoginName=?' requires 1 bind variables, but 0 variables were declared for this object; nested exception is org.springframework.dao.InvalidDataAccessApiUsageException: SQL 'SELECT LoginName, UserPassword, Email, FirstName, LastName FROM Users WHERE LoginName=?' requires 1 bind variables, but 0 variables were declared for this object

  3. #13
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    There must be a problem with the query class. Is it possible to have a look at it?

  4. #14
    Join Date
    Feb 2007
    Posts
    8

    Default

    Quote Originally Posted by karldmoore View Post
    There must be a problem with the query class. Is it possible to have a look at it?
    Now I have found out what the problem was, I left out following lines from the constructor

    declareParameter(new SqlParameter(Types.VARCHAR));
    compile();

    Thank you very very much for your help, I really appreciate it.

  5. #15
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    Not a problem, glad it's all working! By the sounds of it, apart from the JdbcDaoImpl changes, it wasn't that much of a problem.

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

    Default

    You are trying to set the query objects on the JdbcDaoImpl, which only has setters for the sql. Look at the code:

    http://monkeymachine.co.uk/acegisecu...bcDaoImpl.html

    Use the approach Karl described above (extending JdbcDaoImpl).

  7. #17
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    I'd be interested to know how you found the upgrade process. There were obviously a couple of hiccups but apart from those, how did it go?

  8. #18
    Join Date
    Feb 2007
    Posts
    8

    Default

    Quote Originally Posted by karldmoore View Post
    I'd be interested to know how you found the upgrade process. There were obviously a couple of hiccups but apart from those, how did it go?
    I didn't actually upgrade, it was my first attempt getting acegi to work since we are considering using it in our business application. I found most of the documentations on the net and I got help from you when it came to jdbcdaoimpl.

  9. #19
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    Ok, my mistake. I read the original title of the thread and thought you were also doing an upgrade.

  10. #20
    Join Date
    Feb 2007
    Posts
    8

    Default

    Quote Originally Posted by karldmoore View Post
    Ok, my mistake. I read the original title of the thread and thought you were also doing an upgrade.
    I would like to use my acegi webapplication as authentication and authorization module for several webapps also a common webapp for security but the problem is with request uri. My acegi webapp has to know which appliacation the request comes from( one way to do this is to have request parameter like &product=netbank ) so that it can redirect again after successful login. The problem is when I use {pageContext.request.contextPath} it gives me context path of acegi webapp not the one the request originally come from. Do you have a suggestion how to get around this ?

Posting Permissions

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