WSO2 UserManager 0.6, Guide to using User Manager
[Download] | [Documentation Home] | [Release Note]
Table of Contents
- Overview of UserManager
- Compiling with UserManager
- Coding with UserManager
- Connecting to Existing User Stores
- Creating your own User Stores
- Using a AuthorizingRealm
Overview of UserManager
WSO2 UserManager uses Realms to connect to user stores. For example org.wso2.usermanager.custom.jdbc.JDBCRealm can connect to relational databases to authenticate users. Following is the list of Realms with their speciality. All Realms implement the org.wso2.usermanager.Realm interface. Therefore your application can switch back and forth between Realms.
| Realm Name | Description |
|---|---|
| JDBCRealm | Authenticate users in relational databases |
| LDAPRealm | Authenticate users in company LDAP to Authenticate users |
| AcegiRealm | Authenticate users in Acegi user stores |
| DefaultRealm | Create/manage/querry users. The database can be created using the scripts provided or by calling utility methods. |
| AuthorizingRealm | This realm wraps other realms. It calls isUserAuthorized() method before performing actions. |
Coding with UserManager
Using the Realm interface is accompanied by 5 other interfaces. Using the Realm interface we can get objects that implement these interfaces. They can manipute or read UserStore.
| Interface | Realm Interface Method | Description |
|---|---|---|
| org.wso2.usermanager.Authenticator | getAuthenticator() | Authenticate users. |
| org.wso2.usermanager.AccessControlAdmin | getAccessControlAdmin() | Add/edit/delete Authorization on users/roles/resources |
| org.wso2.usermanager.Authorizer | getAuthorizer() | Can check for authorizations |
| org.wso2.usermanager.UserStoreAdmin | getUserStoreAdmin() | Add/edit/delete users. |
| org.wso2.usermanager.UserStoreReader | getUserStoreReader() | Querry user details. |
This is how you initialize and use the realm.
Realm realm = new XYZRealm();
XYZRealmConfig config = (XYZRealmConfig) realm
.getRealmConfiguration();
/*Call setter methods on the configuration object*/
config.set.......
config.set.......
realm.init(config);
realm.getAuthenticator().authenticate("anne", "annepass");
For more details on configuration baen parameters please refer Configuration Manual
Compiling with UserManager
You only need the usermanager-core.jar and usemanager-config.jar. Other libraries depends on the type of Realm that you are using.
| Realm Name | Required Additional Libraries |
|---|---|
| JDBCRealm | Only the jar containing the JDBC driver of your choice |
| LDAPRealm | naming-factory.jar, naming-factory-dbcp.jar, naming-resources.jar |
| AcegiRealm | spring.jar, acegi-security.jar |
| DefaultRealm | Only the jar containing the JDBC driver of your choice |
| AuthorizingRealm | - None - |
Connecting to Existing User Stores
When connecting to existing user stores you only perform Authentication. The following realms are the Realms that you can use for this purpose
- JDBCRealm
- LDAPRealm
- AcegiRealm
Creating your own User Stores
When your application wants to create and maintain users in your own database Default Realm can be used. It is a fully pleged Realm where users/roles and permissions can be created/managed and querried.
Using a AuthorizingRealm
AuthorizingRealm wraps another Realm inside it along with a username. Before calling the actions it calls isUserAuthorized() method for the authenticated user.