use of com.novell.ldapchai.impl.edir.NmasResponseSet in project pwm by pwm-project.
the class NMASCrOperator method writeResponses.
public void writeResponses(final UserIdentity userIdentity, final ChaiUser theUser, final String userGuid, final ResponseInfoBean responseInfoBean) throws PwmUnrecoverableException {
try {
if (theUser.getChaiProvider().getDirectoryVendor() == DirectoryVendor.EDIRECTORY) {
final NmasResponseSet nmasResponseSet = NmasCrFactory.newNmasResponseSet(responseInfoBean.getCrMap(), responseInfoBean.getLocale(), responseInfoBean.getMinRandoms(), theUser, responseInfoBean.getCsIdentifier());
NmasCrFactory.writeResponseSet(nmasResponseSet);
LOGGER.info("saved responses for user using NMAS method ");
}
} catch (ChaiException e) {
final String errorMsg = "error writing responses to nmas: " + e.getMessage();
final ErrorInformation errorInfo = new ErrorInformation(PwmError.ERROR_WRITING_RESPONSES, errorMsg);
final PwmUnrecoverableException pwmOE = new PwmUnrecoverableException(errorInfo);
pwmOE.initCause(e);
throw pwmOE;
}
}
use of com.novell.ldapchai.impl.edir.NmasResponseSet in project ldapchai by ldapchai.
the class ChaiTester method testCreateNmasResponses.
public void testCreateNmasResponses() throws Exception {
final ChaiEntry testContainer = TestHelper.createTestContainer();
final String createDN = "cn=sadams," + testContainer.getEntryDN();
final String createClass = "inetOrgPerson";
final Map<String, String> createAttributes = new HashMap<String, String>();
createAttributes.put("givenName", "Sam");
createAttributes.put("sn", "Adams");
createAttributes.put("title", "Revolutionary");
createAttributes.put("mail", "mc@teaparty.org");
// perform the create operation in eDirectory
TestHelper.getProvider().createEntry(createDN, createClass, createAttributes);
final ChaiUser theUser = ChaiFactory.createChaiUser(createDN, TestHelper.getProvider());
final Map<Challenge, String> crMap = new HashMap<Challenge, String>();
crMap.put(new ChaiChallenge(true, "Got Milk?", 2, 255, true), "yep");
crMap.put(new ChaiChallenge(true, "Zoinks?", 2, 255, true), "Zoinks!");
final NmasResponseSet rs = NmasCrFactory.newNmasResponseSet(crMap, null, 2, theUser, null);
Assert.assertTrue("NMAS Response Writing Test failed", NmasCrFactory.writeResponseSet(rs));
}
Aggregations