Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 11 Next »

A simple user management library. Contains a simple user model and a couple of DAOs, profile and password management components. Current dao implementations are hibernate-based. Should happily replace osuser.

Swaf-user was started long ago, then re-used once I got disapointed with osuser. Still has a couple of old classes or ideas here and there, needs clean up and polishing.

User management

Swaf-user defines a couple of interface for users, groups, permissions, membership management. Much like os-user does, but maybe with a more "modern" architecture.
All these are based on the principles of IOC, using CDI (constructor dependency injection). I'm personnaly using picocontainer, but I believe Spring or any other ioc container should be usable as well.
You will need to declare the implementations you want to use to your container.

User Preferences

Swaf-user defines simple interfaces to define the preferences that an application wants to expose to the end-user, ie what properties s/he can freely modify to suit his needs.
Read more.

Passwords

Swaf-user also defines interfaces and a couple of implementations for

  • password generation strategies (can generate a random password for new users for example)
  • password encoding strategies
  • password retrieval strategies (mail current password, mail newly generated password, ...)
    All these are also based on the principles of IOC/CDI.

Datamodel

The current db schema can be created as follows:

  • create a database called swaf (or other if you want, you'll have to update your jndi configuration accordingly)
  • create a user for swaf and give it the right permissions.
    On mysql, this can be done with the following script:
    create database swaf;
    grant all privileges on swaf.* to 'swaf'@'localhost' identified by 'swaf';
    
  • create the schema itself, using the following script:
    use swaf;
    
    create table user (
       user_id bigint not null auto_increment,
       password varchar(255) not null,
       user_name varchar(32) not null,
       email varchar(128),
       full_name varchar(128),
       primary key (user_id)
    );
    create table group_role (
       group_id bigint not null,
       role varchar(255) not null,
       primary key (group_id, role)
    );
    create table group_properties (
       group_id bigint not null,
       value text,
       name varchar(255) not null,
       primary key (group_id, name)
    );
    create table `group` (
       group_id bigint not null auto_increment,
       group_name varchar(32) not null unique,
       primary key (group_id)
    );
    create table user_properties (
       user_id bigint not null,
       value text,
       name varchar(255) not null,
       primary key (user_id, name)
    );
    create table role (
       name varchar(255) not null,
       primary key (name)
    );
    create table user_group (
       group_id bigint not null,
       user_id bigint not null,
       primary key (user_id, group_id)
    );
    alter table group_role 
      add index FK4C707A36358076 (role), 
      add constraint FK4C707A36358076 foreign key (role) references role (name);
    alter table group_role
      add index FK4C707A361E2E76DB (group_id), 
      add constraint FK4C707A361E2E76DB foreign key (group_id) references `group` (group_id);
    alter table group_properties 
      add index FK1DD636F31E2E76DB (group_id), 
      add constraint FK1DD636F31E2E76DB foreign key (group_id) references `group` (group_id);
    alter table user_properties
      add index FK18623A27F73AEE0F (user_id), 
      add constraint FK18623A27F73AEE0F foreign key (user_id) references user (user_id);
    alter table user_group
      add index FK72A9010B1E2E76DB (group_id), 
      add constraint FK72A9010B1E2E76DB foreign key (group_id) references `group` (group_id);
    alter table user_group
      add index FK72A9010BF73AEE0F (user_id), 
      add constraint FK72A9010BF73AEE0F foreign key (user_id) references user (user_id);
    
  • No labels