Mittwoch, Januar 12, 2005

 

How to use the JAZN API to manage OC4J users

Here is a sample code to change the password in the jazn.xml file in usage of the JAZN API:

changeJaznUserPassword(String realm, String userName, String password){

RealmManager realmMgr = JAZNContext.getRealmManager();
Realm realm = realmMgr.getRealm(realm);
UserManager userMgr = realm.getUserManager();
RealmUser user = userMgr.getUser(userName);

XMLRealmUser xmlrealmuser = (XMLRealmUser)realm.getUserManager().getUser(userName);
if(xmlrealmuser == null)
throw new Exception("The specified user does not exist in the system.");
xmlrealmuser.setCredentials(userPwd, serRepeatedPwd);

// to refresh automaticlly you must set the property "external.synchronization = true" in jazn.xml - see previous blog
userMgr.refresh();




<< Home

This page is powered by Blogger. Isn't yours?