001package org.nuxeo.ecm.platform.oauth2.openid.auth.googleplus; 002 003import java.util.Date; 004import java.util.List; 005 006import org.nuxeo.ecm.platform.oauth2.openid.auth.OpenIDUserInfo; 007 008import com.google.api.client.json.GenericJson; 009import com.google.api.client.util.ArrayMap; 010import com.google.api.client.util.Key; 011 012/** 013 * GooglePlus user info 014 * 015 * @author <a href="mailto:ak@nuxeo.com">Arnaud Kervern</a> 016 * @since 5.9.5 017 */ 018public class GooglePlusUserInfo extends GenericJson implements OpenIDUserInfo { 019 @Key("id") 020 protected String id; 021 022 @Key("displayName") 023 protected String name; 024 025 @Key("verified") 026 protected boolean verified; 027 028 @Key("gender") 029 protected String gender; 030 031 @Override 032 public String getSubject() { 033 return id; 034 } 035 036 @Override 037 public String getName() { 038 return name; 039 } 040 041 @Override 042 public String getGivenName() { 043 ArrayMap<String, Object> nameObject = getNameObject(); 044 return nameObject == null ? "" : String.valueOf(nameObject.get("givenName")); 045 } 046 047 @Override 048 public String getFamilyName() { 049 ArrayMap<String, Object> nameObject = getNameObject(); 050 return nameObject == null ? "" : String.valueOf(nameObject.get("familyName")); 051 } 052 053 @Override 054 public String getMiddleName() { 055 return null; 056 } 057 058 @Override 059 public String getNickname() { 060 return null; 061 } 062 063 @Override 064 public String getPreferredUsername() { 065 return getGivenName(); 066 } 067 068 @Override 069 public String getProfile() { 070 return null; 071 } 072 073 @Override 074 public String getPicture() { 075 return null; 076 } 077 078 @Override 079 public String getWebsite() { 080 return null; 081 } 082 083 @Override 084 public String getEmail() { 085 return String.valueOf(getEmailsObject().get(0).get("value")); 086 } 087 088 @Override 089 public boolean isEmailVerified() { 090 return verified; 091 } 092 093 @Override 094 public String getGender() { 095 return gender; 096 } 097 098 @Override 099 public Date getBirthdate() { 100 return null; 101 } 102 103 @Override 104 public String getZoneInfo() { 105 return null; 106 } 107 108 @Override 109 public String getLocale() { 110 return null; 111 } 112 113 @Override 114 public String getPhoneNumber() { 115 return null; 116 } 117 118 @Override 119 public String getAddress() { 120 return null; 121 } 122 123 @Override 124 public Date getUpdatedTime() { 125 return null; 126 } 127 128 protected ArrayMap<String, Object> getNameObject() { 129 return (ArrayMap<String, Object>) get("name"); 130 } 131 132 protected List<ArrayMap<String, Object>> getEmailsObject() { 133 return (List<ArrayMap<String, Object>>) get("emails"); 134 } 135}