added phone-number verified, addresses #505

affects #455
pull/516/head
Justin Richer 2013-09-12 10:19:14 -04:00
parent 6cbed133b2
commit f9ca15139d
5 changed files with 62 additions and 21 deletions

View File

@ -56,6 +56,7 @@ public class DefaultUserInfo implements UserInfo {
private String zoneinfo;
private String locale;
private String phoneNumber;
private Boolean phoneNumberVerified;
private Address address;
private String updatedTime;
private String birthdate;
@ -332,6 +333,24 @@ public class DefaultUserInfo implements UserInfo {
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
/* (non-Javadoc)
* @see org.mitre.openid.connect.model.UserInfo#getPhoneNumberVerified()
*/
@Override
@Basic
@Column(name="phone_number_verified")
public Boolean getPhoneNumberVerified() {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see org.mitre.openid.connect.model.UserInfo#setPhoneNumberVerified(java.lang.Boolean)
*/
@Override
public void setPhoneNumberVerified(Boolean phoneNumberVerified) {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see org.mitre.openid.connect.model.UserInfo#getAddress()
*/
@ -411,7 +430,7 @@ public class DefaultUserInfo implements UserInfo {
ui.setEmailVerified(obj.has("email_verified") ? obj.get("email_verified").getAsBoolean() : null);
ui.setPhoneNumber(obj.has("phone_number") ? obj.get("phone_number").getAsString() : null);
ui.setPhoneNumberVerified(obj.has("phone_number_verified") ? obj.get("phone_number_verified").getAsBoolean() : null);
if (obj.has("address") && obj.get("address").isJsonObject()) {
JsonObject addr = obj.get("address").getAsJsonObject();
@ -451,6 +470,7 @@ public class DefaultUserInfo implements UserInfo {
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((nickname == null) ? 0 : nickname.hashCode());
result = prime * result + ((phoneNumber == null) ? 0 : phoneNumber.hashCode());
result = prime * result + ((phoneNumberVerified == null) ? 0 : phoneNumberVerified.hashCode());
result = prime * result + ((picture == null) ? 0 : picture.hashCode());
result = prime * result + ((preferredUsername == null) ? 0 : preferredUsername.hashCode());
result = prime * result + ((profile == null) ? 0 : profile.hashCode());
@ -567,6 +587,13 @@ public class DefaultUserInfo implements UserInfo {
} else if (!phoneNumber.equals(other.phoneNumber)) {
return false;
}
if (phoneNumberVerified == null) {
if (other.phoneNumberVerified != null) {
return false;
}
} else if (!phoneNumberVerified.equals(other.phoneNumberVerified)) {
return false;
}
if (picture == null) {
if (other.picture != null) {
return false;

View File

@ -178,6 +178,17 @@ public interface UserInfo {
* @param phoneNumber the phoneNumber to set
*/
public abstract void setPhoneNumber(String phoneNumber);
/**
*
*/
public abstract Boolean getPhoneNumberVerified();
/**
*
* @param phoneNumberVerified
*/
public abstract void setPhoneNumberVerified(Boolean phoneNumberVerified);
/**
* @return the address

View File

@ -57,6 +57,26 @@ public class UserInfoView extends AbstractView {
private static Logger logger = LoggerFactory.getLogger(UserInfoView.class);
private Gson gson = new GsonBuilder()
.setExclusionStrategies(new ExclusionStrategy() {
@Override
public boolean shouldSkipField(FieldAttributes f) {
return false;
}
@Override
public boolean shouldSkipClass(Class<?> clazz) {
// skip the JPA binding wrapper
if (clazz.equals(BeanPropertyBindingResult.class)) {
return true;
}
return false;
}
}).create();
/* (non-Javadoc)
* @see org.springframework.web.servlet.view.AbstractView#renderMergedOutputModel(java.util.Map, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
@ -82,26 +102,6 @@ public class UserInfoView extends AbstractView {
}
Gson gson = new GsonBuilder()
.setExclusionStrategies(new ExclusionStrategy() {
@Override
public boolean shouldSkipField(FieldAttributes f) {
return false;
}
@Override
public boolean shouldSkipClass(Class<?> clazz) {
// skip the JPA binding wrapper
if (clazz.equals(BeanPropertyBindingResult.class)) {
return true;
}
return false;
}
}).create();
response.setContentType("application/json");
Writer out;
@ -174,6 +174,7 @@ public class UserInfoView extends AbstractView {
if (scope.contains("phone")) {
obj.addProperty("phone_number", ui.getPhoneNumber());
obj.addProperty("phone_number_verified", ui.getPhoneNumberVerified());
}
if (scope.contains("address") && ui.getAddress() != null) {

View File

@ -188,6 +188,7 @@ CREATE TABLE IF NOT EXISTS user_info (
zone_info VARCHAR(256),
locale VARCHAR(256),
phone_number VARCHAR(256),
phone_number_verified BOOLEAN,
address_id VARCHAR(256),
updated_time VARCHAR(256),
birthdate VARCHAR(256)

View File

@ -188,6 +188,7 @@ CREATE TABLE IF NOT EXISTS user_info (
zone_info VARCHAR(256),
locale VARCHAR(256),
phone_number VARCHAR(256),
phone_number_verified BOOLEAN,
address_id VARCHAR(256),
updated_time VARCHAR(256),
birthdate VARCHAR(256)