twofa.xhtml 10.2 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
<?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>
18
	<f:viewParam name="retsid" value="#{twoFaUserBean.returnServiceId}"/>
michael.simon's avatar
michael.simon committed
19
20
21
22
23
24
25
26
27
	<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">
28
			<div><p:messages showDetail="true" /></div>
ls1947's avatar
ls1947 committed
29
30
31
32
33
34

		<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>
			
ls1947's avatar
ls1947 committed
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
			<p:dataGrid var="token" value="#{twoFaUserBean.tokenList}" columns="2" styleClass="whitefoot"
					layout="grid" style="margin-bottom: 16px; opacity: 0.5;">
		        <p:panel styleClass="grayback" style="margin-bottom: 0px;">
		        	<f:facet name="header">
		        		<i class="fa fa-fw fa-key"></i>
						<b><h:outputText value="#{token.serial}" /></b>
					</f:facet>
					<p:panelGrid columns="2">
						<p:outputPanel>
							<h:graphicImage width="60px" value="#{resource['img/smartphone.svg']}" alt="Smartphone" rendered="#{token.tokenType == 'TOTP' and token.serial.startsWith('TOTP')}"/>
							<h:graphicImage width="60px" value="#{resource['img/kittoken_small.png']}" alt="Hardware Token" rendered="#{token.tokenType == 'TOTP' and not token.serial.startsWith('TOTP')}"/>
							<h:graphicImage width="60px" value="#{resource['img/yubikey_small.png']}" alt="Yubikey" rendered="#{token.tokenType == 'yubico'}"/>
						</p:outputPanel>
						<p:outputPanel>
							<h:panelGrid columns="2">
								<p:outputLabel for="@next" value="#{messages.twofa_tokentype}:" />
								<h:panelGroup>
									<h:outputText value="#{messages.twofa_tokentype_tanlist}" rendered="#{token.tokenType == 'HMAC' and token.serial.startsWith('OATH')}"/>
									<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>

							<p:panel style="margin: 8px;" rendered="#{! token.isactive and (token.tokenDesc.contains('INIT'))}">
								<h:outputText value="#{messages.twofa_token_not_init}" style="color:red;"/>
							</p:panel>
							</p:outputPanel>
					</p:panelGrid>
				</p:panel>
			</p:dataGrid>
ls1947's avatar
ls1947 committed
70
71
		</p:panel>

ls1947's avatar
ls1947 committed
72
		<p:dataGrid var="token" value="#{twoFaUserBean.tokenList}" columns="2" styleClass="whitefoot"
ls1947's avatar
ls1947 committed
73
74
75
76
				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">
77
78
	        		<i class="fa fa-fw fa-key"></i>
					<b><h:outputText value="#{token.serial}" /></b>
ls1947's avatar
ls1947 committed
79
				</f:facet>
ls1947's avatar
ls1947 committed
80
81
82
83
84
85
86
				<p:panelGrid columns="2">
					<p:outputPanel>
						<h:graphicImage width="60px" value="#{resource['img/smartphone.svg']}" alt="Smartphone" rendered="#{token.tokenType == 'TOTP' and token.serial.startsWith('TOTP')}"/>
						<h:graphicImage width="60px" value="#{resource['img/kittoken_small.png']}" alt="Hardware Token" rendered="#{token.tokenType == 'TOTP' and not token.serial.startsWith('TOTP')}"/>
						<h:graphicImage width="60px" value="#{resource['img/yubikey_small.png']}" alt="Yubikey" rendered="#{token.tokenType == 'yubico'}"/>
					</p:outputPanel>
					<p:outputPanel>
ls1947's avatar
ls1947 committed
87
						<h:panelGrid columns="2" style="margin-bottom: 16px;">
88
89
90
91
92
93
94
95
96
97
98
							<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
99
100
						<p:panel style="margin: 8px;" rendered="#{! token.isactive and (token.tokenDesc.contains('INIT'))}">
							<h:outputText value="#{messages.twofa_token_not_init}" style="color:red;" />
101
102
103
						</p:panel>
						<p:commandButton action="#{twoFaUserBean.disableToken(token.serial)}" value="#{messages.disable}" 
							update="@form" rendered="#{token.isactive}"/>
ls1947's avatar
ls1947 committed
104
						<p:commandButton action="#{twoFaUserBean.enableToken(token.serial)}" value="#{messages.enable}" 
105
106
							update="@form" rendered="#{! token.isactive and (! token.tokenDesc.contains('INIT'))}"/>
						<p:commandButton action="#{twoFaUserBean.deleteToken(token.serial)}" value="#{messages.delete}" 
107
							update="@form" rendered="#{! token.isactive and (token.tokenDesc.contains('DELABLE'))}" style="color:red;">
108
109
							<p:confirm header="#{messages.confirm_header}" message="#{messages.confirm}" />
						</p:commandButton>
