Made interfaces... deleted a thing.
parent
ffe31e6049
commit
fd91c884bb
|
@ -47,7 +47,7 @@ public class ApprovedSite {
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
// which user made the approval
|
// which user made the approval
|
||||||
private UserInfo userInfo;
|
private String userInfo;
|
||||||
|
|
||||||
// which OAuth2 client is this tied to
|
// which OAuth2 client is this tied to
|
||||||
private ClientDetailsEntity clientDetails;
|
private ClientDetailsEntity clientDetails;
|
||||||
|
@ -93,16 +93,15 @@ public class ApprovedSite {
|
||||||
/**
|
/**
|
||||||
* @return the userInfo
|
* @return the userInfo
|
||||||
*/
|
*/
|
||||||
@ManyToOne
|
@Basic
|
||||||
@JoinColumn(name="userinfo_id")
|
public String getUserInfo() {
|
||||||
public UserInfo getUserInfo() {
|
|
||||||
return userInfo;
|
return userInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param userInfo the userInfo to set
|
* @param userInfo the userInfo to set
|
||||||
*/
|
*/
|
||||||
public void setUserInfo(UserInfo userInfo) {
|
public void setUserInfo(String userInfo) {
|
||||||
this.userInfo = userInfo;
|
this.userInfo = userInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,310 +1,202 @@
|
||||||
/*******************************************************************************
|
|
||||||
* Copyright 2012 The MITRE Corporation
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
******************************************************************************/
|
|
||||||
package org.mitre.openid.connect.model;
|
package org.mitre.openid.connect.model;
|
||||||
|
|
||||||
import javax.persistence.Basic;
|
import javax.persistence.Basic;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.Inheritance;
|
||||||
|
import javax.persistence.InheritanceType;
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.NamedQueries;
|
|
||||||
import javax.persistence.NamedQuery;
|
|
||||||
import javax.persistence.OneToOne;
|
import javax.persistence.OneToOne;
|
||||||
import javax.persistence.Table;
|
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="userinfo")
|
@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
|
||||||
@NamedQueries({
|
public interface UserInfo {
|
||||||
@NamedQuery(name="UserInfo.getAll", query = "select u from UserInfo u")
|
|
||||||
})
|
|
||||||
public class UserInfo {
|
|
||||||
|
|
||||||
private String userId;
|
|
||||||
private String name;
|
|
||||||
private String givenName;
|
|
||||||
private String familyName;
|
|
||||||
private String middleName;
|
|
||||||
private String nickname;
|
|
||||||
private String profile;
|
|
||||||
private String picture;
|
|
||||||
private String website;
|
|
||||||
private String email;
|
|
||||||
private Boolean verified;
|
|
||||||
private String gender;
|
|
||||||
private String zoneinfo;
|
|
||||||
private String locale;
|
|
||||||
private String phoneNumber;
|
|
||||||
private Address address;
|
|
||||||
private String updatedTime;
|
|
||||||
|
|
||||||
|
|
||||||
public JsonObject toJson() {
|
|
||||||
JsonObject obj = new JsonObject();
|
|
||||||
|
|
||||||
obj.addProperty("user_id", getUserId());
|
|
||||||
obj.addProperty("name", getName());
|
|
||||||
obj.addProperty("given_name", getGivenName());
|
|
||||||
obj.addProperty("family_name", getFamilyName());
|
|
||||||
obj.addProperty("middle_name", getMiddleName());
|
|
||||||
obj.addProperty("nickname", getNickname());
|
|
||||||
obj.addProperty("profile", getProfile());
|
|
||||||
obj.addProperty("picture", getPicture());
|
|
||||||
obj.addProperty("website", getWebsite());
|
|
||||||
obj.addProperty("verified", getVerified());
|
|
||||||
obj.addProperty("gender", getGender());
|
|
||||||
obj.addProperty("zone_info", getZoneinfo());
|
|
||||||
obj.addProperty("locale", getLocale());
|
|
||||||
obj.addProperty("phone_number", getPhoneNumber());
|
|
||||||
obj.addProperty("updated_time", getUpdatedTime());
|
|
||||||
|
|
||||||
JsonObject addr = new JsonObject();
|
|
||||||
addr.addProperty("formatted", getAddress().getFormatted());
|
|
||||||
addr.addProperty("street_address", getAddress().getStreetAddress());
|
|
||||||
addr.addProperty("locality", getAddress().getLocality());
|
|
||||||
addr.addProperty("region", getAddress().getRegion());
|
|
||||||
addr.addProperty("postal_code", getAddress().getPostalCode());
|
|
||||||
addr.addProperty("country", getAddress().getCountry());
|
|
||||||
|
|
||||||
obj.add("address", addr);
|
|
||||||
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the userId
|
* @return the userId
|
||||||
*/
|
*/
|
||||||
@Id
|
@Id
|
||||||
public String getUserId() {
|
public abstract String getUserId();
|
||||||
return userId;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @param userId the userId to set
|
* @param userId the userId to set
|
||||||
*/
|
*/
|
||||||
public void setUserId(String userId) {
|
public abstract void setUserId(String userId);
|
||||||
this.userId = userId;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @return the name
|
* @return the name
|
||||||
*/
|
*/
|
||||||
@Basic
|
@Basic
|
||||||
public String getName() {
|
public abstract String getName();
|
||||||
return name;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @param name the name to set
|
* @param name the name to set
|
||||||
*/
|
*/
|
||||||
public void setName(String name) {
|
public abstract void setName(String name);
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @return the givenName
|
* @return the givenName
|
||||||
*/
|
*/
|
||||||
@Basic
|
@Basic
|
||||||
public String getGivenName() {
|
public abstract String getGivenName();
|
||||||
return givenName;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @param givenName the givenName to set
|
* @param givenName the givenName to set
|
||||||
*/
|
*/
|
||||||
public void setGivenName(String givenName) {
|
public abstract void setGivenName(String givenName);
|
||||||
this.givenName = givenName;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @return the familyName
|
* @return the familyName
|
||||||
*/
|
*/
|
||||||
@Basic
|
@Basic
|
||||||
public String getFamilyName() {
|
public abstract String getFamilyName();
|
||||||
return familyName;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @param familyName the familyName to set
|
* @param familyName the familyName to set
|
||||||
*/
|
*/
|
||||||
public void setFamilyName(String familyName) {
|
public abstract void setFamilyName(String familyName);
|
||||||
this.familyName = familyName;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @return the middleName
|
* @return the middleName
|
||||||
*/
|
*/
|
||||||
@Basic
|
@Basic
|
||||||
public String getMiddleName() {
|
public abstract String getMiddleName();
|
||||||
return middleName;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @param middleName the middleName to set
|
* @param middleName the middleName to set
|
||||||
*/
|
*/
|
||||||
public void setMiddleName(String middleName) {
|
public abstract void setMiddleName(String middleName);
|
||||||
this.middleName = middleName;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @return the nickname
|
* @return the nickname
|
||||||
*/
|
*/
|
||||||
@Basic
|
@Basic
|
||||||
public String getNickname() {
|
public abstract String getNickname();
|
||||||
return nickname;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @param nickname the nickname to set
|
* @param nickname the nickname to set
|
||||||
*/
|
*/
|
||||||
public void setNickname(String nickname) {
|
public abstract void setNickname(String nickname);
|
||||||
this.nickname = nickname;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @return the profile
|
* @return the profile
|
||||||
*/
|
*/
|
||||||
@Basic
|
@Basic
|
||||||
public String getProfile() {
|
public abstract String getProfile();
|
||||||
return profile;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @param profile the profile to set
|
* @param profile the profile to set
|
||||||
*/
|
*/
|
||||||
public void setProfile(String profile) {
|
public abstract void setProfile(String profile);
|
||||||
this.profile = profile;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @return the picture
|
* @return the picture
|
||||||
*/
|
*/
|
||||||
@Basic
|
@Basic
|
||||||
public String getPicture() {
|
public abstract String getPicture();
|
||||||
return picture;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @param picture the picture to set
|
* @param picture the picture to set
|
||||||
*/
|
*/
|
||||||
public void setPicture(String picture) {
|
public abstract void setPicture(String picture);
|
||||||
this.picture = picture;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @return the website
|
* @return the website
|
||||||
*/
|
*/
|
||||||
@Basic
|
@Basic
|
||||||
public String getWebsite() {
|
public abstract String getWebsite();
|
||||||
return website;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @param website the website to set
|
* @param website the website to set
|
||||||
*/
|
*/
|
||||||
public void setWebsite(String website) {
|
public abstract void setWebsite(String website);
|
||||||
this.website = website;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @return the email
|
* @return the email
|
||||||
*/
|
*/
|
||||||
@Basic
|
@Basic
|
||||||
public String getEmail() {
|
public abstract String getEmail();
|
||||||
return email;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @param email the email to set
|
* @param email the email to set
|
||||||
*/
|
*/
|
||||||
public void setEmail(String email) {
|
public abstract void setEmail(String email);
|
||||||
this.email = email;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @return the verified
|
* @return the verified
|
||||||
*/
|
*/
|
||||||
@Basic
|
@Basic
|
||||||
public Boolean getVerified() {
|
public abstract Boolean getVerified();
|
||||||
return verified;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @param verified the verified to set
|
* @param verified the verified to set
|
||||||
*/
|
*/
|
||||||
public void setVerified(Boolean verified) {
|
public abstract void setVerified(Boolean verified);
|
||||||
this.verified = verified;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @return the gender
|
* @return the gender
|
||||||
*/
|
*/
|
||||||
@Basic
|
@Basic
|
||||||
public String getGender() {
|
public abstract String getGender();
|
||||||
return gender;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @param gender the gender to set
|
* @param gender the gender to set
|
||||||
*/
|
*/
|
||||||
public void setGender(String gender) {
|
public abstract void setGender(String gender);
|
||||||
this.gender = gender;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @return the zoneinfo
|
* @return the zoneinfo
|
||||||
*/
|
*/
|
||||||
@Basic
|
@Basic
|
||||||
public String getZoneinfo() {
|
public abstract String getZoneinfo();
|
||||||
return zoneinfo;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @param zoneinfo the zoneinfo to set
|
* @param zoneinfo the zoneinfo to set
|
||||||
*/
|
*/
|
||||||
public void setZoneinfo(String zoneinfo) {
|
public abstract void setZoneinfo(String zoneinfo);
|
||||||
this.zoneinfo = zoneinfo;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @return the locale
|
* @return the locale
|
||||||
*/
|
*/
|
||||||
@Basic
|
@Basic
|
||||||
public String getLocale() {
|
public abstract String getLocale();
|
||||||
return locale;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @param locale the locale to set
|
* @param locale the locale to set
|
||||||
*/
|
*/
|
||||||
public void setLocale(String locale) {
|
public abstract void setLocale(String locale);
|
||||||
this.locale = locale;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @return the phoneNumber
|
* @return the phoneNumber
|
||||||
*/
|
*/
|
||||||
@Basic
|
@Basic
|
||||||
public String getPhoneNumber() {
|
public abstract String getPhoneNumber();
|
||||||
return phoneNumber;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @param phoneNumber the phoneNumber to set
|
* @param phoneNumber the phoneNumber to set
|
||||||
*/
|
*/
|
||||||
public void setPhoneNumber(String phoneNumber) {
|
public abstract void setPhoneNumber(String phoneNumber);
|
||||||
this.phoneNumber = phoneNumber;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @return the address
|
* @return the address
|
||||||
*/
|
*/
|
||||||
@OneToOne
|
@OneToOne
|
||||||
@JoinColumn(name="address_id")
|
public abstract Address getAddress();
|
||||||
public Address getAddress() {
|
|
||||||
return address;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @param address the address to set
|
* @param address the address to set
|
||||||
*/
|
*/
|
||||||
public void setAddress(Address address) {
|
public abstract void setAddress(Address address);
|
||||||
this.address = address;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @return the updatedTime
|
* @return the updatedTime
|
||||||
*/
|
*/
|
||||||
@Basic
|
@Basic
|
||||||
public String getUpdatedTime() {
|
public abstract String getUpdatedTime();
|
||||||
return updatedTime;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @param updatedTime the updatedTime to set
|
* @param updatedTime the updatedTime to set
|
||||||
*/
|
*/
|
||||||
public void setUpdatedTime(String updatedTime) {
|
public abstract void setUpdatedTime(String updatedTime);
|
||||||
this.updatedTime = updatedTime;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
|
@ -17,6 +17,7 @@ package org.mitre.openid.connect.model;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.persistence.Basic;
|
||||||
import javax.persistence.ElementCollection;
|
import javax.persistence.ElementCollection;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.FetchType;
|
import javax.persistence.FetchType;
|
||||||
|
@ -48,7 +49,7 @@ public class WhitelistedSite {
|
||||||
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)
|
||||||
private UserInfo userInfo;
|
private String userInfo;
|
||||||
|
|
||||||
// which OAuth2 client is this tied to
|
// which OAuth2 client is this tied to
|
||||||
private ClientDetailsEntity clientDetails;
|
private ClientDetailsEntity clientDetails;
|
||||||
|
@ -83,16 +84,15 @@ public class WhitelistedSite {
|
||||||
/**
|
/**
|
||||||
* @return the userInfo
|
* @return the userInfo
|
||||||
*/
|
*/
|
||||||
@ManyToOne
|
@Basic
|
||||||
@JoinColumn(name="userinfo_id")
|
public String getUserInfo() {
|
||||||
public UserInfo getUserInfo() {
|
|
||||||
return userInfo;
|
return userInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param userInfo the userInfo to set
|
* @param userInfo the userInfo to set
|
||||||
*/
|
*/
|
||||||
public void setUserInfo(UserInfo userInfo) {
|
public void setUserInfo(String userInfo) {
|
||||||
this.userInfo = userInfo;
|
this.userInfo = userInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ package org.mitre.openid.connect.repository;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
|
import org.mitre.openid.connect.model.DefaultUserInfo;
|
||||||
import org.mitre.openid.connect.model.UserInfo;
|
import org.mitre.openid.connect.model.UserInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -42,7 +43,7 @@ public interface UserInfoRepository {
|
||||||
* @param user
|
* @param user
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public UserInfo save(UserInfo userInfo);
|
public UserInfo save(DefaultUserInfo userInfo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the given UserInfo from the repository
|
* Removes the given UserInfo from the repository
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package org.mitre.openid.connect.service;
|
package org.mitre.openid.connect.service;
|
||||||
|
|
||||||
|
import org.mitre.openid.connect.model.DefaultUserInfo;
|
||||||
import org.mitre.openid.connect.model.UserInfo;
|
import org.mitre.openid.connect.model.UserInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,7 +32,7 @@ public interface UserInfoService {
|
||||||
* @param userInfo
|
* @param userInfo
|
||||||
* the UserInfo to be saved
|
* the UserInfo to be saved
|
||||||
*/
|
*/
|
||||||
public void save(UserInfo userInfo);
|
public void save(DefaultUserInfo userInfo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get UserInfo for user id
|
* Get UserInfo for user id
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class JpaApprovedSiteRepository implements ApprovedSiteRepository {
|
||||||
public Collection<ApprovedSite> getByUserInfo(UserInfo userInfo) {
|
public Collection<ApprovedSite> getByUserInfo(UserInfo userInfo) {
|
||||||
TypedQuery<ApprovedSite> query = manager.createNamedQuery(
|
TypedQuery<ApprovedSite> query = manager.createNamedQuery(
|
||||||
"ApprovedSite.getByUserInfo", ApprovedSite.class);
|
"ApprovedSite.getByUserInfo", ApprovedSite.class);
|
||||||
query.setParameter("approvedSiteUserInfo", userInfo);
|
query.setParameter("approvedSiteUserInfo", userInfo.getUserId());
|
||||||
|
|
||||||
List<ApprovedSite> found = query.getResultList();
|
List<ApprovedSite> found = query.getResultList();
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ import javax.persistence.EntityManager;
|
||||||
import javax.persistence.PersistenceContext;
|
import javax.persistence.PersistenceContext;
|
||||||
import javax.persistence.TypedQuery;
|
import javax.persistence.TypedQuery;
|
||||||
|
|
||||||
|
import org.mitre.openid.connect.model.DefaultUserInfo;
|
||||||
import org.mitre.openid.connect.model.UserInfo;
|
import org.mitre.openid.connect.model.UserInfo;
|
||||||
import org.mitre.openid.connect.repository.UserInfoRepository;
|
import org.mitre.openid.connect.repository.UserInfoRepository;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
@ -43,12 +44,12 @@ public class JpaUserInfoRepository implements UserInfoRepository {
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public UserInfo getByUserId(String userId) {
|
public UserInfo getByUserId(String userId) {
|
||||||
return manager.find(UserInfo.class, userId);
|
return manager.find(DefaultUserInfo.class, userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public UserInfo save(UserInfo userInfo) {
|
public UserInfo save(DefaultUserInfo userInfo) {
|
||||||
return saveOrUpdate(userInfo.getUserId(), manager, userInfo);
|
return saveOrUpdate(userInfo.getUserId(), manager, userInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +57,7 @@ public class JpaUserInfoRepository implements UserInfoRepository {
|
||||||
@Transactional
|
@Transactional
|
||||||
public void remove(UserInfo userInfo) {
|
public void remove(UserInfo userInfo) {
|
||||||
|
|
||||||
UserInfo found = manager.find(UserInfo.class, userInfo.getUserId());
|
UserInfo found = manager.find(DefaultUserInfo.class, userInfo.getUserId());
|
||||||
|
|
||||||
if (found != null) {
|
if (found != null) {
|
||||||
manager.remove(userInfo);
|
manager.remove(userInfo);
|
||||||
|
@ -68,7 +69,7 @@ public class JpaUserInfoRepository implements UserInfoRepository {
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void removeByUserId(String userId) {
|
public void removeByUserId(String userId) {
|
||||||
UserInfo found = manager.find(UserInfo.class, userId);
|
UserInfo found = manager.find(DefaultUserInfo.class, userId);
|
||||||
|
|
||||||
if (found != null) {
|
if (found != null) {
|
||||||
manager.remove(found);
|
manager.remove(found);
|
||||||
|
@ -79,10 +80,10 @@ public class JpaUserInfoRepository implements UserInfoRepository {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public Collection<UserInfo> getAll() {
|
public Collection<DefaultUserInfo> getAll() {
|
||||||
|
|
||||||
TypedQuery<UserInfo> query = manager.createNamedQuery(
|
TypedQuery<DefaultUserInfo> query = manager.createNamedQuery(
|
||||||
"UserInfo.getAll", UserInfo.class);
|
"DefaultUserInfo.getAll", DefaultUserInfo.class);
|
||||||
|
|
||||||
return query.getResultList();
|
return query.getResultList();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,75 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* Copyright 2012 The MITRE Corporation
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
******************************************************************************/
|
|
||||||
package org.mitre.openid.connect.repository.impl;
|
|
||||||
|
|
||||||
import static org.mitre.util.jpa.JpaUtil.saveOrUpdate;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
import javax.persistence.EntityManager;
|
|
||||||
import javax.persistence.PersistenceContext;
|
|
||||||
import javax.persistence.TypedQuery;
|
|
||||||
|
|
||||||
import org.mitre.openid.connect.model.WhitelistedSite;
|
|
||||||
import org.mitre.openid.connect.repository.WhitelistedSiteRepository;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
public class JpaWhitelistedSiteRepositiory implements WhitelistedSiteRepository {
|
|
||||||
|
|
||||||
@PersistenceContext
|
|
||||||
private EntityManager manager;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public Collection<WhitelistedSite> getAll() {
|
|
||||||
TypedQuery<WhitelistedSite> query = manager.createNamedQuery(
|
|
||||||
"WhitelistedSite.getAll", WhitelistedSite.class);
|
|
||||||
return query.getResultList();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public WhitelistedSite getById(Long id) {
|
|
||||||
return manager.find(WhitelistedSite.class, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public void remove(WhitelistedSite whitelistedSite) {
|
|
||||||
WhitelistedSite found = manager.find(WhitelistedSite.class,
|
|
||||||
whitelistedSite.getId());
|
|
||||||
|
|
||||||
if (found != null) {
|
|
||||||
manager.remove(whitelistedSite);
|
|
||||||
} else {
|
|
||||||
throw new IllegalArgumentException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public void removeById(Long id) {
|
|
||||||
WhitelistedSite found = getById(id);
|
|
||||||
|
|
||||||
manager.remove(found);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional
|
|
||||||
public WhitelistedSite save(WhitelistedSite whiteListedSite) {
|
|
||||||
return saveOrUpdate(whiteListedSite.getId(), manager, whiteListedSite);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -15,6 +15,7 @@
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package org.mitre.openid.connect.service.impl;
|
package org.mitre.openid.connect.service.impl;
|
||||||
|
|
||||||
|
import org.mitre.openid.connect.model.DefaultUserInfo;
|
||||||
import org.mitre.openid.connect.model.UserInfo;
|
import org.mitre.openid.connect.model.UserInfo;
|
||||||
import org.mitre.openid.connect.repository.UserInfoRepository;
|
import org.mitre.openid.connect.repository.UserInfoRepository;
|
||||||
import org.mitre.openid.connect.service.UserInfoService;
|
import org.mitre.openid.connect.service.UserInfoService;
|
||||||
|
@ -52,7 +53,7 @@ public class UserInfoServiceImpl implements UserInfoService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void save(UserInfo userInfo) {
|
public void save(DefaultUserInfo userInfo) {
|
||||||
userInfoRepository.save(userInfo);
|
userInfoRepository.save(userInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
<class>org.mitre.openid.connect.model.Event</class>
|
<class>org.mitre.openid.connect.model.Event</class>
|
||||||
<class>org.mitre.openid.connect.model.IdToken</class>
|
<class>org.mitre.openid.connect.model.IdToken</class>
|
||||||
<class>org.mitre.openid.connect.model.IdTokenClaims</class>
|
<class>org.mitre.openid.connect.model.IdTokenClaims</class>
|
||||||
<class>org.mitre.openid.connect.model.UserInfo</class>
|
<class>org.mitre.openid.connect.model.DefaultUserInfo</class>
|
||||||
<class>org.mitre.openid.connect.model.WhitelistedSite</class>
|
<class>org.mitre.openid.connect.model.WhitelistedSite</class>
|
||||||
</persistence-unit>
|
</persistence-unit>
|
||||||
</persistence>
|
</persistence>
|
||||||
|
|
Loading…
Reference in New Issue