Search in sources :

Example 11 with AuditRecordFactory

use of password.pwm.svc.event.AuditRecordFactory in project pwm by pwm-project.

the class ActivateUserServlet method handleAgreeRequest.

@ActionHandler(action = "agree")
public ProcessStatus handleAgreeRequest(final PwmRequest pwmRequest) throws ServletException, IOException, PwmUnrecoverableException, ChaiUnavailableException {
    LOGGER.debug(pwmRequest, "user accepted agreement");
    final ActivateUserBean activateUserBean = activateUserBean(pwmRequest);
    if (!activateUserBean.isAgreementPassed()) {
        activateUserBean.setAgreementPassed(true);
        final AuditRecord auditRecord = new AuditRecordFactory(pwmRequest).createUserAuditRecord(AuditEvent.AGREEMENT_PASSED, pwmRequest.getUserInfoIfLoggedIn(), pwmRequest.getSessionLabel(), "ActivateUser");
        pwmRequest.getPwmApplication().getAuditManager().submit(auditRecord);
    }
    return ProcessStatus.Continue;
}
Also used : AuditRecordFactory(password.pwm.svc.event.AuditRecordFactory) AuditRecord(password.pwm.svc.event.AuditRecord) ActivateUserBean(password.pwm.http.bean.ActivateUserBean)

Example 12 with AuditRecordFactory

use of password.pwm.svc.event.AuditRecordFactory in project pwm by pwm-project.

the class ChangePasswordServlet method processAgreeAction.

@ActionHandler(action = "agree")
ProcessStatus processAgreeAction(final PwmRequest pwmRequest) throws ServletException, PwmUnrecoverableException, IOException, ChaiUnavailableException {
    final ChangePasswordBean changePasswordBean = pwmRequest.getPwmApplication().getSessionStateService().getBean(pwmRequest, ChangePasswordBean.class);
    LOGGER.debug(pwmRequest, "user accepted password change agreement");
    if (!changePasswordBean.isAgreementPassed()) {
        changePasswordBean.setAgreementPassed(true);
        final AuditRecord auditRecord = new AuditRecordFactory(pwmRequest).createUserAuditRecord(AuditEvent.AGREEMENT_PASSED, pwmRequest.getUserInfoIfLoggedIn(), pwmRequest.getSessionLabel(), "ChangePassword");
        pwmRequest.getPwmApplication().getAuditManager().submit(auditRecord);
    }
    return ProcessStatus.Continue;
}
Also used : ChangePasswordBean(password.pwm.http.bean.ChangePasswordBean) AuditRecordFactory(password.pwm.svc.event.AuditRecordFactory) AuditRecord(password.pwm.svc.event.AuditRecord)

Example 13 with AuditRecordFactory

use of password.pwm.svc.event.AuditRecordFactory in project pwm by pwm-project.

the class UpdateProfileServlet method handleAgreeRequest.

@ActionHandler(action = "agree")
ProcessStatus handleAgreeRequest(final PwmRequest pwmRequest) throws ServletException, IOException, PwmUnrecoverableException, ChaiUnavailableException {
    LOGGER.debug(pwmRequest, "user accepted agreement");
    final UpdateProfileBean updateProfileBean = getBean(pwmRequest);
    if (!updateProfileBean.isAgreementPassed()) {
        updateProfileBean.setAgreementPassed(true);
        final AuditRecord auditRecord = new AuditRecordFactory(pwmRequest).createUserAuditRecord(AuditEvent.AGREEMENT_PASSED, pwmRequest.getUserInfoIfLoggedIn(), pwmRequest.getSessionLabel(), "UpdateProfile");
        pwmRequest.getPwmApplication().getAuditManager().submit(auditRecord);
    }
    return ProcessStatus.Continue;
}
Also used : AuditRecordFactory(password.pwm.svc.event.AuditRecordFactory) UpdateProfileBean(password.pwm.http.bean.UpdateProfileBean) AuditRecord(password.pwm.svc.event.AuditRecord)

Example 14 with AuditRecordFactory

use of password.pwm.svc.event.AuditRecordFactory in project pwm by pwm-project.

the class TokenService method markTokenAsClaimed.

