diff --git a/openid-connect-common/src/main/java/org/mitre/openid/connect/model/ResourceSet.java b/openid-connect-common/src/main/java/org/mitre/openid/connect/model/ResourceSet.java index 88900d10b..5b59e5825 100644 --- a/openid-connect-common/src/main/java/org/mitre/openid/connect/model/ResourceSet.java +++ b/openid-connect-common/src/main/java/org/mitre/openid/connect/model/ResourceSet.java @@ -28,7 +28,6 @@ import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; -import javax.persistence.OneToMany; import javax.persistence.Table; @Entity @@ -113,9 +112,10 @@ public class ResourceSet { * @return the scopes */ @ElementCollection(fetch=FetchType.EAGER) + @Column(name = "scope") @CollectionTable( name="resource_set_scope", - joinColumns=@JoinColumn(name="owner_id") + joinColumns=@JoinColumn(name = "owner_id") ) public Set getScopes() { return scopes; diff --git a/openid-connect-common/src/main/java/org/mitre/openid/connect/service/ResourceSetService.java b/openid-connect-common/src/main/java/org/mitre/openid/connect/service/ResourceSetService.java index 74ee0799b..c9e6e1bd4 100644 --- a/openid-connect-common/src/main/java/org/mitre/openid/connect/service/ResourceSetService.java +++ b/openid-connect-common/src/main/java/org/mitre/openid/connect/service/ResourceSetService.java @@ -29,4 +29,6 @@ public interface ResourceSetService { public ResourceSet saveNew(ResourceSet rs); + public ResourceSet getById(Long id); + } diff --git a/openid-connect-common/src/main/java/org/mitre/util/JsonUtils.java b/openid-connect-common/src/main/java/org/mitre/util/JsonUtils.java index e1638e041..c0c877e0e 100644 --- a/openid-connect-common/src/main/java/org/mitre/util/JsonUtils.java +++ b/openid-connect-common/src/main/java/org/mitre/util/JsonUtils.java @@ -155,6 +155,22 @@ public class JsonUtils { return null; } } + + /** + * Gets the value of the given member as a Long, null if it doesn't exist + */ + public static Long getAsLong(JsonObject o, String member) { + if (o.has(member)) { + JsonElement e = o.get(member); + if (e != null && e.isJsonPrimitive()) { + return e.getAsLong(); + } else { + return null; + } + } else { + return null; + } + } /** * Gets the value of the given given member as a set of strings, null if it doesn't exist diff --git a/openid-connect-server/src/main/java/org/mitre/openid/connect/repository/ResourceSetRepository.java b/openid-connect-server/src/main/java/org/mitre/openid/connect/repository/ResourceSetRepository.java index 08932d7e3..f008532ba 100644 --- a/openid-connect-server/src/main/java/org/mitre/openid/connect/repository/ResourceSetRepository.java +++ b/openid-connect-server/src/main/java/org/mitre/openid/connect/repository/ResourceSetRepository.java @@ -27,4 +27,6 @@ public interface ResourceSetRepository { public ResourceSet save(ResourceSet rs); + public ResourceSet getById(Long id); + } diff --git a/openid-connect-server/src/main/java/org/mitre/openid/connect/repository/impl/JpaResourceSetRepository.java b/openid-connect-server/src/main/java/org/mitre/openid/connect/repository/impl/JpaResourceSetRepository.java index 5d9b01fdb..8cf2073f5 100644 --- a/openid-connect-server/src/main/java/org/mitre/openid/connect/repository/impl/JpaResourceSetRepository.java +++ b/openid-connect-server/src/main/java/org/mitre/openid/connect/repository/impl/JpaResourceSetRepository.java @@ -42,4 +42,9 @@ public class JpaResourceSetRepository implements ResourceSetRepository { return JpaUtil.saveOrUpdate(rs.getId(), em, rs); } + @Override + public ResourceSet getById(Long id) { + return em.find(ResourceSet.class, id); + } + } diff --git a/openid-connect-server/src/main/java/org/mitre/openid/connect/service/impl/DefaultResourceSetService.java b/openid-connect-server/src/main/java/org/mitre/openid/connect/service/impl/DefaultResourceSetService.java index b79f233a7..c89b0e6a9 100644 --- a/openid-connect-server/src/main/java/org/mitre/openid/connect/service/impl/DefaultResourceSetService.java +++ b/openid-connect-server/src/main/java/org/mitre/openid/connect/service/impl/DefaultResourceSetService.java @@ -45,6 +45,11 @@ public class DefaultResourceSetService implements ResourceSetService { return saved; } + + @Override + public ResourceSet getById(Long id) { + return repository.getById(id); + } diff --git a/openid-connect-server/src/main/java/org/mitre/openid/connect/view/ResourceSetEntityView.java b/openid-connect-server/src/main/java/org/mitre/openid/connect/view/ResourceSetEntityAbbreviatedView.java similarity index 100% rename from openid-connect-server/src/main/java/org/mitre/openid/connect/view/ResourceSetEntityView.java rename to openid-connect-server/src/main/java/org/mitre/openid/connect/view/ResourceSetEntityAbbreviatedView.java