001/*
002 * (C) Copyright 2006-2013 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Nelson Silva <nelson.silva@inevo.pt> - initial API and implementation
018 *     Nuxeo
019 */
020package org.nuxeo.ecm.platform.oauth2.openid.auth.linkedin;
021
022import java.util.Date;
023import java.util.List;
024
025import org.nuxeo.ecm.platform.oauth2.openid.auth.OpenIDUserInfo;
026
027import com.google.api.client.json.GenericJson;
028import com.google.api.client.util.Key;
029
030public class LinkedInUserInfo extends GenericJson implements OpenIDUserInfo {
031
032    // These fields require the r_basicprofile member permission
033
034    @Key("id")
035    protected String subject;
036
037    @Key("formattedName")
038    protected String name;
039
040    @Key("firstName")
041    protected String givenName;
042
043    @Key("lastName")
044    protected String familyName;
045
046    @Key("publicProfileUrl")
047    protected String profile;
048
049    @Key("pictureUrl")
050    protected String picture;
051
052    // These fields require the r_emailaddress member permission
053
054    @Key("emailAddress")
055    protected String email;
056
057    // These fields require the r_fullprofile member permission
058
059    @Key("dateOfBirth")
060    protected Date birthdate;
061
062    // These fields require the r_contactinfo member permission
063
064    @Key("phoneNumbers")
065    protected List<String> phoneNumbers;
066
067    @Key("mainAddress")
068    protected String address;
069
070    // These fields are not available
071
072    @Key("middle_name")
073    protected String middleName;
074
075    @Key("nickname")
076    protected String nickname;
077
078    @Key("preferred_username")
079    protected String preferredUsername;
080
081    @Key("website")
082    protected String website;
083
084    @Key("verified_email")
085    protected boolean verifiedEmail;
086
087    @Key("gender")
088    protected String gender;
089
090    @Key("zoneinfo")
091    protected String zoneInfo;
092
093    @Key("locale")
094    protected String locale;
095
096    @Key("updated_time")
097    protected Date updatedTime;
098
099    @Override
100    public String getSubject() {
101        return subject;
102    }
103
104    @Override
105    public String getName() {
106        return name;
107    }
108
109    @Override
110    public String getGivenName() {
111        return givenName;
112    }
113
114    @Override
115    public String getFamilyName() {
116        return familyName;
117    }
118
119    @Override
120    public String getMiddleName() {
121        return middleName;
122    }
123
124    @Override
125    public String getNickname() {
126        return nickname;
127    }
128
129    @Override
130    public String getPreferredUsername() {
131        return preferredUsername;
132    }
133
134    @Override
135    public String getProfile() {
136        return profile;
137    }
138
139    @Override
140    public String getPicture() {
141        return picture;
142    }
143
144    @Override
145    public String getWebsite() {
146        return website;
147    }
148
149    @Override
150    public String getEmail() {
151        return email;
152    }
153
154    @Override
155    public boolean isEmailVerified() {
156        return verifiedEmail;
157    }
158
159    @Override
160    public String getGender() {
161        return gender;
162    }
163
164    @Override
165    public Date getBirthdate() {
166        return birthdate;
167    }
168
169    @Override
170    public String getZoneInfo() {
171        return zoneInfo;
172    }
173
174    @Override
175    public String getLocale() {
176        return locale;
177    }
178
179    @Override
180    public String getPhoneNumber() {
181        if (phoneNumbers == null || phoneNumbers.isEmpty()) {
182            return null;
183        }
184        return phoneNumbers.get(0);
185    }
186
187    @Override
188    public String getAddress() {
189        return address;
190    }
191
192    @Override
193    public Date getUpdatedTime() {
194        return updatedTime;
195    }
196}