added basic repository and model components

pull/59/head
Justin Richer 13 years ago
parent 9ada098b75
commit 9ab65b84a3

@ -0,0 +1,155 @@
package org.mitre.openid.connect.model;
import java.util.Collection;
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;
import org.springframework.security.oauth2.provider.ClientDetails;
@Entity
public class ApprovedSite {
// unique id
private Long id;
// which user made the approval
private UserInfo userInfo;
// which OAuth2 client is this tied to
private ClientDetails clientDetails;
// when was this first approved?
private Date creationDate;
// when was this last accessed?
private Date accessDate;
// if this is a time-limited access, when does it run out?
private Date timeoutDate;
// what scopes have been allowed
// this should include all information for what data to access
private Collection<String> allowedScopes;
// TODO: should we store the OAuth2 tokens and IdTokens here?
public ApprovedSite() {
}
/**
* @return the id
*/
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
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 creationDate
*/
@Basic
@Temporal(javax.persistence.TemporalType.TIMESTAMP)
public Date getCreationDate() {
return creationDate;
}
/**
* @param creationDate the creationDate to set
*/
public void setCreationDate(Date creationDate) {
this.creationDate = creationDate;
}
/**
* @return the accessDate
*/
@Basic
@Temporal(javax.persistence.TemporalType.TIMESTAMP)
public Date getAccessDate() {
return accessDate;
}
/**
* @param accessDate the accessDate to set
*/
public void setAccessDate(Date accessDate) {
this.accessDate = accessDate;
}
/**
* @return the allowedScopes
*/
public Collection<String> getAllowedScopes() {
return allowedScopes;
}
/**
* @param allowedScopes the allowedScopes to set
*/
public void setAllowedScopes(Collection<String> allowedScopes) {
this.allowedScopes = allowedScopes;
}
/**
* @return the timeoutDate
*/
@Basic
@Temporal(javax.persistence.TemporalType.TIMESTAMP)
public Date getTimeoutDate() {
return timeoutDate;
}
/**
* @param timeoutDate the timeoutDate to set
*/
public void setTimeoutDate(Date timeoutDate) {
this.timeoutDate = timeoutDate;
}
}

@ -0,0 +1,23 @@
package org.mitre.openid.connect.model;
import java.util.Date;
import javax.persistence.Entity;
/**
* Class to contain a logged event in the system.
*
* @author jricher
*
*/
@Entity
public class Event {
public static enum EventType { LOGIN, AUTHORIZATION, ACCESS }
private Long id;
private EventType type;
private Date timestamp;
}

@ -0,0 +1,34 @@
package org.mitre.openid.connect.model;
import java.util.Collection;
import java.util.Date;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import org.springframework.security.oauth2.provider.ClientDetails;
/**
* Indicator that login to a site should be automatically granted
* without user interaction.
* @author jricher
*
*/
public class WhitelistedSite {
// unique id
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
// who added this site to the whitelist (should be an admin)
private UserInfo userInfo;
// which OAuth2 client is this tied to
private ClientDetails clientDetails;
// what scopes be allowed by default
// this should include all information for what data to access
private Collection<String> allowedScopes;
}

@ -0,0 +1,11 @@
package org.mitre.openid.connect.repository;
import org.mitre.openid.connect.model.ApprovedSite;
public interface ApprovedSiteRepository {
public ApprovedSite getById(Long id);
public ApprovedSite getByUrl(String url);
}

@ -0,0 +1,5 @@
package org.mitre.openid.connect.repository;
public interface IdTokenRepository {
}

@ -0,0 +1,9 @@
package org.mitre.openid.connect.repository;
import org.mitre.openid.connect.model.UserInfo;
public interface UserInfoRepository {
public UserInfo getByUserId(String user_id);
}

@ -0,0 +1,5 @@
package org.mitre.openid.connect.repository;
public interface WhitelistedSiteRepository {
}
Loading…
Cancel
Save