Skip to content

Commit bb1c57b

Browse files
committed
improve token lookup page
1 parent cb8bcc3 commit bb1c57b

File tree

1 file changed

+38
-29
lines changed

1 file changed

+38
-29
lines changed

webapp/src/main/webapp/WEB-INF/jsp/admin-tokenlookup.jsp

Lines changed: 38 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
<%@ page import="password.pwm.util.java.JavaHelper" %>
2929
<%@ page import="java.util.Iterator" %>
3030
<%@ page import="password.pwm.util.java.JsonUtil" %>
31+
<%@ page import="password.pwm.util.java.StringUtil" %>
32+
<%@ page import="password.pwm.bean.TokenDestinationItem" %>
3133

3234
<!DOCTYPE html>
3335
<%@ page language="java" session="true" isThreadSafe="true"
@@ -53,30 +55,29 @@
5355
<h1 id="page-content-title"><pwm:display key="Title_TokenLookup" bundle="Admin" displayIfMissing="true"/></h1>
5456
<%@ include file="fragment/admin-nav.jsp" %>
5557
<% final String tokenKey = tokenlookup_pwmRequest.readParameterAsString("token");%>
56-
<% if (tokenKey != null && tokenKey.length() > 0) { %>
58+
<%
59+
TokenPayload tokenPayload = null;
60+
boolean tokenExpired = false;
61+
String lookupError = null;
62+
%>
63+
<%
64+
if ( !StringUtil.isEmpty( tokenKey ) )
65+
{
66+
try
67+
{
68+
tokenPayload = tokenlookup_pwmRequest.getPwmApplication().getTokenService().retrieveTokenData(tokenlookup_pwmRequest.getSessionLabel(), tokenKey);
69+
} catch ( PwmOperationalException e )
70+
{
71+
tokenExpired = e.getError() == PwmError.ERROR_TOKEN_EXPIRED;
72+
lookupError = e.getMessage();
73+
}
74+
}
75+
%>
76+
<% if ( !StringUtil.isEmpty( tokenKey ) ) { %>
5777
<table>
5878
<tr>
5979
<td colspan="10" class="title">Token Information</td>
6080
</tr>
61-
<tr>
62-
<td class="key">
63-
Key
64-
</td>
65-
<td>
66-
<%=tokenKey%>
67-
</td>
68-
</tr>
69-
<%
70-
TokenPayload tokenPayload = null;
71-
boolean tokenExpired = false;
72-
String lookupError = null;
73-
try {
74-
tokenPayload = tokenlookup_pwmRequest.getPwmApplication().getTokenService().retrieveTokenData(tokenlookup_pwmRequest.getSessionLabel(), tokenKey);
75-
} catch (PwmOperationalException e) {
76-
tokenExpired= e.getError() == PwmError.ERROR_TOKEN_EXPIRED;
77-
lookupError = e.getMessage();
78-
}
79-
%>
8081
<% if (tokenPayload != null) { %>
8182
<tr>
8283
<td class="key">
@@ -123,7 +124,17 @@
123124
Destination(s)
124125
</td>
125126
<td>
126-
<%=JspUtility.friendlyWrite(pageContext, JsonUtil.serialize( tokenPayload.getDestination() ) )%>
127+
<% TokenDestinationItem tokenDestinationItem = tokenPayload.getDestination(); %>
128+
<% if ( tokenDestinationItem != null ) { %>
129+
<table>
130+
<tr>
131+
<td>Type</td><td><%=tokenDestinationItem.getType()%></td>
132+
</tr>
133+
<tr>
134+
<td>Destination</td><td><%=tokenDestinationItem.getDisplay()%></td>
135+
</tr>
136+
</table>
137+
<% } %>
127138
</td>
128139
</tr>
129140
<tr>
@@ -145,15 +156,13 @@
145156
</table>
146157
</td>
147158
</tr>
148-
<% } else { %>
159+
<% } %>
160+
<% if ( tokenPayload == null && lookupError == null ) { %>
149161
<tr>
150-
<td class="key">
151-
Status
152-
</td>
153-
<td>
154-
<% if (tokenExpired) { %>Expired<% } else { %>Token Not Found<% } %>
155-
</td>
162+
<td>Status</td><td>Not Found</td>
156163
</tr>
164+
<% } %>
165+
<% if ( lookupError != null ) { %>
157166
<tr>
158167
<td class="key">
159168
Lookup Error
@@ -164,8 +173,8 @@
164173
</tr>
165174
<% } %>
166175
</table>
167-
<br/>
168176
<% } %>
177+
<br/>
169178
<form id="tokenForm" action="<pwm:current-url/>" method="post">
170179
<textarea name="token" id="token" style="width: 580px; height: 150px"></textarea>
171180
<div class="buttonbar">

0 commit comments

Comments
 (0)