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 21b64b9d5..0c5aa5db4 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 @@ -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; diff --git a/openid-connect-common/src/main/java/org/mitre/openid/connect/model/UserInfo.java b/openid-connect-common/src/main/java/org/mitre/openid/connect/model/UserInfo.java index 8eb947c94..341a4f90d 100644 --- a/openid-connect-common/src/main/java/org/mitre/openid/connect/model/UserInfo.java +++ b/openid-connect-common/src/main/java/org/mitre/openid/connect/model/UserInfo.java @@ -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 diff --git a/openid-connect-server/src/main/java/org/mitre/openid/connect/view/UserInfoView.java b/openid-connect-server/src/main/java/org/mitre/openid/connect/view/UserInfoView.java index d0a551450..829642695 100644 --- a/openid-connect-server/src/main/java/org/mitre/openid/connect/view/UserInfoView.java +++ b/openid-connect-server/src/main/java/org/mitre/openid/connect/view/UserInfoView.java @@ -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) { diff --git a/openid-connect-server/src/main/resources/db/tables/hsql_database_tables.sql b/openid-connect-server/src/main/resources/db/tables/hsql_database_tables.sql index fdf474217..7ec5e0453 100644 --- a/openid-connect-server/src/main/resources/db/tables/hsql_database_tables.sql +++ b/openid-connect-server/src/main/resources/db/tables/hsql_database_tables.sql @@ -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) diff --git a/openid-connect-server/src/main/resources/db/tables/mysql_database_tables.sql b/openid-connect-server/src/main/resources/db/tables/mysql_database_tables.sql index 5ac865435..08d3862f6 100644 --- a/openid-connect-server/src/main/resources/db/tables/mysql_database_tables.sql +++ b/openid-connect-server/src/main/resources/db/tables/mysql_database_tables.sql @@ -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)