Made interfaces... deleted a thing.
parent
ffe31e6049
commit
fd91c884bb
|
@ -47,7 +47,7 @@ public class ApprovedSite {
|
|||
private Long id;
|
||||
|
||||
// which user made the approval
|
||||
private UserInfo userInfo;
|
||||
private String userInfo;
|
||||
|
||||
// which OAuth2 client is this tied to
|
||||
private ClientDetailsEntity clientDetails;
|
||||
|
@ -93,16 +93,15 @@ public class ApprovedSite {
|
|||
/**
|
||||
* @return the userInfo
|
||||
*/
|
||||
@ManyToOne
|
||||
@JoinColumn(name="userinfo_id")
|
||||
public UserInfo getUserInfo() {
|
||||
@Basic
|
||||
public String getUserInfo() {
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param userInfo the userInfo to set
|
||||
*/
|
||||
public void setUserInfo(UserInfo userInfo) {
|
||||
public void setUserInfo(String 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;
|
||||
|
||||
import javax.persistence.Basic;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Inheritance;
|
||||
import javax.persistence.InheritanceType;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.NamedQueries;
|
||||
import javax.persistence.NamedQuery;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
@Entity
|
||||
@Table(name="userinfo")
|
||||
@NamedQueries({
|
||||
@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;
|
||||
}
|
||||
|
||||
@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
|
||||
public interface UserInfo {
|
||||
|
||||
/**
|
||||
* @return the userId
|
||||
*/
|
||||
@Id
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
public abstract String getUserId();
|
||||
|
||||
/**
|
||||
* @param userId the userId to set
|
||||
*/
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
public abstract void setUserId(String userId);
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
@Basic
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public abstract String getName();
|
||||
|
||||
/**
|
||||
* @param name the name to set
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public abstract void setName(String name);
|
||||
|
||||
/**
|
||||
* @return the givenName
|
||||
*/
|
||||
@Basic
|
||||
public String getGivenName() {
|
||||
return givenName;
|
||||
}
|
||||
public abstract String getGivenName();
|
||||
|
||||
/**
|
||||
* @param givenName the givenName to set
|
||||
*/
|
||||
public void setGivenName(String givenName) {
|
||||
this.givenName = givenName;
|
||||
}
|
||||
public abstract void setGivenName(String givenName);
|
||||
|
||||
/**
|
||||
* @return the familyName
|
||||
*/
|
||||
@Basic
|
||||
public String getFamilyName() {
|
||||
return familyName;
|
||||
}
|
||||
public abstract String getFamilyName();
|
||||
|
||||
/**
|
||||
* @param familyName the familyName to set
|
||||
*/
|
||||
public void setFamilyName(String familyName) {
|
||||
this.familyName = familyName;
|
||||
}
|
||||
public abstract void setFamilyName(String familyName);
|
||||
|
||||
/**
|
||||
* @return the middleName
|
||||
*/
|
||||
@Basic
|
||||
public String getMiddleName() {
|
||||
return middleName;
|
||||
}
|
||||
public abstract String getMiddleName();
|
||||
|
||||
/**
|
||||
* @param middleName the middleName to set
|
||||
*/
|
||||
public void setMiddleName(String middleName) {
|
||||
this.middleName = middleName;
|
||||
}
|
||||
public abstract void setMiddleName(String middleName);
|
||||
|
||||
/**
|
||||
* @return the nickname
|
||||
*/
|
||||
@Basic
|
||||
public String getNickname() {
|
||||
return nickname;
|
||||
}
|
||||
public abstract String getNickname();
|
||||
|
||||
/**
|
||||
* @param nickname the nickname to set
|
||||
*/
|
||||
public void setNickname(String nickname) {
|
||||
this.nickname = nickname;
|
||||
}
|
||||
public abstract void setNickname(String nickname);
|
||||
|
||||
/**
|
||||
* @return the profile
|
||||
*/
|
||||
@Basic
|
||||
public String getProfile() {
|
||||
return profile;
|
||||
}
|
||||
public abstract String getProfile();
|
||||
|
||||
/**
|
||||
* @param profile the profile to set
|
||||
*/
|
||||
public void setProfile(String profile) {
|
||||
this.profile = profile;
|
||||
}
|
||||
public abstract void setProfile(String profile);
|
||||
|
||||
/**
|
||||
* @return the picture
|
||||
*/
|
||||
@Basic
|
||||
public String getPicture() {
|
||||
return picture;
|
||||
}
|
||||
public abstract String getPicture();
|
||||
|
||||
/**
|
||||
* @param picture the picture to set
|
||||
*/
|
||||
public void setPicture(String picture) {
|
||||
this.picture = picture;
|
||||
}
|
||||
public abstract void setPicture(String picture);
|
||||
|
||||
/**
|
||||
* @return the website
|
||||
*/
|
||||
@Basic
|
||||
public String getWebsite() {
|
||||
return website;
|
||||
}
|
||||
public abstract String getWebsite();
|
||||
|
||||
/**
|
||||
* @param website the website to set
|
||||
*/
|
||||
public void setWebsite(String website) {
|
||||
this.website = website;
|
||||
}
|
||||
public abstract void setWebsite(String website);
|
||||
|
||||
/**
|
||||
* @return the email
|
||||
*/
|
||||
@Basic
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
public abstract String getEmail();
|
||||
|
||||
/**
|
||||
* @param email the email to set
|
||||
*/
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
public abstract void setEmail(String email);
|
||||
|
||||
/**
|
||||
* @return the verified
|
||||
*/
|
||||
@Basic
|
||||
public Boolean getVerified() {
|
||||
return verified;
|
||||
}
|
||||
public abstract Boolean getVerified();
|
||||
|
||||
/**
|
||||
* @param verified the verified to set
|
||||
*/
|
||||
public void setVerified(Boolean verified) {
|
||||
this.verified = verified;
|
||||
}
|
||||
public abstract void setVerified(Boolean verified);
|
||||
|
||||
/**
|
||||
* @return the gender
|
||||
*/
|
||||
@Basic
|
||||
public String getGender() {
|
||||
return gender;
|
||||
}
|
||||
public abstract String getGender();
|
||||
|
||||
/**
|
||||
* @param gender the gender to set
|
||||
*/
|
||||
public void setGender(String gender) {
|
||||
this.gender = gender;
|
||||
}
|
||||
public abstract void setGender(String gender);
|
||||
|
||||
/**
|
||||
* @return the zoneinfo
|
||||
*/
|
||||
@Basic
|
||||
public String getZoneinfo() {
|
||||
return zoneinfo;
|
||||
}
|
||||
public abstract String getZoneinfo();
|
||||
|
||||
/**
|
||||
* @param zoneinfo the zoneinfo to set
|
||||
*/
|
||||
public void setZoneinfo(String zoneinfo) {
|
||||
this.zoneinfo = zoneinfo;
|
||||
}
|
||||
public abstract void setZoneinfo(String zoneinfo);
|
||||
|
||||
/**
|
||||
* @return the locale
|
||||
*/
|
||||
@Basic
|
||||
public String getLocale() {
|
||||
return locale;
|
||||
}
|
||||
public abstract String getLocale();
|
||||
|
||||
/**
|
||||
* @param locale the locale to set
|
||||
*/
|
||||
public void setLocale(String locale) {
|
||||
this.locale = locale;
|
||||
}
|
||||
public abstract void setLocale(String locale);
|
||||
|
||||
/**
|
||||
* @return the phoneNumber
|
||||
*/
|
||||
@Basic
|
||||
public String getPhoneNumber() {
|
||||
return phoneNumber;
|
||||
}
|
||||
public abstract String getPhoneNumber();
|
||||
|
||||
/**
|
||||
* @param phoneNumber the phoneNumber to set
|
||||
*/
|
||||
public void setPhoneNumber(String phoneNumber) {
|
||||
this.phoneNumber = phoneNumber;
|
||||
}
|
||||
public abstract void setPhoneNumber(String phoneNumber);
|
||||
|
||||
/**
|
||||
* @return the address
|
||||
*/
|
||||
@OneToOne
|
||||
@JoinColumn(name="address_id")
|
||||
public Address getAddress() {
|
||||
return address;
|
||||
}
|
||||
public abstract Address getAddress();
|
||||
|
||||
/**
|
||||
* @param address the address to set
|
||||
*/
|
||||
public void setAddress(Address address) {
|
||||
this.address = address;
|
||||
}
|
||||
public abstract void setAddress(Address address);
|
||||
|
||||
/**
|
||||
* @return the updatedTime
|
||||
*/
|
||||
@Basic
|
||||
public String getUpdatedTime() {
|
||||
return updatedTime;
|
||||
}
|
||||
public abstract String getUpdatedTime();
|
||||
|
||||
/**
|
||||
* @param updatedTime the updatedTime to set
|
||||
*/
|
||||
public void setUpdatedTime(String updatedTime) {
|
||||
this.updatedTime = updatedTime;
|
||||
}
|
||||
|
||||
}
|
||||
public abstract void setUpdatedTime(String updatedTime);
|
||||
|
||||
}
|
|
@ -17,6 +17,7 @@ package org.mitre.openid.connect.model;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.persistence.Basic;
|
||||
import javax.persistence.ElementCollection;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
|
@ -48,7 +49,7 @@ public class WhitelistedSite {
|
|||
private Long id;
|
||||
|
||||
// who added this site to the whitelist (should be an admin)
|
||||
private UserInfo userInfo;
|
||||
private String userInfo;
|
||||
|
||||
// which OAuth2 client is this tied to
|
||||
private ClientDetailsEntity clientDetails;
|
||||
|
@ -83,16 +84,15 @@ public class WhitelistedSite {
|
|||
/**
|
||||
* @return the userInfo
|
||||
*/
|
||||
@ManyToOne
|
||||
@JoinColumn(name="userinfo_id")
|
||||
public UserInfo getUserInfo() {
|
||||
@Basic
|
||||
public String getUserInfo() {
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param userInfo the userInfo to set
|
||||
*/
|
||||
public void setUserInfo(UserInfo userInfo) {
|
||||
public void setUserInfo(String userInfo) {
|
||||
this.userInfo = userInfo;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ package org.mitre.openid.connect.repository;
|
|||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.mitre.openid.connect.model.DefaultUserInfo;
|
||||
import org.mitre.openid.connect.model.UserInfo;
|
||||
|
||||
/**
|
||||
|
@ -42,7 +43,7 @@ public interface UserInfoRepository {
|
|||
* @param user
|
||||
* @return
|
||||
*/
|
||||
public UserInfo save(UserInfo userInfo);
|
||||
public UserInfo save(DefaultUserInfo userInfo);
|
||||
|
||||
/**
|
||||
* Removes the given UserInfo from the repository
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
******************************************************************************/
|
||||
package org.mitre.openid.connect.service;
|
||||
|
||||
import org.mitre.openid.connect.model.DefaultUserInfo;
|
||||
import org.mitre.openid.connect.model.UserInfo;
|
||||
|
||||
/**
|
||||
|
@ -31,7 +32,7 @@ public interface UserInfoService {
|
|||
* @param userInfo
|
||||
* the UserInfo to be saved
|
||||
*/
|
||||
public void save(UserInfo userInfo);
|
||||
public void save(DefaultUserInfo userInfo);
|
||||
|
||||
/**
|
||||
* Get UserInfo for user id
|
||||
|
|
|
@ -76,7 +76,7 @@ public class JpaApprovedSiteRepository implements ApprovedSiteRepository {
|
|||
public Collection<ApprovedSite> getByUserInfo(UserInfo userInfo) {
|
||||
TypedQuery<ApprovedSite> query = manager.createNamedQuery(
|
||||
"ApprovedSite.getByUserInfo", ApprovedSite.class);
|
||||
query.setParameter("approvedSiteUserInfo", userInfo);
|
||||
query.setParameter("approvedSiteUserInfo", userInfo.getUserId());
|
||||
|
||||
List<ApprovedSite> found = query.getResultList();
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import javax.persistence.EntityManager;
|
|||
import javax.persistence.PersistenceContext;
|
||||
import javax.persistence.TypedQuery;
|
||||
|
||||
import org.mitre.openid.connect.model.DefaultUserInfo;
|
||||
import org.mitre.openid.connect.model.UserInfo;
|
||||
import org.mitre.openid.connect.repository.UserInfoRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
@ -43,12 +44,12 @@ public class JpaUserInfoRepository implements UserInfoRepository {
|
|||
@Override
|
||||
@Transactional
|
||||
public UserInfo getByUserId(String userId) {
|
||||
return manager.find(UserInfo.class, userId);
|
||||
return manager.find(DefaultUserInfo.class, userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public UserInfo save(UserInfo userInfo) {
|
||||
public UserInfo save(DefaultUserInfo userInfo) {
|
||||
return saveOrUpdate(userInfo.getUserId(), manager, userInfo);
|
||||
}
|
||||
|
||||
|
@ -56,7 +57,7 @@ public class JpaUserInfoRepository implements UserInfoRepository {
|
|||
@Transactional
|
||||
public void remove(UserInfo userInfo) {
|
||||
|
||||
UserInfo found = manager.find(UserInfo.class, userInfo.getUserId());
|
||||
UserInfo found = manager.find(DefaultUserInfo.class, userInfo.getUserId());
|
||||
|
||||
if (found != null) {
|
||||
manager.remove(userInfo);
|
||||
|
@ -68,7 +69,7 @@ public class JpaUserInfoRepository implements UserInfoRepository {
|
|||
@Override
|
||||
@Transactional
|
||||
public void removeByUserId(String userId) {
|
||||
UserInfo found = manager.find(UserInfo.class, userId);
|
||||
UserInfo found = manager.find(DefaultUserInfo.class, userId);
|
||||
|
||||
if (found != null) {
|
||||
manager.remove(found);
|
||||
|
@ -79,10 +80,10 @@ public class JpaUserInfoRepository implements UserInfoRepository {
|
|||
|
||||
@Override
|
||||
@Transactional
|
||||
public Collection<UserInfo> getAll() {
|
||||
public Collection<DefaultUserInfo> getAll() {
|
||||
|
||||
TypedQuery<UserInfo> query = manager.createNamedQuery(
|
||||
"UserInfo.getAll", UserInfo.class);
|
||||
TypedQuery<DefaultUserInfo> query = manager.createNamedQuery(
|
||||
"DefaultUserInfo.getAll", DefaultUserInfo.class);
|
||||
|
||||
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;
|
||||
|
||||
import org.mitre.openid.connect.model.DefaultUserInfo;
|
||||
import org.mitre.openid.connect.model.UserInfo;
|
||||
import org.mitre.openid.connect.repository.UserInfoRepository;
|
||||
import org.mitre.openid.connect.service.UserInfoService;
|
||||
|
@ -52,7 +53,7 @@ public class UserInfoServiceImpl implements UserInfoService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void save(UserInfo userInfo) {
|
||||
public void save(DefaultUserInfo userInfo) {
|
||||
userInfoRepository.save(userInfo);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<class>org.mitre.openid.connect.model.Event</class>
|
||||
<class>org.mitre.openid.connect.model.IdToken</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>
|
||||
</persistence-unit>
|
||||
</persistence>
|
||||
|
|
Loading…
Reference in New Issue