From 20f74269e11029273260edf39f6132f1f095cddb Mon Sep 17 00:00:00 2001 From: Justin Richer Date: Wed, 4 Jan 2012 16:39:26 -0500 Subject: [PATCH] updated some entity annotations --- .../mitre/openid/connect/model/Address.java | 22 ++++ .../openid/connect/model/ApprovedSite.java | 6 +- .../org/mitre/openid/connect/model/Event.java | 46 +++++++ .../mitre/openid/connect/model/IdToken.java | 124 +++++------------- .../mitre/openid/connect/model/UserInfo.java | 2 + .../openid/connect/model/WhitelistedSite.java | 4 +- 6 files changed, 113 insertions(+), 91 deletions(-) diff --git a/server/src/main/java/org/mitre/openid/connect/model/Address.java b/server/src/main/java/org/mitre/openid/connect/model/Address.java index f74b968e6..9fefc09b8 100644 --- a/server/src/main/java/org/mitre/openid/connect/model/Address.java +++ b/server/src/main/java/org/mitre/openid/connect/model/Address.java @@ -1,10 +1,14 @@ package org.mitre.openid.connect.model; import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; @Entity public class Address { + private Long id; private String formatted; private String street_address; private String locality; @@ -12,6 +16,8 @@ public class Address { private String postal_code; private String country; + + /** * @return the formatted */ @@ -84,5 +90,21 @@ public class Address { public void setCountry(String country) { this.country = country; } + + /** + * @return the id + */ + @Id + @GeneratedValue(strategy=GenerationType.IDENTITY) + public Long getId() { + return id; + } + + /** + * @param id the id to set + */ + public void setId(Long id) { + this.id = id; + } } diff --git a/server/src/main/java/org/mitre/openid/connect/model/ApprovedSite.java b/server/src/main/java/org/mitre/openid/connect/model/ApprovedSite.java index 3f16c4d03..4b6e4682a 100644 --- a/server/src/main/java/org/mitre/openid/connect/model/ApprovedSite.java +++ b/server/src/main/java/org/mitre/openid/connect/model/ApprovedSite.java @@ -8,6 +8,8 @@ import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; import javax.persistence.Temporal; import org.springframework.security.oauth2.provider.ClientDetails; @@ -48,7 +50,7 @@ public class ApprovedSite { * @return the id */ @Id - @GeneratedValue(strategy = GenerationType.AUTO) + @GeneratedValue(strategy = GenerationType.IDENTITY) public Long getId() { return id; } @@ -63,6 +65,7 @@ public class ApprovedSite { /** * @return the userInfo */ + @ManyToOne public UserInfo getUserInfo() { return userInfo; } @@ -123,6 +126,7 @@ public class ApprovedSite { /** * @return the allowedScopes */ + @OneToMany public Collection getAllowedScopes() { return allowedScopes; } diff --git a/server/src/main/java/org/mitre/openid/connect/model/Event.java b/server/src/main/java/org/mitre/openid/connect/model/Event.java index d287ad996..bc776c423 100644 --- a/server/src/main/java/org/mitre/openid/connect/model/Event.java +++ b/server/src/main/java/org/mitre/openid/connect/model/Event.java @@ -2,7 +2,12 @@ package org.mitre.openid.connect.model; import java.util.Date; +import javax.persistence.Basic; import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Temporal; /** * Class to contain a logged event in the system. @@ -19,5 +24,46 @@ public class Event { private Long id; private EventType type; private Date timestamp; + + /** + * @return the id + */ + @Id + @GeneratedValue(strategy=GenerationType.IDENTITY) + public Long getId() { + return id; + } + /** + * @param id the id to set + */ + public void setId(Long id) { + this.id = id; + } + /** + * @return the type + */ + public EventType getType() { + return type; + } + /** + * @param type the type to set + */ + public void setType(EventType type) { + this.type = type; + } + /** + * @return the timestamp + */ + @Basic + @Temporal(javax.persistence.TemporalType.TIMESTAMP) + public Date getTimestamp() { + return timestamp; + } + /** + * @param timestamp the timestamp to set + */ + public void setTimestamp(Date timestamp) { + this.timestamp = timestamp; + } } diff --git a/server/src/main/java/org/mitre/openid/connect/model/IdToken.java b/server/src/main/java/org/mitre/openid/connect/model/IdToken.java index 5a08edb4f..a7df4a097 100644 --- a/server/src/main/java/org/mitre/openid/connect/model/IdToken.java +++ b/server/src/main/java/org/mitre/openid/connect/model/IdToken.java @@ -1,105 +1,51 @@ package org.mitre.openid.connect.model; import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; import org.mitre.jwt.model.Jwt; +import org.mitre.jwt.model.JwtClaims; /* * TODO: This class needs to be encoded as a JWT */ @Entity -public class IdToken extends Jwt { +public class IdToken extends JwtClaims { - private String iss; - private String user_id; - private String aud; - private String exp; - private String iso29115; - private String nonce; - private String auth_time; + public static final String USER_ID = "user_id"; + public static final String ISO29115 = "iso29115"; + public static final String NONCE = "nonce"; + public static final String AUTH_TIME = "auth_time"; + + private Long id; + /** - * @return the iss - */ - public String getIss() { - return iss; - } + * @return the id + */ + @Id + @GeneratedValue(strategy=GenerationType.IDENTITY) + public Long getId() { + return id; + } /** - * @param iss the iss to set - */ - public void setIss(String iss) { - this.iss = iss; - } - /** - * @return the user_id - */ - public String getUser_id() { - return user_id; - } - /** - * @param user_id the user_id to set - */ - public void setUser_id(String user_id) { - this.user_id = user_id; - } - /** - * @return the aud - */ - public String getAud() { - return aud; - } - /** - * @param aud the aud to set - */ - public void setAud(String aud) { - this.aud = aud; - } - /** - * @return the exp - */ - public String getExp() { - return exp; - } - /** - * @param exp the exp to set - */ - public void setExp(String exp) { - this.exp = exp; - } - /** - * @return the iso29115 - */ - public String getIso29115() { - return iso29115; - } - /** - * @param iso29115 the iso29115 to set - */ - public void setIso29115(String iso29115) { - this.iso29115 = iso29115; - } - /** - * @return the nonce - */ - public String getNonce() { - return nonce; - } - /** - * @param nonce the nonce to set - */ - public void setNonce(String nonce) { - this.nonce = nonce; - } - /** - * @return the auth_time - */ - public String getAuth_time() { - return auth_time; - } - /** - * @param auth_time the auth_time to set - */ - public void setAuth_time(String auth_time) { - this.auth_time = auth_time; + * @param id the id to set + */ + public void setId(Long id) { + this.id = id; + } + + + public String getUserId() { + return getClaimAsString(USER_ID); } + public void setUserId(String user_id) { + setClaim(USER_ID, user_id); + } + + + // TODO: add in other fields + } diff --git a/server/src/main/java/org/mitre/openid/connect/model/UserInfo.java b/server/src/main/java/org/mitre/openid/connect/model/UserInfo.java index 67c8a2687..acbebd898 100644 --- a/server/src/main/java/org/mitre/openid/connect/model/UserInfo.java +++ b/server/src/main/java/org/mitre/openid/connect/model/UserInfo.java @@ -1,6 +1,7 @@ package org.mitre.openid.connect.model; import javax.persistence.Entity; +import javax.persistence.Id; @Entity public class UserInfo { @@ -29,6 +30,7 @@ public class UserInfo { /** * @return the user_id */ + @Id public String getUser_id() { return user_id; } diff --git a/server/src/main/java/org/mitre/openid/connect/model/WhitelistedSite.java b/server/src/main/java/org/mitre/openid/connect/model/WhitelistedSite.java index ca5b4987d..019988888 100644 --- a/server/src/main/java/org/mitre/openid/connect/model/WhitelistedSite.java +++ b/server/src/main/java/org/mitre/openid/connect/model/WhitelistedSite.java @@ -6,6 +6,7 @@ import java.util.Date; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +import javax.persistence.ManyToOne; import org.springframework.security.oauth2.provider.ClientDetails; @@ -19,7 +20,7 @@ public class WhitelistedSite { // unique id @Id - @GeneratedValue(strategy = GenerationType.AUTO) + @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; // who added this site to the whitelist (should be an admin) @@ -30,5 +31,6 @@ public class WhitelistedSite { // what scopes be allowed by default // this should include all information for what data to access + @ManyToOne private Collection allowedScopes; }