У меня есть обычная страница авторизации на сервере.
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<ui:composition template="/templates/main.xhtml">
<ui:define name="content">
<h1>#{loginMsg.title}</h1>
<form name="login" id="login" action="/cms/j_security_check" method="post">
<h:outputText value="#{loginMsg.try_again}" styleClass="error"
rendered="#{param.error}"/>
<table class="auth">
<tr>
<th><label for="username">#{loginMsg.login}</label></th>
<td>
<input type="text" id="username" name="j_username" />
<span id="loginError" class="error" style="display: none;">
<br/>
#{commonMsg.empty_field_error}
</span>
</td>
<td> </td>
</tr>
<tr>
<th><label for="password">#{loginMsg.password}</label></th>
<td>
<input type="password" id="password" name="j_password" />
<span id="passwordError" class="error" style="display: none;">
<br/>
#{commonMsg.empty_field_error}
</span>
</td>
<td>
<a href="#" onclick="return auth();" class="login">
#{loginMsg.enter}
</a>
</td>
</tr>
</table>
<input type="submit" style="visibility: hidden;" onclick="return checkForm();"/>
</form>
<script type="text/javascript" src="/cms/js/jquery.js"></script>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery("div#outer").addClass('auth');
var regEx = /^.*MSIE [1-6]\.\d{1}.*$/;
if (navigator.userAgent.match(regEx)) {
window.location = "/cms/403.xhtml"
}
});
jQuery('input').keypress(function(e){
var code = (e.keyCode ? e.keyCode : e.which);
if(code == 13){
e.preventDefault();
auth();
return false;
}
return true;
});
function auth() {
if (checkForm()) {
document.forms['login'].submit();
return true;
}
return false;
}
function checkForm() {
var res = true;
jQuery("#loginError").hide();
jQuery("#passwordError").hide();
if (!jQuery("#username").val()) {
jQuery("#loginError").show();
res = false;
}
if (!jQuery("#password").val()) {
jQuery("#passwordError").show();
res = false;
}
return res;
}
</script>
</ui:define>
</ui:composition>
</html>
После авторизации setMaxInactiveInterval не устанавливается. Устанавливается только после выхода из профиля( и получается что сессия начинается при выходе из профиля и вовзвращаешься на страницу с логином и паролем.
У меня написан
public class HttpSessionTimeoutListener implements HttpSessionListener {
@Override
public void sessionCreated(HttpSessionEvent httpSessionEvent) {
String strLogout = Optional.ofNullable(SystemProperties.get("cms.logout_time")).orElseGet(() -> "10");
try {
System.out.println(new Integer(strLogout));
httpSessionEvent.getSession().setMaxInactiveInterval(new Integer(strLogout));
} catch (NumberFormatException e) {
getLogger().error("e");
}
}
и лисенер к нему.
<listener>
<listener -class>com.bifit.cms.utils.HttpSessionTimeoutListener</listener-class>
</listener>
Почему оно так работает? как мне реализовать логаут? помогите, очень нужно((лемы. Необходимо как-то организовать логаут
Современные инструменты для криптотрейдинга: как технологии помогают принимать решения
Апостиль в Лос-Анджелесе без лишних нервов и бумажной волокиты
Основные этапы разработки сайта для стоматологической клиники
Продвижение своими сайтами как стратегия роста и независимости