From 26f03ec07087fe13e31c637115bfaad0c12d8717 Mon Sep 17 00:00:00 2001
From: Justin Richer <jricher@mitre.org>
Date: Mon, 4 Mar 2013 16:10:42 -0500
Subject: [PATCH] timestamp for creation date

---
 .../java/org/mitre/oauth2/model/ClientDetailsEntity.java    | 4 ++++
 .../impl/DefaultOAuth2ClientDetailsEntityService.java       | 6 ++++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/openid-connect-common/src/main/java/org/mitre/oauth2/model/ClientDetailsEntity.java b/openid-connect-common/src/main/java/org/mitre/oauth2/model/ClientDetailsEntity.java
index 0e721c288..69ef68715 100644
--- a/openid-connect-common/src/main/java/org/mitre/oauth2/model/ClientDetailsEntity.java
+++ b/openid-connect-common/src/main/java/org/mitre/oauth2/model/ClientDetailsEntity.java
@@ -42,6 +42,8 @@ import javax.persistence.JoinColumn;
 import javax.persistence.NamedQueries;
 import javax.persistence.NamedQuery;
 import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
 import javax.persistence.Transient;
 
 import org.mitre.jose.JWEAlgorithmEntity;
@@ -855,6 +857,8 @@ public class ClientDetailsEntity implements ClientDetails {
 	/**
 	 * @return the createdAt
 	 */
+	@Temporal(TemporalType.TIMESTAMP)
+	@Column(name="created_at")
     public Date getCreatedAt() {
 	    return createdAt;
     }
diff --git a/openid-connect-server/src/main/java/org/mitre/oauth2/service/impl/DefaultOAuth2ClientDetailsEntityService.java b/openid-connect-server/src/main/java/org/mitre/oauth2/service/impl/DefaultOAuth2ClientDetailsEntityService.java
index dac44e5b5..3dc2cd16a 100644
--- a/openid-connect-server/src/main/java/org/mitre/oauth2/service/impl/DefaultOAuth2ClientDetailsEntityService.java
+++ b/openid-connect-server/src/main/java/org/mitre/oauth2/service/impl/DefaultOAuth2ClientDetailsEntityService.java
@@ -18,6 +18,7 @@ package org.mitre.oauth2.service.impl;
 import java.math.BigInteger;
 import java.security.SecureRandom;
 import java.util.Collection;
+import java.util.Date;
 import java.util.UUID;
 
 import org.apache.commons.codec.binary.Base64;
@@ -25,7 +26,6 @@ import org.mitre.oauth2.model.ClientDetailsEntity;
 import org.mitre.oauth2.repository.OAuth2ClientRepository;
 import org.mitre.oauth2.repository.OAuth2TokenRepository;
 import org.mitre.oauth2.service.ClientDetailsEntityService;
-import org.mitre.openid.connect.model.ApprovedSite;
 import org.mitre.openid.connect.model.WhitelistedSite;
 import org.mitre.openid.connect.service.ApprovedSiteService;
 import org.mitre.openid.connect.service.BlacklistedSiteService;
@@ -33,7 +33,6 @@ import org.mitre.openid.connect.service.WhitelistedSiteService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.oauth2.common.exceptions.InvalidClientException;
 import org.springframework.security.oauth2.common.exceptions.OAuth2Exception;
-import org.springframework.security.oauth2.provider.refresh.RefreshTokenGranter;
 import org.springframework.stereotype.Service;
 
 import com.google.common.base.Strings;
@@ -93,6 +92,9 @@ public class DefaultOAuth2ClientDetailsEntityService implements ClientDetailsEnt
         	client.getScope().remove("offline_access");
         }
         
+        // timestamp this to right now
+        client.setCreatedAt(new Date());
+        
         return clientRepository.saveClient(client);
 	}