001// Generated by delombok at Sun Apr 14 14:59:49 CEST 2024
002/*
003 * Copyright (c) 2010-2024 Mark Allen, Norbert Bartels.
004 *
005 * Permission is hereby granted, free of charge, to any person obtaining a copy
006 * of this software and associated documentation files (the "Software"), to deal
007 * in the Software without restriction, including without limitation the rights
008 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
009 * copies of the Software, and to permit persons to whom the Software is
010 * furnished to do so, subject to the following conditions:
011 *
012 * The above copyright notice and this permission notice shall be included in
013 * all copies or substantial portions of the Software.
014 *
015 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
016 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
017 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
018 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
019 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
020 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
021 * THE SOFTWARE.
022 */
023package com.restfb.types;
024
025import com.restfb.Facebook;
026import com.restfb.FacebookClient;
027import com.restfb.json.JsonObject;
028import java.util.ArrayList;
029import java.util.Date;
030import java.util.List;
031import static java.util.Collections.unmodifiableList;
032
033/**
034 * <p>
035 * Represents the result of a {@link FacebookClient#debugToken(String)} inquiry.
036 * </p>
037 * See <a href="https://developers.facebook.com/docs/howtos/login/debugging-access-tokens/">Debug access tokens</a>
038 *
039 * @author Broc Seib
040 */
041public class DebugTokenInfo extends AbstractFacebookType {
042    private static final long serialVersionUID = 1L;
043    /**
044     * The ID of the application this access token is for.
045     */
046    @Facebook("app_id")
047    private String appId;
048    /**
049     * Name of the application this access token is for.
050     */
051    @Facebook
052    private String application;
053    /**
054     * Timestamp when this access token expires.
055     */
056    @Facebook("expires_at")
057    private Date expiresAt;
058    /**
059     * Timestamp when app's access to user data expires.
060     */
061    @Facebook("data_access_expires_at")
062    private Date dataAccessExpiresAt;
063    /**
064     * The date on which the access token was issued.
065     */
066    @Facebook("issued_at")
067    private Date issuedAt;
068    /**
069     * Whether the token is valid.
070     */
071    @Facebook("is_valid")
072    private boolean isValid;
073    /**
074     * The ID of the user this access token is for.
075     */
076    @Facebook("user_id")
077    private String userId;
078    /**
079     * For impersonated access tokens, the ID of the page this token contains.
080     */
081    @Facebook("profile_id")
082    private String profileId;
083    /**
084     * General metadata associated with the access token. Can contain data like 'sso', 'auth_type', 'auth_nonce'
085     */
086    @Facebook
087    private JsonObject metadata;
088    /**
089     * Any error that a request to the graph api would return due to the access token.
090     */
091    @Facebook
092    private DebugTokenError error;
093    /**
094     * List of permissions that the user has granted for the app in this access token.
095     */
096    @Facebook
097    private List<String> scopes = new ArrayList<>();
098    /**
099     * List of granular permissions that the user has granted for this app in this access token.
100     */
101    @Facebook("granular_scopes")
102    private List<GranularScope> granularScopes = new ArrayList<>();
103    @Facebook
104    private String type;
105
106    /**
107     * The date on which the access token expires.
108     *
109     * @return The date on which the access token expires.
110     */
111    public Date getExpiresAt() {
112        if (expiresAt != null && expiresAt.getTime() == 0L) {
113            return null;
114        }
115        return expiresAt;
116    }
117
118    /**
119     * List of scopes the access token 'contains'
120     *
121     * @return list of scopes
122     */
123    public List<String> getScopes() {
124        return unmodifiableList(scopes);
125    }
126
127    /**
128     * List of granular scopes the access token 'contains'
129     *
130     * @return list of granular scopes
131     */
132    public List<GranularScope> getGranularScopes() {
133        return unmodifiableList(granularScopes);
134    }
135
136    /**
137     * All Error data associated with access token debug.
138     *
139     * @return debug token error
140     */
141    public DebugTokenError getDebugTokenError() {
142        return error;
143    }
144
145    /**
146     * The ID of the application this access token is for.
147     *
148     * @return The id of the application.
149     */
150    @java.lang.SuppressWarnings("all")
151    public String getAppId() {
152        return this.appId;
153    }
154
155    /**
156     * The ID of the application this access token is for.
157     */
158    @java.lang.SuppressWarnings("all")
159    public void setAppId(final String appId) {
160        this.appId = appId;
161    }
162
163    /**
164     * Name of the application this access token is for.
165     *
166     * @return The name of the application.
167     */
168    @java.lang.SuppressWarnings("all")
169    public String getApplication() {
170        return this.application;
171    }
172
173    /**
174     * Name of the application this access token is for.
175     */
176    @java.lang.SuppressWarnings("all")
177    public void setApplication(final String application) {
178        this.application = application;
179    }
180
181    /**
182     * Timestamp when app's access to user data expires.
183     *
184     * @return The date when app's access to user data expires.
185     */
186    @java.lang.SuppressWarnings("all")
187    public Date getDataAccessExpiresAt() {
188        return this.dataAccessExpiresAt;
189    }
190
191    /**
192     * Timestamp when app's access to user data expires.
193     */
194    @java.lang.SuppressWarnings("all")
195    public void setDataAccessExpiresAt(final Date dataAccessExpiresAt) {
196        this.dataAccessExpiresAt = dataAccessExpiresAt;
197    }
198
199    /**
200     * The date on which the access token was issued.
201     *
202     * @return The date on which the access token was issued.
203     */
204    @java.lang.SuppressWarnings("all")
205    public Date getIssuedAt() {
206        return this.issuedAt;
207    }
208
209    /**
210     * The date on which the access token was issued.
211     */
212    @java.lang.SuppressWarnings("all")
213    public void setIssuedAt(final Date issuedAt) {
214        this.issuedAt = issuedAt;
215    }
216
217    /**
218     * Whether the token is valid.
219     *
220     * @return Whether the token is valid.
221     */
222    @java.lang.SuppressWarnings("all")
223    public boolean isValid() {
224        return this.isValid;
225    }
226
227    /**
228     * Whether the token is valid.
229     */
230    @java.lang.SuppressWarnings("all")
231    public void setValid(final boolean isValid) {
232        this.isValid = isValid;
233    }
234
235    /**
236     * The ID of the user this access token is for.
237     *
238     * @return The user id.
239     */
240    @java.lang.SuppressWarnings("all")
241    public String getUserId() {
242        return this.userId;
243    }
244
245    /**
246     * The ID of the user this access token is for.
247     */
248    @java.lang.SuppressWarnings("all")
249    public void setUserId(final String userId) {
250        this.userId = userId;
251    }
252
253    /**
254     * For impersonated access tokens, the ID of the page this token contains.
255     *
256     * @return the profile id
257     */
258    @java.lang.SuppressWarnings("all")
259    public String getProfileId() {
260        return this.profileId;
261    }
262
263    /**
264     * For impersonated access tokens, the ID of the page this token contains.
265     */
266    @java.lang.SuppressWarnings("all")
267    public void setProfileId(final String profileId) {
268        this.profileId = profileId;
269    }
270
271    /**
272     * General metadata associated with the access token. Can contain data like 'sso', 'auth_type', 'auth_nonce'
273     *
274     * @return General metadata associated with the access token
275     */
276    @java.lang.SuppressWarnings("all")
277    public JsonObject getMetadata() {
278        return this.metadata;
279    }
280
281    /**
282     * General metadata associated with the access token. Can contain data like 'sso', 'auth_type', 'auth_nonce'
283     */
284    @java.lang.SuppressWarnings("all")
285    public void setMetadata(final JsonObject metadata) {
286        this.metadata = metadata;
287    }
288
289    @java.lang.SuppressWarnings("all")
290    public String getType() {
291        return this.type;
292    }
293
294    @java.lang.SuppressWarnings("all")
295    public void setType(final String type) {
296        this.type = type;
297    }
298}