updated some entity annotations

pull/59/head
Justin Richer 2012-01-04 16:39:26 -05:00
parent 4db5d50864
commit 20f74269e1
6 changed files with 113 additions and 91 deletions

View File

@ -1,10 +1,14 @@
package org.mitre.openid.connect.model; package org.mitre.openid.connect.model;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@Entity @Entity
public class Address { public class Address {
private Long id;
private String formatted; private String formatted;
private String street_address; private String street_address;
private String locality; private String locality;
@ -12,6 +16,8 @@ public class Address {
private String postal_code; private String postal_code;
private String country; private String country;
/** /**
* @return the formatted * @return the formatted
*/ */
@ -85,4 +91,20 @@ public class Address {
this.country = 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;
}
} }

View File

@ -8,6 +8,8 @@ import javax.persistence.Entity;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType; import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Temporal; import javax.persistence.Temporal;
import org.springframework.security.oauth2.provider.ClientDetails; import org.springframework.security.oauth2.provider.ClientDetails;
@ -48,7 +50,7 @@ public class ApprovedSite {
* @return the id * @return the id
*/ */
@Id @Id
@GeneratedValue(strategy = GenerationType.AUTO) @GeneratedValue(strategy = GenerationType.IDENTITY)
public Long getId() { public Long getId() {
return id; return id;
} }
@ -63,6 +65,7 @@ public class ApprovedSite {
/** /**
* @return the userInfo * @return the userInfo
*/ */
@ManyToOne
public UserInfo getUserInfo() { public UserInfo getUserInfo() {
return userInfo; return userInfo;
} }
@ -123,6 +126,7 @@ public class ApprovedSite {
/** /**
* @return the allowedScopes * @return the allowedScopes
*/ */
@OneToMany
public Collection<String> getAllowedScopes() { public Collection<String> getAllowedScopes() {
return allowedScopes; return allowedScopes;
} }

View File

@ -2,7 +2,12 @@ package org.mitre.openid.connect.model;
import java.util.Date; import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Entity; 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. * Class to contain a logged event in the system.
@ -20,4 +25,45 @@ public class Event {
private EventType type; private EventType type;
private Date timestamp; 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;
}
} }

View File

@ -1,105 +1,51 @@
package org.mitre.openid.connect.model; package org.mitre.openid.connect.model;
import javax.persistence.Entity; 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.Jwt;
import org.mitre.jwt.model.JwtClaims;
/* /*
* TODO: This class needs to be encoded as a JWT * TODO: This class needs to be encoded as a JWT
*/ */
@Entity @Entity
public class IdToken extends Jwt { public class IdToken extends JwtClaims {
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;
private String iss;
private String user_id;
private String aud;
private String exp;
private String iso29115;
private String nonce;
private String auth_time;
/** /**
* @return the iss * @return the id
*/ */
public String getIss() { @Id
return iss; @GeneratedValue(strategy=GenerationType.IDENTITY)
} public Long getId() {
return id;
}
/** /**
* @param iss the iss to set * @param id the id to set
*/ */
public void setIss(String iss) { public void setId(Long id) {
this.iss = iss; this.id = id;
}
public String getUserId() {
return getClaimAsString(USER_ID);
} }
/**
* @return the user_id public void setUserId(String user_id) {
*/ setClaim(USER_ID, 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;
} }
// TODO: add in other fields
} }

View File

@ -1,6 +1,7 @@
package org.mitre.openid.connect.model; package org.mitre.openid.connect.model;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.Id;
@Entity @Entity
public class UserInfo { public class UserInfo {
@ -29,6 +30,7 @@ public class UserInfo {
/** /**
* @return the user_id * @return the user_id
*/ */
@Id
public String getUser_id() { public String getUser_id() {
return user_id; return user_id;
} }

View File

@ -6,6 +6,7 @@ import java.util.Date;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType; import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.ManyToOne;
import org.springframework.security.oauth2.provider.ClientDetails; import org.springframework.security.oauth2.provider.ClientDetails;
@ -19,7 +20,7 @@ public class WhitelistedSite {
// unique id // unique id
@Id @Id
@GeneratedValue(strategy = GenerationType.AUTO) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; private Long id;
// who added this site to the whitelist (should be an admin) // who added this site to the whitelist (should be an admin)
@ -30,5 +31,6 @@ public class WhitelistedSite {
// what scopes be allowed by default // what scopes be allowed by default
// this should include all information for what data to access // this should include all information for what data to access
@ManyToOne
private Collection<String> allowedScopes; private Collection<String> allowedScopes;
} }