twofa.xhtml 7.97 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
35
36
37
38
39

		<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
40
		<p:dataGrid var="token" value="#{twoFaUserBean.tokenList}" columns="2" styleClass="whitefoot"
ls1947's avatar
ls1947 committed
41
42
43
44
				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">
45
46
	        		<i class="fa fa-fw fa-key"></i>
					<b><h:outputText value="#{token.serial}" /></b>
ls1947's avatar
ls1947 committed
47
				</f:facet>
ls1947's avatar
ls1947 committed
48
49
50
51
52
53
54
				<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>
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
						<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>
						<p:panel style="margin: 8px;">
							<h:outputText value="#{messages.twofa_token_not_init}" style="color:red;" 
									rendered="#{! token.isactive and (token.tokenDesc.contains('INIT'))}" />
						</p:panel>
						<p:commandButton action="#{twoFaUserBean.disableToken(token.serial)}" value="#{messages.disable}" 
							update="@form" rendered="#{token.isactive}"/>
						<p:commandButton action="#{twoFaUserBean.enableToken(token.serial)}" value="#{messages.disable}" 
							update="@form" rendered="#{! token.isactive and (! token.tokenDesc.contains('INIT'))}"/>
						<p:commandButton action="#{twoFaUserBean.deleteToken(token.serial)}" value="#{messages.delete}" 
							update="@form" rendered="#{! token.isactive}" style="color:red;">
							<p:confirm header="#{messages.confirm_header}" message="#{messages.confirm}" />
						</p:commandButton>
						</p:outputPanel>
ls1947's avatar
ls1947 committed
80
				</p:panelGrid>
ls1947's avatar
ls1947 committed
81
82
			</p:panel>
		</p:dataGrid>
ls1947's avatar
ls1947 committed
83

84
		<p:panel rendered="#{! twoFaUserBean.readOnly}">
85
			<div style="margin-bottom: 16px;">
ls1947's avatar
ls1947 committed
86
87
				<h:outputText value="#{messages.twofa_create_new_token}" />
			</div>
88
89
90
91
92
93
94
95
96
			<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
97
		</p:panel>
ls1947's avatar
ls1947 committed
98
99
	
		<p:dialog header="#{messages.twofa_create_totp_token}" 
ls1947's avatar
ls1947 committed
100
					widgetVar="addTotpDlg" id="addTotpDlgId" modal="true" closable="true" closeOnEscape="true"
ls1947's avatar
ls1947 committed
101
102
103
					showEffect="fade" hideEffect="fade">
			<p:ajax event="close" update="@form" />

104
			<div class="panel" style="width:520px;">
ls1947's avatar
ls1947 committed
105
			    <h:outputText value="#{messages.twofa_create_totp_token_desc}" escape="false" />
ls1947's avatar
ls1947 committed
106
107
		    </div>

108
			<p:panel id="totpResponsePanel" style="height: 260px;">
ls1947's avatar
ls1947 committed
109
			    <p:commandButton id="totpStartButton" action="#{twoFaUserBean.createAuthenticatorToken()}" value="#{messages.start}"
ls1947's avatar
ls1947 committed
110
		    		update="totpResponsePanel" oncomplete="PF('addTotpDlg').initPosition()" rendered="#{empty twoFaUserBean.createTokenResponse}"/>
ls1947's avatar
ls1947 committed
111
112
				<h:panelGroup rendered="#{not empty twoFaUserBean.createTokenResponse}">
					<h:panelGrid columns="2">
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
						<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}:" />
								<p:inputText id="totpText" value="#{twoFaUserBean.totpCode}"/>
							</h:panelGrid>
							<p:commandButton id="checkTotpButton" action="#{twoFaUserBean.checkAuthenticatorToken()}" value="#{messages.check}"
								update="totpResponsePanel" />
							</p:outputPanel>
						</h:panelGrid>
ls1947's avatar
ls1947 committed
128
129
130
131
132
				</h:panelGroup>
			</p:panel>
		</p:dialog>

		<p:dialog header="#{messages.twofa_create_yubico_token}" 
ls1947's avatar
ls1947 committed
133
					widgetVar="addYubicoDlg" id="addYubicoDlgId" modal="true" closable="true" closeOnEscape="true"
ls1947's avatar
ls1947 committed
134
135
136
					showEffect="fade" hideEffect="fade">
			<p:ajax event="close" update="@form" />
			<div class="panel" style="width:360px;">
ls1947's avatar
ls1947 committed
137
			    <h:outputText value="#{messages.twofa_create_yubico_token_desc}" escape="false" />
ls1947's avatar
ls1947 committed
138
139
140
141
142
143
144
145
146
147
148
149
150
151
		    </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}" 
ls1947's avatar
ls1947 committed
152
					widgetVar="addBackuptanDlg" id="addBackuptanDlgId" modal="true" closable="true" closeOnEscape="true"
ls1947's avatar
ls1947 committed
153
154
155
156
157
158
159
160
161
162
163
164
					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
165
166
167
168
169
170
171
	</h:form>
	</ui:define>

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