/** * Check if a result generated by this flow is still active. * * @param result {@link AuthenticationResult} to check * * @return true iff the result remains valid */ public boolean isResultActive(@Nonnull final AuthenticationResult result) { Constraint.isNotNull(result, "AuthenticationResult cannot be null"); Constraint.isTrue(result.getAuthenticationFlowId().equals(getId()), "AuthenticationResult was not produced by this flow"); final long now = System.currentTimeMillis(); if (getLifetime() > 0 && result.getAuthenticationInstant() + getLifetime() <= now) { return false; } else if (getInactivityTimeout() > 0 && result.getLastActivityInstant() + getInactivityTimeout() <= now) { return false; } return true; }
do { success = sessionManager.getStorageService().create(getId(), flowId, result, flow, result.getLastActivityInstant() + flow.getInactivityTimeout() + AuthenticationFlowDescriptor.STORAGE_EXPIRATION_OFFSET); if (!success) { result.getLastActivityInstant() + flow.getInactivityTimeout() + AuthenticationFlowDescriptor.STORAGE_EXPIRATION_OFFSET);
/** {@inheritDoc} */ @Override public void updateAuthenticationResultActivity(@Nonnull final AuthenticationResult result) throws SessionException { final String flowId = result.getAuthenticationFlowId(); final AuthenticationFlowDescriptor flow = sessionManager.getAuthenticationFlowDescriptor(flowId); if (flow != null) { try { if (!sessionManager.getStorageService().updateExpiration(getId(), result.getAuthenticationFlowId(), result.getLastActivityInstant() + flow.getInactivityTimeout() + AuthenticationFlowDescriptor.STORAGE_EXPIRATION_OFFSET)) { log.warn("Skipping update, AuthenticationResult for flow {} in session {} not found in storage", flowId, getId()); } } catch (final IOException e) { log.error("Exception updating AuthenticationResult expiration for session {} and flow {}", getId(), flowId, e); if (!sessionManager.isMaskStorageFailure()) { throw new SessionException("Exception updating AuthenticationResult expiration in storage", e); } } } else { log.warn("No flow descriptor installed for ID {}, unable to update result in storage", flowId); } }