twofa.xhtml 6.31 KB
Newer Older
michael.simon's avatar
michael.simon committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:bw="http://www.scc.kit.edu/bwfacelets"
	xmlns:p="http://primefaces.org/ui"
	xmlns:of="http://omnifaces.org/functions">
<head>
<title></title>
</head>
<body>

<f:view>
<f:metadata>
	<f:event type="javax.faces.event.PreRenderViewEvent"
           listener="#{twoFaUserBean.preRenderView}" />
</f:metadata>

<ui:composition template="/template/default.xhtml">
	<ui:param name="title" value="#{messages.title}"/>

	<ui:define name="content">
	<h:form id="form">
27
			<div><p:messages showDetail="true" /></div>
ls1947's avatar
ls1947 committed
28
29
30
31
32
33
34
35
36
37
38

		<p:panel header="#{messages.twofa_list}" rendered="#{twoFaUserBean.readOnly}">
			
			<div><h:outputText value="#{messages.twofa_list_readonly}"/></div>
			<div><a href="#{twoFaUserBean.managementUrl}" target="_blank">#{twoFaUserBean.managementUrl}</a></div>
			
			<p:repeat var="token" value="#{twoFaUserBean.tokenList}">
				<div><h:outputText value="#{token.serial}" /></div>
			</p:repeat>
		</p:panel>

ls1947's avatar
ls1947 committed
39
		<p:dataGrid var="token" value="#{twoFaUserBean.tokenList}" columns="2" styleClass="whitefoot"
ls1947's avatar
ls1947 committed
40
41
42
43
				layout="grid" style="margin-bottom: 16px;" rendered="#{! twoFaUserBean.readOnly}">
	        <f:facet name="header">#{messages.twofa_list}</f:facet>
	        <p:panel styleClass="grayback" style="margin-bottom: 0px;">
	        	<f:facet name="header">
44
45
	        		<i class="fa fa-fw fa-key"></i>
					<b><h:outputText value="#{token.serial}" /></b>
ls1947's avatar
ls1947 committed
46
				</f:facet>
ls1947's avatar
ls1947 committed
47
48
49
50
51
52
53
54
55
56
57
58
59
				<h:panelGrid columns="2">
					<p:outputLabel for="@next" value="#{messages.twofa_tokentype}:" />
					<h:panelGroup>
						<h:outputText value="#{messages.twofa_tokentype_totp}" rendered="#{token.tokenType == 'TOTP' and token.serial.startsWith('TOTP')}"/>
						<h:outputText value="#{messages.twofa_tokentype_totp_hardware}" rendered="#{token.tokenType == 'TOTP' and not token.serial.startsWith('TOTP')}"/>
						<h:outputText value="#{messages.twofa_tokentype_tanlist}" rendered="#{token.tokenType == 'HOTP'}"/>
						<h:outputText value="#{messages.twofa_tokentype_yubikey}" rendered="#{token.tokenType == 'yubico'}"/>
					</h:panelGroup>

					<p:outputLabel for="@next" value="#{messages.twofa_active}:" />
					<h:outputText value="#{token.isactive ? messages.yes : messages.no}" />
				</h:panelGrid>

ls1947's avatar
ls1947 committed
60
61
62
63
				<p:commandButton action="#{twoFaUserBean.disableToken(token.serial)}" value="Disable" 
					update="@form" rendered="#{token.isactive}"/>
				<p:commandButton action="#{twoFaUserBean.enableToken(token.serial)}" value="Enable" 
					update="@form" rendered="#{! token.isactive}"/>
ls1947's avatar
ls1947 committed
64
65
66
67
				<p:commandButton action="#{twoFaUserBean.deleteToken(token.serial)}" value="Delete" 
					update="@form" rendered="#{! token.isactive}">
					<p:confirm header="#{messages.confirm_header}" message="#{messages.confirm}" />
				</p:commandButton>
ls1947's avatar
ls1947 committed
68
69
			</p:panel>
		</p:dataGrid>
