Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[higgins-dev] change password functionality in IdAS and JNDI CP

Here's the code I'm using to unit test change password with (this is found in the JNDI CP's test project):

String testSubject = "cn=test,o=higgins";
IContext context;
IDigitalSubject ds;
AuthNNamePasswordMaterials namePW; 

context = _registry.createContext("testcontext2.xrds");
assertNotNull(context);

// Authenticate as test subject using old password
namePW = new AuthNNamePasswordMaterials(context, testSubject, "secret");
context.open(namePW);

// Remove old password attribute value and add a new one
IAttribute pwAttr = namePW.getManagedAttr();
ds.removeAttributeValue(pwAttr);
pwAttr = ds.addAttribute(namePW.getManagedAttrURI());
pwAttr.addSimpleValue(ISimpleAttrValue.STRING_TYPE_URI, "new secret");
context.applyUpdates();

// Now try to authenticate again, using the new password
context.close();
namePW = new AuthNNamePasswordMaterials(context, testSubject, "new secret");
context.open(namePW);

This works against our standalone test LDAP server, I still need to run it against a production LDAP server.

Jim



Back to the top