Commit dcfe3863 authored by michael.simon's avatar michael.simon
Browse files

Add more messages to user display

parent 4ff0ab13
...@@ -76,7 +76,7 @@ public class TwoFaUserBean implements Serializable { ...@@ -76,7 +76,7 @@ public class TwoFaUserBean implements Serializable {
try { try {
tokenList = twoFaService.findByIdentity(identity); tokenList = twoFaService.findByIdentity(identity);
} catch (TwoFaException e) { } catch (TwoFaException e) {
messageGenerator.addErrorMessage("Error", e.toString()); messageGenerator.addErrorMessage("messagePanel", "Error", e.toString());
logger.debug("Exception happened", e); logger.debug("Exception happened", e);
} }
...@@ -108,10 +108,11 @@ public class TwoFaUserBean implements Serializable { ...@@ -108,10 +108,11 @@ public class TwoFaUserBean implements Serializable {
checkResponse.getResult().isValue())) { checkResponse.getResult().isValue())) {
// Token creating was successful, but check failed // Token creating was successful, but check failed
twoFaService.deleteToken(identity, serial, "identity-" + identity.getId()); twoFaService.deleteToken(identity, serial, "identity-" + identity.getId());
messageGenerator.addResolvedWarningMessage("warn", "twofa_token_failed", true); messageGenerator.addResolvedWarningMessage("messagePanel", "warn", "twofa_token_init_code_wrong", true);
} }
else { else {
twoFaService.initToken(identity, serial, "identity-" + identity.getId()); twoFaService.initToken(identity, serial, "identity-" + identity.getId());
messageGenerator.addInfoMessage("messagePanel", "Info", "Token " + serial + " created");
} }
} }
...@@ -123,7 +124,7 @@ public class TwoFaUserBean implements Serializable { ...@@ -123,7 +124,7 @@ public class TwoFaUserBean implements Serializable {
tokenList = twoFaService.findByIdentity(identity); tokenList = twoFaService.findByIdentity(identity);
} }
else { else {
messageGenerator.addResolvedWarningMessage("warn", "twofa_token_failed", true); messageGenerator.addResolvedWarningMessage("messagePanel", "warn", "twofa_token_failed", true);
} }
PrimeFaces.current().executeScript("PF('addYubicoDlg').hide();"); PrimeFaces.current().executeScript("PF('addYubicoDlg').hide();");
...@@ -132,7 +133,7 @@ public class TwoFaUserBean implements Serializable { ...@@ -132,7 +133,7 @@ public class TwoFaUserBean implements Serializable {
} catch (TwoFaException e) { } catch (TwoFaException e) {
logger.warn("TwoFaException", e); logger.warn("TwoFaException", e);
messageGenerator.addResolvedWarningMessage("warn", "twofa_token_failed", true); messageGenerator.addResolvedWarningMessage("messagePanel", "warn", "twofa_token_failed", true);
PrimeFaces.current().executeScript("PF('addYubicoDlg').hide();"); PrimeFaces.current().executeScript("PF('addYubicoDlg').hide();");
createTokenResponse = null; createTokenResponse = null;
yubicoCode = ""; yubicoCode = "";
...@@ -150,6 +151,7 @@ public class TwoFaUserBean implements Serializable { ...@@ -150,6 +151,7 @@ public class TwoFaUserBean implements Serializable {
String serial = response.getDetail().getSerial(); String serial = response.getDetail().getSerial();
twoFaService.initToken(identity, serial, "identity-" + identity.getId()); twoFaService.initToken(identity, serial, "identity-" + identity.getId());
messageGenerator.addInfoMessage("messagePanel", "Info", "Token " + serial + " created");
} }
if (! hasActiveToken()) { if (! hasActiveToken()) {
...@@ -158,9 +160,10 @@ public class TwoFaUserBean implements Serializable { ...@@ -158,9 +160,10 @@ public class TwoFaUserBean implements Serializable {
} }
tokenList = twoFaService.findByIdentity(identity); tokenList = twoFaService.findByIdentity(identity);
} }
else { else {
messageGenerator.addResolvedWarningMessage("warn", "twofa_token_failed", true); messageGenerator.addResolvedWarningMessage("messagePanel", "warn", "twofa_token_failed", true);
} }
PrimeFaces.current().executeScript("PF('addBackupTanDlg').hide();"); PrimeFaces.current().executeScript("PF('addBackupTanDlg').hide();");
...@@ -201,6 +204,8 @@ public class TwoFaUserBean implements Serializable { ...@@ -201,6 +204,8 @@ public class TwoFaUserBean implements Serializable {
sessionManager.setTwoFaElevation(Instant.now()); sessionManager.setTwoFaElevation(Instant.now());
} }
messageGenerator.addInfoMessage("messagePanel", "Info", "Token " + serial + " created");
tokenList = twoFaService.findByIdentity(identity); tokenList = twoFaService.findByIdentity(identity);
PrimeFaces.current().executeScript("PF('addTotpDlg').hide();"); PrimeFaces.current().executeScript("PF('addTotpDlg').hide();");
createTokenResponse = null; createTokenResponse = null;
...@@ -210,6 +215,7 @@ public class TwoFaUserBean implements Serializable { ...@@ -210,6 +215,7 @@ public class TwoFaUserBean implements Serializable {
// wrong code, disable token // wrong code, disable token
response = twoFaService.disableToken(identity, serial, "identity-" + identity.getId()); response = twoFaService.disableToken(identity, serial, "identity-" + identity.getId());
totpCode = ""; totpCode = "";
messageGenerator.addResolvedWarningMessage("totp_messages", "warning", "twofa_token_init_code_wrong", true);
} }
} }
} }
...@@ -225,14 +231,14 @@ public class TwoFaUserBean implements Serializable { ...@@ -225,14 +231,14 @@ public class TwoFaUserBean implements Serializable {
tokenList = twoFaService.findByIdentity(identity); tokenList = twoFaService.findByIdentity(identity);
if ((response.getResult() != null) && response.getResult().isStatus() && if ((response.getResult() != null) && response.getResult().isStatus() &&
response.getResult().isValue()) { response.getResult().isValue()) {
messageGenerator.addInfoMessage("Info", "Token " + serial + " enabled"); messageGenerator.addInfoMessage("messagePanel", "Info", "Token " + serial + " enabled");
} }
else { else {
messageGenerator.addWarningMessage("Warn", "Token " + serial + " could not be enabled"); messageGenerator.addWarningMessage("messagePanel", "Warn", "Token " + serial + " could not be enabled");
} }
} catch (TwoFaException e) { } catch (TwoFaException e) {
logger.warn("TwoFaException", e); logger.warn("TwoFaException", e);
messageGenerator.addErrorMessage("Error", e.toString()); messageGenerator.addErrorMessage("messagePanel", "Error", e.toString());
} }
} }
} }
...@@ -244,14 +250,14 @@ public class TwoFaUserBean implements Serializable { ...@@ -244,14 +250,14 @@ public class TwoFaUserBean implements Serializable {
tokenList = twoFaService.findByIdentity(identity); tokenList = twoFaService.findByIdentity(identity);
if ((response.getResult() != null) && response.getResult().isStatus() && if ((response.getResult() != null) && response.getResult().isStatus() &&
response.getResult().isValue()) { response.getResult().isValue()) {
messageGenerator.addInfoMessage("Info", "Token " + serial + " disabled"); messageGenerator.addInfoMessage("messagePanel", "Info", "Token " + serial + " disabled");
} }
else { else {
messageGenerator.addWarningMessage("Warn", "Token " + serial + " could not be disable"); messageGenerator.addWarningMessage("messagePanel", "Warn", "Token " + serial + " could not be disable");
} }
} catch (TwoFaException e) { } catch (TwoFaException e) {
logger.warn("TwoFaException", e); logger.warn("TwoFaException", e);
messageGenerator.addErrorMessage("Error", e.toString()); messageGenerator.addErrorMessage("messagePanel", "Error", e.toString());
} }
} }
} }
...@@ -263,14 +269,14 @@ public class TwoFaUserBean implements Serializable { ...@@ -263,14 +269,14 @@ public class TwoFaUserBean implements Serializable {
tokenList = twoFaService.findByIdentity(identity); tokenList = twoFaService.findByIdentity(identity);
if ((response.getResult() != null) && response.getResult().isStatus() && if ((response.getResult() != null) && response.getResult().isStatus() &&
response.getResult().isValue()) { response.getResult().isValue()) {
messageGenerator.addInfoMessage("Info", "Token " + serial + " deleted"); messageGenerator.addInfoMessage("messagePanel", "Info", "Token " + serial + " deleted");
} }
else { else {
messageGenerator.addWarningMessage("Warn", "Token " + serial + " could not be deleted"); messageGenerator.addWarningMessage("messagePanel", "Warn", "Token " + serial + " could not be deleted");
} }
} catch (TwoFaException e) { } catch (TwoFaException e) {
logger.warn("TwoFaException", e); logger.warn("TwoFaException", e);
messageGenerator.addErrorMessage("Error", e.toString()); messageGenerator.addErrorMessage("messagePanel", "Error", e.toString());
} }
} }
} }
......
...@@ -107,6 +107,7 @@ public class FacesMessageGenerator { ...@@ -107,6 +107,7 @@ public class FacesMessageGenerator {
} }
public void addMessage(String msgName, Severity severity, String messageText, String detail) { public void addMessage(String msgName, Severity severity, String messageText, String detail) {
FacesContext.getCurrentInstance().getExternalContext().getFlash().setKeepMessages(true);
FacesContext.getCurrentInstance().addMessage(msgName, FacesContext.getCurrentInstance().addMessage(msgName,
new FacesMessage(severity, messageText, detail)); new FacesMessage(severity, messageText, detail));
} }
......
...@@ -467,6 +467,7 @@ twofa_login_text=Um die angeforderte Aktion durchzuf\u00FChren, muss ein zweiter ...@@ -467,6 +467,7 @@ twofa_login_text=Um die angeforderte Aktion durchzuf\u00FChren, muss ein zweiter
twofa_list_really_readonly=Ihre zweiten Faktoren werden an dieser Stelle nur gepr\u00FCft. Die Verwaltung Ihrer zweiten Faktoren finden Sie bei der folgenden Webadresse\: twofa_list_really_readonly=Ihre zweiten Faktoren werden an dieser Stelle nur gepr\u00FCft. Die Verwaltung Ihrer zweiten Faktoren finden Sie bei der folgenden Webadresse\:
twofa_mandatory=F\u00FCr diesen Dienst ist es notwendig einen zweiten Faktor einzurichten. Bitte richten Sie sich <a href\="../user/twofa.xhtml?retsid\=$service.id">hier</a> einen zweiten Faktor ein. twofa_mandatory=F\u00FCr diesen Dienst ist es notwendig einen zweiten Faktor einzurichten. Bitte richten Sie sich <a href\="../user/twofa.xhtml?retsid\=$service.id">hier</a> einen zweiten Faktor ein.
twofa_serial=Serial twofa_serial=Serial
twofa_token_init_code_wrong=Der Code stimmt nicht \u00FCberein. Bitte versuchen Sie es erneut.
twofa_token_not_init=Token ist nicht initialisiert worden twofa_token_not_init=Token ist nicht initialisiert worden
twofa_tokentype=Toketyp twofa_tokentype=Toketyp
twofa_tokentype_tanlist=Backup TAN Liste twofa_tokentype_tanlist=Backup TAN Liste
......
...@@ -467,6 +467,7 @@ twofa_login_text=To perform the requested action, a second factor must be entere ...@@ -467,6 +467,7 @@ twofa_login_text=To perform the requested action, a second factor must be entere
twofa_list_really_readonly=Your second factors are only checked at this point. The administration of your second factors can be found at the following web address\: twofa_list_really_readonly=Your second factors are only checked at this point. The administration of your second factors can be found at the following web address\:
twofa_mandatory=For this service it is necessary to set up a second factor. Please set up a second factor <a href\="../user/twofa.xhtml?retsid\=$service.id">here</a>. twofa_mandatory=For this service it is necessary to set up a second factor. Please set up a second factor <a href\="../user/twofa.xhtml?retsid\=$service.id">here</a>.
twofa_serial=Serial twofa_serial=Serial
twofa_token_init_code_wrong=The code does not match. Please try again.
twofa_token_not_init=Token has not been initialised twofa_token_not_init=Token has not been initialised
twofa_tokentype=Tokentype twofa_tokentype=Tokentype
twofa_tokentype_tanlist=Backup TAN list twofa_tokentype_tanlist=Backup TAN list
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
<ui:define name="content"> <ui:define name="content">
<h:form id="form" class="full fancy form"> <h:form id="form" class="full fancy form">
<div><p:messages showDetail="true" /></div> <p:messages id="messagePanel" showDetail="true" />
<p:outputPanel rendered="#{twoFaUserBean.reallyReadOnly}"> <p:outputPanel rendered="#{twoFaUserBean.reallyReadOnly}">
<h3>#{messages.twofa_list}</h3> <h3>#{messages.twofa_list}</h3>
...@@ -77,7 +77,7 @@ ...@@ -77,7 +77,7 @@
</p:dataGrid> </p:dataGrid>
</p:outputPanel> </p:outputPanel>
<p:dataGrid var="token" value="#{twoFaUserBean.tokenList}" columns="2" styleClass="whitefoot" <p:dataGrid id="tokenDisplayPanel" var="token" value="#{twoFaUserBean.tokenList}" columns="2" styleClass="whitefoot"
layout="grid" style="margin-bottom: 16px;" rendered="#{! twoFaUserBean.readOnly}"> layout="grid" style="margin-bottom: 16px;" rendered="#{! twoFaUserBean.readOnly}">
<f:facet name="header">#{messages.twofa_list}</f:facet> <f:facet name="header">#{messages.twofa_list}</f:facet>
<p:panel style="margin-bottom: 0px;"> <p:panel style="margin-bottom: 0px;">
...@@ -161,13 +161,15 @@ ...@@ -161,13 +161,15 @@
<p:dialog header="#{messages.twofa_create_totp_token}" <p:dialog header="#{messages.twofa_create_totp_token}"
widgetVar="addTotpDlg" id="addTotpDlgId" modal="true" closable="true" closeOnEscape="true" widgetVar="addTotpDlg" id="addTotpDlgId" modal="true" closable="true" closeOnEscape="true"
showEffect="fade" hideEffect="fade"> showEffect="fade" hideEffect="fade">
<p:ajax event="close" update="@form" /> <p:ajax event="close" update=":form:tokenDisplayPanel" />
<div class="panel" style="width:520px;"> <div class="panel" style="width:520px;">
<h:outputText value="#{messages.twofa_create_totp_token_desc}" escape="false" /> <h:outputText value="#{messages.twofa_create_totp_token_desc}" escape="false" />
</div> </div>
<p:panel id="totpResponsePanel" style="height: 260px;">
<p:panel id="totpResponsePanel" style="height: 300px;">
<p:messages id="totp_messages" showDetail="true" />
<p:commandButton id="totpStartButton" action="#{twoFaUserBean.createAuthenticatorToken()}" value="#{messages.start}" <p:commandButton id="totpStartButton" action="#{twoFaUserBean.createAuthenticatorToken()}" value="#{messages.start}"
update="totpResponsePanel" oncomplete="PF('addTotpDlg').initPosition()" rendered="#{empty twoFaUserBean.createTokenResponse}"/> update="totpResponsePanel" oncomplete="PF('addTotpDlg').initPosition()" rendered="#{empty twoFaUserBean.createTokenResponse}"/>
<h:panelGroup rendered="#{not empty twoFaUserBean.createTokenResponse}"> <h:panelGroup rendered="#{not empty twoFaUserBean.createTokenResponse}">
...@@ -184,7 +186,7 @@ ...@@ -184,7 +186,7 @@
<p:inputText id="totpText" autocomplete="false" value="#{twoFaUserBean.totpCode}"/> <p:inputText id="totpText" autocomplete="false" value="#{twoFaUserBean.totpCode}"/>
</h:panelGrid> </h:panelGrid>
<p:commandButton id="checkTotpButton" action="#{twoFaUserBean.checkAuthenticatorToken()}" value="#{messages.check}" <p:commandButton id="checkTotpButton" action="#{twoFaUserBean.checkAuthenticatorToken()}" value="#{messages.check}"
update="totpResponsePanel" /> update="totpResponsePanel, :form:messagePanel" />
</p:outputPanel> </p:outputPanel>
<p:outputLabel for="@next" value="Seed:" /> <p:outputLabel for="@next" value="Seed:" />
...@@ -198,7 +200,7 @@ ...@@ -198,7 +200,7 @@
<p:dialog header="#{messages.twofa_create_yubico_token}" <p:dialog header="#{messages.twofa_create_yubico_token}"
widgetVar="addYubicoDlg" id="addYubicoDlgId" modal="true" closable="true" closeOnEscape="true" widgetVar="addYubicoDlg" id="addYubicoDlgId" modal="true" closable="true" closeOnEscape="true"
showEffect="fade" hideEffect="fade"> showEffect="fade" hideEffect="fade">
<p:ajax event="close" update="@form" /> <p:ajax event="close" update=":form:tokenDisplayPanel" />
<div class="panel" style="width:360px;"> <div class="panel" style="width:360px;">
<h:outputText value="#{messages.twofa_create_yubico_token_desc}" escape="false" /> <h:outputText value="#{messages.twofa_create_yubico_token_desc}" escape="false" />
</div> </div>
...@@ -209,7 +211,7 @@ ...@@ -209,7 +211,7 @@
<p:inputText id="yubicoText" autocomplete="false" value="#{twoFaUserBean.yubicoCode}"/> <p:inputText id="yubicoText" autocomplete="false" value="#{twoFaUserBean.yubicoCode}"/>
</h:panelGrid> </h:panelGrid>
<p:commandButton id="yubicoStartButton" action="#{twoFaUserBean.createYubicoToken()}" value="#{messages.start}" <p:commandButton id="yubicoStartButton" action="#{twoFaUserBean.createYubicoToken()}" value="#{messages.start}"
update="yubicoResponsePanel"/> update="yubicoResponsePanel, :form:messagePanel"/>
</p:panel> </p:panel>
</p:dialog> </p:dialog>
...@@ -217,14 +219,14 @@ ...@@ -217,14 +219,14 @@
<p:dialog header="#{messages.twofa_create_backup_tan_list}" <p:dialog header="#{messages.twofa_create_backup_tan_list}"
widgetVar="addBackupTanDlg" id="addBackupTanDlgId" modal="true" closable="true" closeOnEscape="true" widgetVar="addBackupTanDlg" id="addBackupTanDlgId" modal="true" closable="true" closeOnEscape="true"
showEffect="fade" hideEffect="fade"> showEffect="fade" hideEffect="fade">
<p:ajax event="close" update="@form" /> <p:ajax event="close" update=":form:tokenDisplayPanel" />
<div class="panel" style="width:360px;"> <div class="panel" style="width:360px;">
<h:outputText value="#{messages.twofa_create_backup_tan_list_desc}" escape="false" /> <h:outputText value="#{messages.twofa_create_backup_tan_list_desc}" escape="false" />
</div> </div>
<p:panel id="backupTanResponsePanel"> <p:panel id="backupTanResponsePanel">
<p:commandButton id="backupTanStartButton" action="#{twoFaUserBean.createBackupTanList()}" value="#{messages.start}" <p:commandButton id="backupTanStartButton" action="#{twoFaUserBean.createBackupTanList()}" value="#{messages.start}"
update="backupTanResponsePanel"/> update="backupTanResponsePanel, :form:messagePanel"/>
</p:panel> </p:panel>
</p:dialog> </p:dialog>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment