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 */
020
021package org.nuxeo.ecm.platform.oauth2.openid.auth;
022
023import java.util.Date;
024import com.google.api.client.json.GenericJson;
025import com.google.api.client.util.DateTime;
026import com.google.api.client.util.Key;
027
028public class DefaultOpenIDUserInfo extends GenericJson implements OpenIDUserInfo {
029
030    @Key("sub")
031    protected String subject;
032
033    @Key("name")
034    protected String name;
035
036    @Key("given_name")
037    protected String givenName;
038
039    @Key("family_name")
040    protected String familyName;
041
042    @Key("middle_name")
043    protected String middleName;
044
045    @Key("nickname")
046    protected String nickname;
047
048    @Key("preferred_username")
049    protected String preferredUsername;
050
051    @Key("profile")
052    protected String profile;
053
054    @Key("picture")
055    protected String picture;
056
057    @Key("website")
058    protected String website;
059
060    @Key("email")
061    protected String email;
062
063    @Key("email_verified")
064    protected boolean emailVerified;
065
066    @Key("gender")
067    protected String gender;
068
069    @Key("birthdate")
070    protected Date birthdate;
071
072    @Key("zoneinfo")
073    protected String zoneInfo;
074
075    @Key("locale")
076    protected String locale;
077
078    @Key("phone_number")
079    protected String phoneNumber;
080
081    @Key("address")
082    protected String address;
083
084    @Key("updated_time")
085    protected String updatedTime;
086
087    @Override
088    public String getSubject() {
089        return subject;
090    }
091
092    @Override
093    public String getName() {
094        return name;
095    }
096
097    @Override
098    public String getGivenName() {
099        return givenName;
100    }
101
102    @Override
103    public String getFamilyName() {
104        return familyName;
105    }
106
107    @Override
108    public String getMiddleName() {
109        return middleName;
110    }
111
112    @Override
113    public String getNickname() {
114        return nickname;
115    }
116
117    @Override
118    public String getPreferredUsername() {
119        return preferredUsername;
120    }
121
122    @Override
123    public String getProfile() {
124        return profile;
125    }
126
127    @Override
128    public String getPicture() {
129        return picture;
130    }
131
132    @Override
133    public String getWebsite() {
134        return website;
135    }
136
137    @Override
138    public String getEmail() {
139        return email;
140    }
141
142    @Override
143    public boolean isEmailVerified() {
144        return emailVerified;
145    }
146
147    @Override
148    public String getGender() {
149        return gender;
150    }
151
152    @Override
153    public Date getBirthdate() {
154        return birthdate;
155    }
156
157    @Override
158    public String getZoneInfo() {
159        return zoneInfo;
160    }
161
162    @Override
163    public String getLocale() {
164        return locale;
165    }
166
167    @Override
168    public String getPhoneNumber() {
169        return phoneNumber;
170    }
171
172    @Override
173    public String getAddress() {
174        return address;
175    }
176
177    @Override
178    public Date getUpdatedTime() {
179        Date date;
180        try {
181            DateTime dateTime = DateTime.parseRfc3339(updatedTime);
182            date = new Date(dateTime.getValue());
183        } catch (NumberFormatException e) {
184            return null;
185        }
186        return date;
187    }
188
189}