String sId = value.substring(firstSeparator + 1, lastSeparator);
int stateId = 0;
try {
stateId = Integer.parseInt(sId);
} catch (NumberFormatException e) {
throw new HDIVException(HDIVErrorCodes.PAGE_ID_INCORRECT);
}
StateScope stateScope = this.stateScopeManager.getStateScope(value);
if (stateScope != null) {
String token = stateScope.getStateToken(stateId);
return requestSuffix.equals(token);
}
IPage currentPage = session.getPage(pageId);
if (currentPage == null) {
if (log.isErrorEnabled()) {
log.error("Page with id [" + pageId + "] not found in session.");
}
throw new HDIVException(HDIVErrorCodes.PAGE_ID_INCORRECT);
}
return currentPage.getRandomToken(restoredState.getMethod()).equals(requestSuffix);
} catch (IndexOutOfBoundsException e) {
String errorMessage = HDIVUtil.getMessage("validation.error", e.getMessage());
if (log.isErrorEnabled()) {
log.error(errorMessage);
}
throw new HDIVException(errorMessage, e);
}
}