From ef3a69697220b1bcec4cebde75da1414c926b5b4 Mon Sep 17 00:00:00 2001 From: Justin Richer Date: Mon, 16 Feb 2015 11:07:41 -0500 Subject: [PATCH] removed getBySubject and getAll from user info repository and service layers, closes #760 --- .../openid/connect/model/DefaultUserInfo.java | 4 +--- .../repository/UserInfoRepository.java | 24 +++---------------- .../connect/service/UserInfoService.java | 9 ------- .../impl/JpaUserInfoRepository.java | 20 +--------------- .../service/impl/DefaultUserInfoService.java | 5 ---- 5 files changed, 5 insertions(+), 57 deletions(-) diff --git a/openid-connect-common/src/main/java/org/mitre/openid/connect/model/DefaultUserInfo.java b/openid-connect-common/src/main/java/org/mitre/openid/connect/model/DefaultUserInfo.java index afee564bc..93ddb2aff 100644 --- a/openid-connect-common/src/main/java/org/mitre/openid/connect/model/DefaultUserInfo.java +++ b/openid-connect-common/src/main/java/org/mitre/openid/connect/model/DefaultUserInfo.java @@ -33,9 +33,7 @@ import com.google.gson.JsonObject; @Entity @Table(name="user_info") @NamedQueries({ - @NamedQuery(name="DefaultUserInfo.getAll", query = "select u from DefaultUserInfo u"), - @NamedQuery(name="DefaultUserInfo.getByUsername", query = "select u from DefaultUserInfo u WHERE u.preferredUsername = :username"), - @NamedQuery(name="DefaultUserInfo.getBySubject", query = "select u from DefaultUserInfo u WHERE u.sub = :sub") + @NamedQuery(name="DefaultUserInfo.getByUsername", query = "select u from DefaultUserInfo u WHERE u.preferredUsername = :username") }) public class DefaultUserInfo implements UserInfo { diff --git a/openid-connect-common/src/main/java/org/mitre/openid/connect/repository/UserInfoRepository.java b/openid-connect-common/src/main/java/org/mitre/openid/connect/repository/UserInfoRepository.java index 115ad25af..ff8c76ca1 100644 --- a/openid-connect-common/src/main/java/org/mitre/openid/connect/repository/UserInfoRepository.java +++ b/openid-connect-common/src/main/java/org/mitre/openid/connect/repository/UserInfoRepository.java @@ -16,8 +16,6 @@ ******************************************************************************/ package org.mitre.openid.connect.repository; -import java.util.Collection; - import org.mitre.openid.connect.model.UserInfo; /** @@ -29,37 +27,21 @@ import org.mitre.openid.connect.model.UserInfo; public interface UserInfoRepository { /** - * Returns the UserInfo for the given subject + * Persists a UserInfo object, if possible. * - * @param sub - * the subject of the UserInfo - * @return a valid UserInfo if it exists, null otherwise - */ - public UserInfo getBySubject(String sub); - - /** - * Persists a UserInfo - * * @param user - * @return + * @return the persisted object */ public UserInfo save(UserInfo userInfo); /** - * Removes the given UserInfo from the repository + * Removes the given UserInfo from the repository, if possible. * * @param userInfo * the UserInfo object to remove */ public void remove(UserInfo userInfo); - /** - * Return a collection of all UserInfos managed by this repository - * - * @return the UserInfo collection, or null - */ - public Collection getAll(); - /** * Get a UserInfo object by its preferred_username field * @param username diff --git a/openid-connect-common/src/main/java/org/mitre/openid/connect/service/UserInfoService.java b/openid-connect-common/src/main/java/org/mitre/openid/connect/service/UserInfoService.java index f43379ff6..9541a1fa3 100644 --- a/openid-connect-common/src/main/java/org/mitre/openid/connect/service/UserInfoService.java +++ b/openid-connect-common/src/main/java/org/mitre/openid/connect/service/UserInfoService.java @@ -34,15 +34,6 @@ public interface UserInfoService { */ public void save(UserInfo userInfo); - /** - * Get UserInfo for the Subject - * - * @param sub - * subject for UserInfo - * @return UserInfo for sub, or null - */ - public UserInfo getBySubject(String userId); - /** * Remove the UserInfo * diff --git a/openid-connect-server/src/main/java/org/mitre/openid/connect/repository/impl/JpaUserInfoRepository.java b/openid-connect-server/src/main/java/org/mitre/openid/connect/repository/impl/JpaUserInfoRepository.java index 88651eb0e..315365885 100644 --- a/openid-connect-server/src/main/java/org/mitre/openid/connect/repository/impl/JpaUserInfoRepository.java +++ b/openid-connect-server/src/main/java/org/mitre/openid/connect/repository/impl/JpaUserInfoRepository.java @@ -37,21 +37,12 @@ import org.springframework.transaction.annotation.Transactional; * @author Michael Joseph Walsh * */ -@Repository +@Repository("jpaUserInfoRepository") public class JpaUserInfoRepository implements UserInfoRepository { @PersistenceContext private EntityManager manager; - @Override - @Transactional - public UserInfo getBySubject(String sub) { - TypedQuery query = manager.createNamedQuery("DefaultUserInfo.getBySubject", DefaultUserInfo.class); - query.setParameter("sub", sub); - - return getSingleResult(query.getResultList()); - } - @Override @Transactional public UserInfo save(UserInfo userInfo) { @@ -72,15 +63,6 @@ public class JpaUserInfoRepository implements UserInfoRepository { } } - @Override - @Transactional - public Collection getAll() { - - TypedQuery query = manager.createNamedQuery("DefaultUserInfo.getAll", DefaultUserInfo.class); - - return query.getResultList(); - } - /** * Get a single UserInfo object by its username */ diff --git a/openid-connect-server/src/main/java/org/mitre/openid/connect/service/impl/DefaultUserInfoService.java b/openid-connect-server/src/main/java/org/mitre/openid/connect/service/impl/DefaultUserInfoService.java index f2eceb45e..d39537daf 100644 --- a/openid-connect-server/src/main/java/org/mitre/openid/connect/service/impl/DefaultUserInfoService.java +++ b/openid-connect-server/src/main/java/org/mitre/openid/connect/service/impl/DefaultUserInfoService.java @@ -49,11 +49,6 @@ public class DefaultUserInfoService implements UserInfoService { userInfoRepository.save(userInfo); } - @Override - public UserInfo getBySubject(String userId) { - return userInfoRepository.getBySubject(userId); - } - @Override public void remove(UserInfo userInfo) { userInfoRepository.remove(userInfo);