|
| 1 | +package com.github.scribejava.apis.facebook; |
| 2 | + |
| 3 | +import com.github.scribejava.core.exceptions.OAuthException; |
| 4 | +import java.util.Objects; |
| 5 | + |
| 6 | +/** |
| 7 | + * non standard Facebook replace for {@link com.github.scribejava.core.model.OAuth2AccessTokenErrorResponse} |
| 8 | + * |
| 9 | + * examples:<br> |
| 10 | + * |
| 11 | + * '{"error":{"message":"This authorization code has been |
| 12 | + * used.","type":"OAuthException","code":100,"fbtrace_id":"DtxvtGRaxbB"}}'<br> |
| 13 | + * |
| 14 | + * '{"error":{"message":"Error validating application. Invalid application |
| 15 | + * ID.","type":"OAuthException","code":101,"fbtrace_id":"CvDR+X4WWIx"}}' |
| 16 | + */ |
| 17 | +public class FacebookAccessTokenErrorResponse extends OAuthException { |
| 18 | + |
| 19 | + private static final long serialVersionUID = -1277129766099856895L; |
| 20 | + |
| 21 | + private final String type; |
| 22 | + private final String code; |
| 23 | + private final String fbtraceId; |
| 24 | + private final String rawResponse; |
| 25 | + |
| 26 | + public FacebookAccessTokenErrorResponse(String message, String type, String code, String fbtraceId, |
| 27 | + String rawResponse) { |
| 28 | + super(message); |
| 29 | + this.type = type; |
| 30 | + this.code = code; |
| 31 | + this.fbtraceId = fbtraceId; |
| 32 | + this.rawResponse = rawResponse; |
| 33 | + } |
| 34 | + |
| 35 | + public String getType() { |
| 36 | + return type; |
| 37 | + } |
| 38 | + |
| 39 | + public String getCode() { |
| 40 | + return code; |
| 41 | + } |
| 42 | + |
| 43 | + public String getFbtraceId() { |
| 44 | + return fbtraceId; |
| 45 | + } |
| 46 | + |
| 47 | + public String getRawResponse() { |
| 48 | + return rawResponse; |
| 49 | + } |
| 50 | + |
| 51 | + @Override |
| 52 | + public int hashCode() { |
| 53 | + int hash = 5; |
| 54 | + hash = 83 * hash + Objects.hashCode(rawResponse); |
| 55 | + hash = 83 * hash + Objects.hashCode(getMessage()); |
| 56 | + hash = 83 * hash + Objects.hashCode(type); |
| 57 | + hash = 83 * hash + Objects.hashCode(code); |
| 58 | + hash = 83 * hash + Objects.hashCode(fbtraceId); |
| 59 | + return hash; |
| 60 | + } |
| 61 | + |
| 62 | + @Override |
| 63 | + public boolean equals(Object obj) { |
| 64 | + if (this == obj) { |
| 65 | + return true; |
| 66 | + } |
| 67 | + if (obj == null) { |
| 68 | + return false; |
| 69 | + } |
| 70 | + if (getClass() != obj.getClass()) { |
| 71 | + return false; |
| 72 | + } |
| 73 | + final FacebookAccessTokenErrorResponse other = (FacebookAccessTokenErrorResponse) obj; |
| 74 | + if (!Objects.equals(rawResponse, other.getRawResponse())) { |
| 75 | + return false; |
| 76 | + } |
| 77 | + if (!Objects.equals(getMessage(), other.getMessage())) { |
| 78 | + return false; |
| 79 | + } |
| 80 | + if (!Objects.equals(type, other.getType())) { |
| 81 | + return false; |
| 82 | + } |
| 83 | + if (!Objects.equals(code, other.getCode())) { |
| 84 | + return false; |
| 85 | + } |
| 86 | + return Objects.equals(fbtraceId, other.getFbtraceId()); |
| 87 | + } |
| 88 | + |
| 89 | + @Override |
| 90 | + public String toString() { |
| 91 | + return "FacebookAccessTokenErrorResponse{'type'='" + type + "', 'code'='" + code |
| 92 | + + "', 'fbtraceId'='" + fbtraceId + "', 'rawResponse'='" + rawResponse |
| 93 | + + "', 'message'='" + getMessage() + "'}"; |
| 94 | + } |
| 95 | +} |
0 commit comments