Search in sources :

Example 1 with NmasResponseSet

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;
    }
}
Also used : ErrorInformation(password.pwm.error.ErrorInformation) NmasResponseSet(com.novell.ldapchai.impl.edir.NmasResponseSet) PwmUnrecoverableException(password.pwm.error.PwmUnrecoverableException) ChaiException(com.novell.ldapchai.exception.ChaiException)

Example 2 with NmasResponseSet

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));
}
Also used : ChaiUser(com.novell.ldapchai.ChaiUser) NmasResponseSet(com.novell.ldapchai.impl.edir.NmasResponseSet) ChaiEntry(com.novell.ldapchai.ChaiEntry)

Aggregations

NmasResponseSet (com.novell.ldapchai.impl.edir.NmasResponseSet)2 ChaiEntry (com.novell.ldapchai.ChaiEntry)1 ChaiUser (com.novell.ldapchai.ChaiUser)1 ChaiException (com.novell.ldapchai.exception.ChaiException)1 ErrorInformation (password.pwm.error.ErrorInformation)1 PwmUnrecoverableException (password.pwm.error.PwmUnrecoverableException)1