Skip to content

Commit

Permalink
Fix OIDC clients properties page #1284
Browse files Browse the repository at this point in the history
  • Loading branch information
syntrydy committed Oct 12, 2018
1 parent 9d1f82f commit aeab0bb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
Expand Up @@ -288,12 +288,13 @@ public String cancel() {

public String save() throws Exception {
LocalDate localDate = LocalDate.now();
LocalDate tomorrow = localDate.plusDays(1);
Date today = Date.from(tomorrow.atStartOfDay(ZoneId.systemDefault()).toInstant());
if (this.client.getClientSecretExpiresAt() == null && !update) {
this.client.setClientSecretExpiresAt(today);
LocalDate nextCentury = localDate.plusYears(100);
Date nextCenturyDate = Date.from(nextCentury.atStartOfDay(ZoneId.systemDefault()).toInstant());
if (this.client.getClientSecretExpiresAt() != null && this.client.getClientSecretExpiresAt()
.before(Date.from(LocalDate.now().plusDays(1).atStartOfDay(ZoneId.systemDefault()).toInstant()))) {
this.client.setClientSecretExpiresAt(nextCenturyDate);
}
if (previousClientExpirationDate != null && this.client.getClientSecretExpiresAt().before(today)) {
if (previousClientExpirationDate != null && this.client.getClientSecretExpiresAt().before(new Date())) {
facesMessages.add(FacesMessage.SEVERITY_ERROR,
"This client has expired. Update the expiration date in order to save changes");
return OxTrustConstants.RESULT_FAILURE;
Expand Down
8 changes: 6 additions & 2 deletions server/src/main/java/org/gluu/oxtrust/model/OxAuthClient.java
Expand Up @@ -29,7 +29,7 @@
* @author Reda Zerrad Date: 06.08.2012
* @author Yuriy Movchan Date: 05/22/2013
* @author Javier Rojas Blum
* @version Junr 13, 2018
* @version June 21, 2018
*/
@LdapEntry(sortBy = {"displayName"})
@LdapObjectClass(values = {"top", "oxAuthClient"})
Expand Down Expand Up @@ -643,7 +643,11 @@ public String getOxAuthClientSecret() throws EncryptionException {
}

public Date getClientSecretExpiresAt() {
return clientSecretExpiresAt;
if (clientSecretExpiresAt == null) {
return new Date();
} else {
return clientSecretExpiresAt;
}
}

public void setClientSecretExpiresAt(Date clientSecretExpiresAt) {
Expand Down
5 changes: 2 additions & 3 deletions server/src/main/webapp/WEB-INF/incl/client/clientForm.xhtml
Expand Up @@ -427,7 +427,6 @@
</ox:decorate>
<ox:decorate id="clientsecretexpiry" leftClass="col-sm-6"
rightClass="col-sm-6"
rendered="#{_client.clientSecretExpiresAt != null || !_clientAction.update}"
label="#{msg['clientForm.clientSecretExpires']}">
<rich:calendar value="#{_client.clientSecretExpiresAt}"
id="calendar" popup="false" datePattern="dd/MM/yyyy HH:mm"
Expand Down Expand Up @@ -829,8 +828,8 @@
maxlength="60" inputWidth="64" required="false"
id="oxdIdId" />
</ox:decorate>
<ox:decorate id="defaultMaxAge" leftClass="col-sm-6"
rightClass="col-sm-6"
<ox:decorate id="defaultMaxAge" leftClass="col-sm-3"
rightClass="col-sm-9"
label="#{msg['clientForm.defaultMaximumAuthenticationAge']}">
<rich:inplaceInput value="#{_client.defaultMaxAge}"
defaultLabel="Maximum Authentication Age (value in seconds)"
Expand Down

0 comments on commit aeab0bb

Please sign in to comment.