account for registration time in approval page, closes #550

pull/592/head
Justin Richer 2014-04-19 07:28:20 -04:00
parent 90b10d7bad
commit 376403fa4a
2 changed files with 29 additions and 10 deletions

View File

@ -37,8 +37,14 @@
<div class="row"> <div class="row">
<div class="span5 offset1 well-small" style="text-align: left"> <div class="span5 offset1 well-small" style="text-align: left">
<%-- TODO: wire up to stats engine and customize display of this block --%>
<c:if test="${ client.dynamicallyRegistered }"> <c:if test="${ client.dynamicallyRegistered }">
<c:choose>
<c:when test="${ gras }">
<!-- client is "generally recognized as safe, display a more muted block -->
<div><p class="alert alert-info"><i class="icon-globe"></i> This client was dynamically registered.</p></div>
</c:when>
<c:otherwise>
<!-- client is dynamically registered -->
<div class="alert alert-block <c:out value="${ count eq 0 ? 'alert-error' : 'alert-warn' }" />"> <div class="alert alert-block <c:out value="${ count eq 0 ? 'alert-error' : 'alert-warn' }" />">
<h4> <h4>
<i class="icon-globe"></i> Caution: <i class="icon-globe"></i> Caution:
@ -47,6 +53,8 @@
<span class="label"><c:out value="${ count }" /></span> <span class="label"><c:out value="${ count }" /></span>
time<c:out value="${ count == 1 ? '' : 's' }"/> previously. time<c:out value="${ count == 1 ? '' : 's' }"/> previously.
</div> </div>
</c:otherwise>
</c:choose>
</c:if> </c:if>
<c:if test="${ not empty client.logoUri }"> <c:if test="${ not empty client.logoUri }">

View File

@ -20,6 +20,7 @@
package org.mitre.oauth2.web; package org.mitre.oauth2.web;
import java.security.Principal; import java.security.Principal;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
@ -181,6 +182,16 @@ public class OAuthConfirmationController {
model.put("contacts", contacts); model.put("contacts", contacts);
} }
// if the client is over a week old and has more than one registration, don't give such a big warning
// instead, tag as "Generally Recognized As Safe (gras)
Date lastWeek = new Date(System.currentTimeMillis() + (60 * 60 * 24 * 7 * 1000));
//Date lastWeek = new Date(System.currentTimeMillis() - (60 * 60 * 24 * 7 * 1000));
if (count > 1 && client.getCreatedAt() != null && client.getCreatedAt().before(lastWeek)) {
model.put("gras", true);
} else {
model.put("gras", false);
}
return "approve"; return "approve";
} }