private void markTokenAsClaimed(final TokenKey tokenKey, final PwmSession pwmSession, final TokenPayload tokenPayload) throws PwmUnrecoverableException {
    if (tokenPayload == null || tokenPayload.getUserIdentity() == null) {
        return;
    }
    final boolean removeOnClaim = Boolean.parseBoolean(configuration.readAppProperty(AppProperty.TOKEN_REMOVE_ON_CLAIM));
    if (removeOnClaim) {
        try {
            LOGGER.trace(pwmSession, "removing claimed token: " + tokenPayload.toDebugString());
            tokenMachine.removeToken(tokenKey);
        } catch (PwmOperationalException e) {
            LOGGER.error(pwmSession, "error clearing claimed token: " + e.getMessage());
        }
    }
    final AuditRecord auditRecord = new AuditRecordFactory(pwmApplication).createUserAuditRecord(AuditEvent.TOKEN_CLAIMED, tokenPayload.getUserIdentity(), pwmSession.getLabel(), JsonUtil.serialize(tokenPayload));
    pwmApplication.getAuditManager().submit(auditRecord);
    StatisticsManager.incrementStat(pwmApplication, Statistic.TOKENS_PASSSED);
}
Also used : AuditRecordFactory(password.pwm.svc.event.AuditRecordFactory) AuditRecord(password.pwm.svc.event.AuditRecord) PwmOperationalException(password.pwm.error.PwmOperationalException)

Example 15 with AuditRecordFactory

use of password.pwm.svc.event.AuditRecordFactory in project pwm by pwm-project.

the class TokenService method generateNewToken.

public String generateNewToken(final TokenPayload tokenPayload, final SessionLabel sessionLabel) throws PwmUnrecoverableException, PwmOperationalException {
    checkStatus();
    final String tokenKey;
    try {
        tokenKey = tokenMachine.generateToken(sessionLabel, tokenPayload);
        tokenMachine.storeToken(tokenMachine.keyFromKey(tokenKey), tokenPayload);
    } catch (PwmException e) {
        final String errorMsg = "unexpected error trying to store token in datastore: " + e.getMessage();
        final ErrorInformation errorInformation = new ErrorInformation(e.getError(), errorMsg);
        throw new PwmOperationalException(errorInformation);
    }
    LOGGER.trace(sessionLabel, "generated token with payload: " + tokenPayload.toDebugString());
    final AuditRecord auditRecord = new AuditRecordFactory(pwmApplication).createUserAuditRecord(AuditEvent.TOKEN_ISSUED, tokenPayload.getUserIdentity(), sessionLabel, JsonUtil.serialize(tokenPayload));
    pwmApplication.getAuditManager().submit(auditRecord);
    return tokenKey;
}
Also used : PwmException(password.pwm.error.PwmException) ErrorInformation(password.pwm.error.ErrorInformation) AuditRecordFactory(password.pwm.svc.event.AuditRecordFactory) AuditRecord(password.pwm.svc.event.AuditRecord) PwmOperationalException(password.pwm.error.PwmOperationalException)

Aggregations

AuditRecordFactory (password.pwm.svc.event.AuditRecordFactory)24 ErrorInformation (password.pwm.error.ErrorInformation)14 UserIdentity (password.pwm.bean.UserIdentity)13 PwmUnrecoverableException (password.pwm.error.PwmUnrecoverableException)10 AuditRecord (password.pwm.svc.event.AuditRecord)10 HelpdeskAuditRecord (password.pwm.svc.event.HelpdeskAuditRecord)10 PwmOperationalException (password.pwm.error.PwmOperationalException)9 HelpdeskProfile (password.pwm.config.profile.HelpdeskProfile)8 RestResultBean (password.pwm.ws.server.RestResultBean)8 ChaiUser (com.novell.ldapchai.ChaiUser)7 PwmSession (password.pwm.http.PwmSession)7 PwmException (password.pwm.error.PwmException)6 PwmApplication (password.pwm.PwmApplication)5 ChaiOperationException (com.novell.ldapchai.exception.ChaiOperationException)4 ChaiUnavailableException (com.novell.ldapchai.exception.ChaiUnavailableException)4 IOException (java.io.IOException)4 Instant (java.time.Instant)4 HashMap (java.util.HashMap)3 List (java.util.List)3 Map (java.util.Map)3