From 6cce82f48478596d89da1bbfc649113dc9604e7d Mon Sep 17 00:00:00 2001 From: Amanda Anganes Date: Tue, 10 Jan 2012 16:17:12 -0500 Subject: [PATCH] checked in stuff --- .project | 6 ++ server/.classpath | 7 +- server/.project | 6 ++ .../org.eclipse.wst.common.component | 6 +- .../mitre/openid/connect/model/Address.java | 26 ++++++- .../openid/connect/model/ApprovedSite.java | 18 ++++- .../mitre/openid/connect/model/UserInfo.java | 41 +++++++++- .../openid/connect/model/WhitelistedSite.java | 76 ++++++++++++++++++- 8 files changed, 174 insertions(+), 12 deletions(-) diff --git a/.project b/.project index 965bb02e4..041d25bcb 100644 --- a/.project +++ b/.project @@ -10,8 +10,14 @@ + + org.eclipse.m2e.core.maven2Builder + + + + org.eclipse.m2e.core.maven2Nature org.maven.ide.eclipse.maven2Nature diff --git a/server/.classpath b/server/.classpath index 6186af403..59b77ad1e 100644 --- a/server/.classpath +++ b/server/.classpath @@ -4,13 +4,16 @@ - + + + + + - diff --git a/server/.project b/server/.project index d94333531..9debe6479 100644 --- a/server/.project +++ b/server/.project @@ -31,8 +31,14 @@ + + org.eclipse.m2e.core.maven2Builder + + + + org.eclipse.m2e.core.maven2Nature org.maven.ide.eclipse.maven2Nature org.eclipse.jem.workbench.JavaEMFNature org.eclipse.wst.common.modulecore.ModuleCoreNature diff --git a/server/.settings/org.eclipse.wst.common.component b/server/.settings/org.eclipse.wst.common.component index 56a002a7c..7297c8ed1 100644 --- a/server/.settings/org.eclipse.wst.common.component +++ b/server/.settings/org.eclipse.wst.common.component @@ -3,9 +3,9 @@ - - - + + + uses 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 9fefc09b8..1345e2f78 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,5 +1,6 @@ package org.mitre.openid.connect.model; +import javax.persistence.Basic; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; @@ -8,24 +9,43 @@ import javax.persistence.Id; @Entity public class Address { + @Id + @GeneratedValue(strategy=GenerationType.IDENTITY) private Long id; + + @Basic private String formatted; + + @Basic private String street_address; + + @Basic private String locality; + + @Basic private String region; + + @Basic private String postal_code; + + @Basic private String country; - + /** + * Empty constructor + */ + public Address() { + + } /** - * @return the formatted + * @return the formatted address string */ public String getFormatted() { return formatted; } /** - * @param formatted the formatted to set + * @param formatted the formatted address to set */ public void setFormatted(String formatted) { this.formatted = formatted; 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 4b6e4682a..f98232c53 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,40 +8,56 @@ import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.OneToMany; +import javax.persistence.Table; import javax.persistence.Temporal; +import javax.persistence.TemporalType; import org.springframework.security.oauth2.provider.ClientDetails; @Entity +@Table(name="approvedsite") public class ApprovedSite { // unique id + @Id + @GeneratedValue(strategy=GenerationType.IDENTITY) private Long id; // which user made the approval + @ManyToOne + @JoinColumn(name="userinfo_id") private UserInfo userInfo; // which OAuth2 client is this tied to + @ManyToOne + @JoinColumn(name="clientdetails_id") private ClientDetails clientDetails; // when was this first approved? + @Temporal(TemporalType.DATE) private Date creationDate; // when was this last accessed? + @Temporal(TemporalType.DATE) private Date accessDate; // if this is a time-limited access, when does it run out? + @Temporal(TemporalType.DATE) private Date timeoutDate; // what scopes have been allowed // this should include all information for what data to access + @OneToMany(mappedBy = "approvedsite") private Collection allowedScopes; // TODO: should we store the OAuth2 tokens and IdTokens here? - + /** + * Empty constructor + */ public ApprovedSite() { } 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 acbebd898..8bbb71a28 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,32 +1,71 @@ package org.mitre.openid.connect.model; +import javax.persistence.Basic; import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; import javax.persistence.Id; +import javax.persistence.OneToOne; +import javax.persistence.Table; @Entity +@Table(name="userinfo") public class UserInfo { - // TODO: underbars are awkward in java, should we switch all this to camel case and put in underbars in the serialization view? + // unique object id for persistence + @Id + @GeneratedValue(strategy=GenerationType.IDENTITY) + private Long id; + // TODO: underbars are awkward in java, should we switch all this to camel case and put in underbars in the serialization view? + @Basic private String user_id; + @Basic private String name; + @Basic private String given_name; + @Basic private String family_name; + @Basic private String middle_name; + @Basic private String nickname; + @Basic private String profile; + @Basic private String picture; + @Basic private String website; + @Basic private String email; + @Basic private Boolean verified; + @Basic private String gender; + @Basic private String zoneinfo; + @Basic private String locale; + @Basic private String phone_number; + @OneToOne private Address address; + @Basic private String updated_time; + /** + * @return the id + */ + public Long getId() { + return id; + } + /** + * @param id the id to set + */ + public void setId(Long id) { + this.id = id; + } /** * @return the 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 019988888..c0e5dd676 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 @@ -1,12 +1,15 @@ package org.mitre.openid.connect.model; import java.util.Collection; -import java.util.Date; +import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; +import javax.persistence.Table; import org.springframework.security.oauth2.provider.ClientDetails; @@ -16,6 +19,8 @@ import org.springframework.security.oauth2.provider.ClientDetails; * @author jricher * */ +@Entity +@Table(name="whitelistedsite") public class WhitelistedSite { // unique id @@ -24,13 +29,80 @@ public class WhitelistedSite { private Long id; // who added this site to the whitelist (should be an admin) + @ManyToOne + @JoinColumn(name="userinfo_id") private UserInfo userInfo; // which OAuth2 client is this tied to + @ManyToOne + @JoinColumn(name="clientdetails_id") private ClientDetails clientDetails; // what scopes be allowed by default // this should include all information for what data to access - @ManyToOne + @OneToMany(mappedBy="whitelistedsite") private Collection allowedScopes; + + /** + * Empty constructor + */ + public WhitelistedSite() { + + } + + /** + * @return the id + */ + public Long getId() { + return id; + } + + /** + * @param id the id to set + */ + public void setId(Long id) { + this.id = id; + } + + /** + * @return the userInfo + */ + public UserInfo getUserInfo() { + return userInfo; + } + + /** + * @param userInfo the userInfo to set + */ + public void setUserInfo(UserInfo userInfo) { + this.userInfo = userInfo; + } + + /** + * @return the clientDetails + */ + public ClientDetails getClientDetails() { + return clientDetails; + } + + /** + * @param clientDetails the clientDetails to set + */ + public void setClientDetails(ClientDetails clientDetails) { + this.clientDetails = clientDetails; + } + + /** + * @return the allowedScopes + */ + public Collection getAllowedScopes() { + return allowedScopes; + } + + /** + * @param allowedScopes the allowedScopes to set + */ + public void setAllowedScopes(Collection allowedScopes) { + this.allowedScopes = allowedScopes; + } }