ls1947's avatar
ls1947 committed
110
					</p:outputPanel>
ls1947's avatar
ls1947 committed
111
				</p:panelGrid>
ls1947's avatar
ls1947 committed
112
113
			</p:panel>
		</p:dataGrid>
ls1947's avatar
ls1947 committed
114

115
		<p:panel rendered="#{! twoFaUserBean.readOnly}">
116
			<div style="margin-bottom: 16px;">
ls1947's avatar
ls1947 committed
117
118
				<h:outputText value="#{messages.twofa_create_new_token}" />
			</div>
119
120
121
122
123
124
125
126
127
			<p:outputPanel style="margin-bottom: 16px;">
				<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>
			</p:outputPanel>
			<p:outputPanel rendered="#{not empty twoFaUserBean.returnServiceId}">
				<p:link href="../user/register-service.xhtml" value="#{messages.twofa_back_to_register}">
					<f:param name="serviceId" value="#{twoFaUserBean.returnServiceId}"/>
				</p:link>
			</p:outputPanel>
michael.simon's avatar
michael.simon committed
128
		</p:panel>
ls1947's avatar
ls1947 committed
129
130
	
		<p:dialog header="#{messages.twofa_create_totp_token}" 
ls1947's avatar
ls1947 committed
131
					widgetVar="addTotpDlg" id="addTotpDlgId" modal="true" closable="true" closeOnEscape="true"
ls1947's avatar
ls1947 committed
132
133
134
					showEffect="fade" hideEffect="fade">
			<p:ajax event="close" update="@form" />

135
			<div class="panel" style="width:520px;">
ls1947's avatar
ls1947 committed
136
			    <h:outputText value="#{messages.twofa_create_totp_token_desc}" escape="false" />
ls1947's avatar
ls1947 committed
137
138
		    </div>

139
			<p:panel id="totpResponsePanel" style="height: 260px;">
ls1947's avatar
ls1947 committed
140
			    <p:commandButton id="totpStartButton" action="#{twoFaUserBean.createAuthenticatorToken()}" value="#{messages.start}"
ls1947's avatar
ls1947 committed
141
		    		update="totpResponsePanel" oncomplete="PF('addTotpDlg').initPosition()" rendered="#{empty twoFaUserBean.createTokenResponse}"/>
ls1947's avatar
ls1947 committed
142
143
				<h:panelGroup rendered="#{not empty twoFaUserBean.createTokenResponse}">
					<h:panelGrid columns="2">
144
145
146
147
148
149
150
151
152
						<p:outputPanel>
							<h:outputText value="#{twoFaUserBean.createTokenResponse.detail.googleurl.img}" escape="false" />
						</p:outputPanel>
						<p:outputPanel>
							<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}:" />
ls1947's avatar
ls1947 committed
153
								<p:inputText id="totpText" autocomplete="false" value="#{twoFaUserBean.totpCode}"/>
154
155
156
157
158
							</h:panelGrid>
							<p:commandButton id="checkTotpButton" action="#{twoFaUserBean.checkAuthenticatorToken()}" value="#{messages.check}"
								update="totpResponsePanel" />
							</p:outputPanel>
						</h:panelGrid>
ls1947's avatar
ls1947 committed
159
160
161
162
163
				</h:panelGroup>
			</p:panel>
		</p:dialog>

		<p:dialog header="#{messages.twofa_create_yubico_token}" 
ls1947's avatar
ls1947 committed
164
					widgetVar="addYubicoDlg" id="addYubicoDlgId" modal="true" closable="true" closeOnEscape="true"
ls1947's avatar
ls1947 committed
165
166
167
					showEffect="fade" hideEffect="fade">
			<p:ajax event="close" update="@form" />
			<div class="panel" style="width:360px;">
ls1947's avatar
ls1947 committed
168
			    <h:outputText value="#{messages.twofa_create_yubico_token_desc}" escape="false" />
ls1947's avatar
ls1947 committed
169
170
171
172
173
		    </div>
		
			<p:panel id="yubicoResponsePanel">
				<h:panelGrid columns="2">
					<p:outputLabel for="@next" value="#{messages.twofa_code}:" />
ls1947's avatar
ls1947 committed
174
					<p:inputText id="yubicoText" autocomplete="false" value="#{twoFaUserBean.yubicoCode}"/>
ls1947's avatar
ls1947 committed
175
176
177
178
179
180
181
182
				</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}" 
ls1947's avatar
ls1947 committed
183
					widgetVar="addBackuptanDlg" id="addBackuptanDlgId" modal="true" closable="true" closeOnEscape="true"
ls1947's avatar
ls1947 committed
184
185
186
187
188
189
190
191
192
193
194
195
					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
196
197
198
199
200
201
202
	</h:form>
	</ui:define>

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