twofa.xhtml 7.49 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
				<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_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: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}"/>
					<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>
					</p:outputPanel>
				</p:panelGrid>
ls1947's avatar
ls1947 committed
77
78
			</p:panel>
		</p:dataGrid>
ls1947's avatar
ls1947 committed
79

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

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

			<p:panel id="totpResponsePanel">
			    <p:commandButton id="totpStartButton" action="#{twoFaUserBean.createAuthenticatorToken()}" value="#{messages.start}"
ls1947's avatar
ls1947 committed
106
		    		update="totpResponsePanel" oncomplete="PF('addTotpDlg').initPosition()" rendered="#{empty twoFaUserBean.createTokenResponse}"/>
ls1947's avatar
ls1947 committed
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
				<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}" 
ls1947's avatar
ls1947 committed
125
					widgetVar="addYubicoDlg" id="addYubicoDlgId" modal="true" closable="true" closeOnEscape="true"
ls1947's avatar
ls1947 committed
126
127
128
					showEffect="fade" hideEffect="fade">
			<p:ajax event="close" update="@form" />
			<div class="panel" style="width:360px;">
ls1947's avatar
ls1947 committed
129
			    <h:outputText value="#{messages.twofa_create_yubico_token_desc}" escape="false" />
ls1947's avatar
ls1947 committed
130
131
132
133
134
135
136
137
138
139
140
141
142
143
		    </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
144
					widgetVar="addBackuptanDlg" id="addBackuptanDlgId" modal="true" closable="true" closeOnEscape="true"
ls1947's avatar
ls1947 committed
145
146
147
148
149
150
151
152
153
154
155
156
					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
157
158
159
160
161
162
163
	</h:form>
	</ui:define>

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