• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Accessing UserMap from InMemoryDaoImpl

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to access the currently loaded UserMap in my web application. To do this, I'm thinking I need to access and instance of the InMemoryDaoImpl object. Can anyone help me on this?
 
Ranch Hand
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well, you query is not actually clear, can you make is simpler it will help others to reply you in right context.
 
Matthew Snow
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, I've been hit with another project and have had to lay this one aside for a while. I'm storing user information in a user.properties file for this application. My goal in the end is to have a My Account page where users can change their passwords and a User Accounts page for administrators to view/create/modify current user accounts.

What I've found so far: I've decided to just inject the InMemoryDAOImpl bean into my application using Spring's inversion of control. Acegi however is very tight about it's UserMap. I can see who is currently logged in and search users by username. I can't, however, select arbitrary user let alone modify the UserMap.

Purposed solution: Since Acegi locks the properties file once it's loaded I can't read from it, let alone modify it. So, I'll have two identical files, one for Acegi and one for viewing all user information. For saving new information, I'll use InMemoryDaoImpl.setUserProperties() to switch between the two files. I just hope Acegi will release the original user.properties file so I can modify it. I'll try this as soon as I get a chance.
 
Matthew Snow
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, it's turned out to be less messy than I thought but it's still kind of underhanded. My guess is that the general idea of this proceedure would work for other authentication implementations such as LDAP, but of course would not involve the use of java.util.Properties as InMemroyDaoImpl does. Basically I have a userService bean with the following properties:

userDetailsService references a bean of class="org.acegisecurity.userdetails.memory.InMemoryDaoImpl". To view all user information, I simply read the keySet() from the userProperties object injected by the PropertiesFactoryBean. Here is the code for saving to the user.properties while acegi still holds it (no switching necesary):

This proceedure does not require the user to reauthenticate upon saving.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic