001/*
002 * (C) Copyright 2006-2013 Nuxeo SA (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Nelson Silva <nelson.silva@inevo.pt> - initial API and implementation
016 *     Nuxeo
017 */
018package org.nuxeo.ecm.platform.oauth2.openid.auth.linkedin;
019
020import java.util.Date;
021import java.util.List;
022
023import org.nuxeo.ecm.platform.oauth2.openid.auth.OpenIDUserInfo;
024
025import com.google.api.client.json.GenericJson;
026import com.google.api.client.util.Key;
027
028public class LinkedInUserInfo extends GenericJson implements OpenIDUserInfo {
029
030    // These fields require the r_basicprofile member permission
031
032    @Key("id")
033    protected String subject;
034
035    @Key("formattedName")
036    protected String name;
037
038    @Key("firstName")
039    protected String givenName;
040
041    @Key("lastName")
042    protected String familyName;
043
044    @Key("publicProfileUrl")
045    protected String profile;
046
047    @Key("pictureUrl")
048    protected String picture;
049
050    // These fields require the r_emailaddress member permission
051
052    @Key("emailAddress")
053    protected String email;
054
055    // These fields require the r_fullprofile member permission
056
057    @Key("dateOfBirth")
058    protected Date birthdate;
059
060    // These fields require the r_contactinfo member permission
061
062    @Key("phoneNumbers")
063    protected List<String> phoneNumbers;
064
065    @Key("mainAddress")
066    protected String address;
067
068    // These fields are not available
069
070    @Key("middle_name")
071    protected String middleName;
072
073    @Key("nickname")
074    protected String nickname;
075
076    @Key("preferred_username")
077    protected String preferredUsername;
078
079    @Key("website")
080    protected String website;
081
082    @Key("verified_email")
083    protected boolean verifiedEmail;
084
085    @Key("gender")
086    protected String gender;
087
088    @Key("zoneinfo")
089    protected String zoneInfo;
090
091    @Key("locale")
092    protected String locale;
093
094    @Key("updated_time")
095    protected Date updatedTime;
096
097    @Override
098    public String getSubject() {
099        return subject;
100    }
101
102    @Override
103    public String getName() {
104        return name;
105    }
106
107    @Override
108    public String getGivenName() {
109        return givenName;
110    }
111
112    @Override
113    public String getFamilyName() {
114        return familyName;
115    }
116
117    @Override
118    public String getMiddleName() {
119        return middleName;
120    }
121
122    @Override
123    public String getNickname() {
124        return nickname;
125    }
126
127    @Override
128    public String getPreferredUsername() {
129        return preferredUsername;
130    }
131
132    @Override
133    public String getProfile() {
134        return profile;
135    }
136
137    @Override
138    public String getPicture() {
139        return picture;
140    }
141
142    @Override
143    public String getWebsite() {
144        return website;
145    }
146
147    @Override
148    public String getEmail() {
149        return email;
150    }
151
152    @Override
153    public boolean isEmailVerified() {
154        return verifiedEmail;
155    }
156
157    @Override
158    public String getGender() {
159        return gender;
160    }
161
162    @Override
163    public Date getBirthdate() {
164        return birthdate;
165    }
166
167    @Override
168    public String getZoneInfo() {
169        return zoneInfo;
170    }
171
172    @Override
173    public String getLocale() {
174        return locale;
175    }
176
177    @Override
178    public String getPhoneNumber() {
179        if (phoneNumbers == null || phoneNumbers.isEmpty()) {
180            return null;
181        }
182        return phoneNumbers.get(0);
183    }
184
185    @Override
186    public String getAddress() {
187        return address;
188    }
189
190    @Override
191    public Date getUpdatedTime() {
192        return updatedTime;
193    }
194}