ls1947's avatar
ls1947 committed
70
71
72
73
74
75
76

		<p:panel>
			<div>
				<h:outputText value="#{messages.twofa_create_new_token}" />
			</div>
			<p:commandButton id="openAddTotpDialog" oncomplete="PF('addTotpDlg').show();" value="#{messages.twofa_create_new_totp}"></p:commandButton>
			<p:commandButton id="openAddYubicoDialog" oncomplete="PF('addYubicoDlg').show();" value="#{messages.twofa_create_new_yubico}"></p:commandButton>
michael.simon's avatar
michael.simon committed
77
		</p:panel>
ls1947's avatar
ls1947 committed
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
	
		<p:dialog header="#{messages.twofa_create_totp_token}" 
					widgetVar="addTotpDlg" id="addTotpDlgId" modal="true" closable="false" closeOnEscape="true"
					showEffect="fade" hideEffect="fade">
			<p:ajax event="close" update="@form" />

			<div class="panel" style="width:360px;">
			    <h:outputText value="#{messages.twofa_create_totp_token_desc}" />
		    </div>

			<p:panel id="totpResponsePanel">
			    <p:commandButton id="totpStartButton" action="#{twoFaUserBean.createAuthenticatorToken()}" value="#{messages.start}"
		    		update="totpResponsePanel" rendered="#{empty twoFaUserBean.createTokenResponse}"/>
				<h:panelGroup rendered="#{not empty twoFaUserBean.createTokenResponse}">
					<div>
						<h:outputText value="#{twoFaUserBean.createTokenResponse.detail.googleurl.img}" escape="false" />
					</div>
					<h:panelGrid columns="2">
						<p:outputLabel for="@next" value="#{messages.twofa_serial}:" />
						<h:outputText value="#{twoFaUserBean.createTokenResponse.detail.serial}"/>
						
						<p:outputLabel for="@next" value="#{messages.twofa_code}:" />
						<p:inputText id="totpText" value="#{twoFaUserBean.totpCode}"/>
					</h:panelGrid>
					<p:commandButton id="checkTotpButton" action="#{twoFaUserBean.checkAuthenticatorToken()}" value="#{messages.check}"
						update="totpResponsePanel" />
				</h:panelGroup>
			</p:panel>
		</p:dialog>

		<p:dialog header="#{messages.twofa_create_yubico_token}" 
					widgetVar="addYubicoDlg" id="addYubicoDlgId" modal="true" closable="false" closeOnEscape="true"
					showEffect="fade" hideEffect="fade">
			<p:ajax event="close" update="@form" />
			<div class="panel" style="width:360px;">
			    <h:outputText value="#{messages.twofa_create_yubico_token_desc}" />
		    </div>
		
			<p:panel id="yubicoResponsePanel">
				<h:panelGrid columns="2">
					<p:outputLabel for="@next" value="#{messages.twofa_code}:" />
					<p:inputText id="yubicoText" value="#{twoFaUserBean.yubicoCode}"/>
				</h:panelGrid>
			    <p:commandButton id="yubicoStartButton" action="#{twoFaUserBean.createYubicoToken()}" value="#{messages.start}"
		    		update="yubicoResponsePanel"/>
			</p:panel>

		</p:dialog>
		
		<p:dialog header="#{messages.twofa_create_backuptan_token}" 
					widgetVar="addBackuptanDlg" id="addBackuptanDlgId" modal="true" closable="false" closeOnEscape="true"
					showEffect="fade" hideEffect="fade">
					
		</p:dialog>

	    <p:confirmDialog global="true" showEffect="fade" hideEffect="fade" closable="false" closeOnEscape="true">
	        <p:commandButton value="#{messages.yes}" type="button" styleClass="ui-confirmdialog-yes" />
	        <p:commandButton value="#{messages.no}" type="button" styleClass="ui-confirmdialog-no" />
	    </p:confirmDialog>    

		<p:defaultCommand target="yubicoStartButton" scope="addYubicoDlgId"/>		
		<p:defaultCommand target="checkTotpButton" scope="addTotpDlgId"/>		

michael.simon's avatar
michael.simon committed
141
142
143
144
145
146
147
	</h:form>
	</ui:define>

</ui:composition>
</f:view>
</body>
</html>