As you might have seen in the Quick start tutorial, you need to provide an implementation for IUserAuthenticator, IPasswordEncoder, IUserPermissionListProvider, IRolePermissionListProvider and IUserRoleListProvider to create a domain. Ori is shipped with a very basic implementation for each of them. (They can be found in the ori.impl.provider.xml package)
XmlRolePermissionListProvider implements IRolePermissionListProvider.
It's configuration file looks like that:
<?xml version="1.0"?> <roles> <role name="administrator"> <module name="Secret" actions="read,write"/> <module name="Public" actions="read,write"/> </role> <role name="user"> <module name="Public" actions="read,write"/> </role> </roles>
The code will look like that:
File rolelistFile = new File("src/test/resources/rolelist.xml"); IRoleListProvider roleListProvider = new XmlRoleListProvider(rolelistFile);
XmlMultipleProvider implements IUserAuthenticator,
IUserPermissionListProvider and IUserRoleListProvider.
It's configuration file looks like that:
<?xml version="1.0"?> <users> <user login="a" password="0cc175b9c0f1b6a831c399e269772661" roles="administrator,user" /> <user login="b" password="92eb5ffee6ae2fec3ad71c777531578f" roles="user" /> <user login="c" password="4a8a08f09d37b73795649038408b5f33" roles="user"> <module name="Secret" actions="read" /> </user> </users>
The code will look like that:
File userroleFile = new File("src/test/resources/userrole.xml"); XmlMultipleProvider multipleProvider = new XmlMultipleProvider(userroleFile); IUserAuthenticator userAuthenticator = multipleProvider; IUserPermissionListProvider userPermissionListProvider = multipleProvider; IUserRoleListProvider userRoleListProvider = multipleProvider;
Once you have all of these, you can create you domain (see Quick start)